Class: Commands::AbstractSSHCommand
Direct Known Subclasses
GetCommand, LogsCommand, PrintHiveVersionCommand, PutCommand, SSHCommand
Constant Summary collapse
- CLOSED_DOWN_STATES =
Set.new(%w(TERMINATED SHUTTING_DOWN COMPLETED FAILED))
- WAITING_OR_RUNNING_STATES =
Set.new(%w(WAITING RUNNING))
Instance Attribute Summary collapse
-
#dest ⇒ Object
Returns the value of attribute dest.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#jobflow_detail ⇒ Object
Returns the value of attribute jobflow_detail.
-
#jobflow_id ⇒ Object
Returns the value of attribute jobflow_id.
-
#key_pair_file ⇒ Object
Returns the value of attribute key_pair_file.
-
#no_wait ⇒ Object
Returns the value of attribute no_wait.
Attributes inherited from Command
#arg, #commands, #description, #logger, #name
Instance Method Summary collapse
Methods inherited from Command
#get_field, #has_value, #have, #initialize, #option, #require, #require_single_jobflow, #resolve, #validate
Constructor Details
This class inherits a constructor from Commands::Command
Instance Attribute Details
#dest ⇒ Object
Returns the value of attribute dest.
572 573 574 |
# File 'lib/commands.rb', line 572 def dest @dest end |
#hostname ⇒ Object
Returns the value of attribute hostname.
572 573 574 |
# File 'lib/commands.rb', line 572 def hostname @hostname end |
#jobflow_detail ⇒ Object
Returns the value of attribute jobflow_detail.
572 573 574 |
# File 'lib/commands.rb', line 572 def jobflow_detail @jobflow_detail end |
#jobflow_id ⇒ Object
Returns the value of attribute jobflow_id.
572 573 574 |
# File 'lib/commands.rb', line 572 def jobflow_id @jobflow_id end |
#key_pair_file ⇒ Object
Returns the value of attribute key_pair_file.
572 573 574 |
# File 'lib/commands.rb', line 572 def key_pair_file @key_pair_file end |
#no_wait ⇒ Object
Returns the value of attribute no_wait.
572 573 574 |
# File 'lib/commands.rb', line 572 def no_wait @no_wait end |
Instance Method Details
#enact(client) ⇒ Object
596 597 598 599 600 601 602 603 604 |
# File 'lib/commands.rb', line 596 def enact(client) self.jobflow_id = require_single_jobflow self.jobflow_detail = client.describe_jobflow_with_id(self.jobflow_id) if ! get_field(:no_wait) then wait_for_jobflow(client) end self.hostname = self.jobflow_detail['Instances']['MasterPublicDnsName'] self.key_pair_file = require(:key_pair_file, "Missing required option --key-pair-file for #{name}") end |
#exec(cmd) ⇒ Object
577 578 579 |
# File 'lib/commands.rb', line 577 def exec(cmd) commands.exec(cmd) end |
#wait_for_jobflow(client) ⇒ Object
581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/commands.rb', line 581 def wait_for_jobflow(client) while true do state = resolve(self.jobflow_detail, "ExecutionStatusDetail", "State") if WAITING_OR_RUNNING_STATES.include?(state) then break elsif CLOSED_DOWN_STATES.include?(state) then raise RuntimeError, "Jobflow entered #{state} while waiting to ssh" else logger.info("Jobflow is in state #{state}, waiting....") sleep(30) self.jobflow_detail = client.describe_jobflow_with_id(jobflow_id) end end end |