Class: TrainPlugins::AWSSSM::Connection
- Inherits:
-
Train::Plugins::Transport::BaseConnection
- Object
- Train::Plugins::Transport::BaseConnection
- TrainPlugins::AWSSSM::Connection
- Defined in:
- lib/train-awsssm/connection.rb
Instance Attribute Summary collapse
-
#ec2 ⇒ Object
writeonly
Sets the attribute ec2.
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#instances ⇒ Object
writeonly
Sets the attribute instances.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#ssm ⇒ Object
writeonly
Sets the attribute ssm.
Instance Method Summary collapse
- #close ⇒ Object
- #execute_on_channel(cmd, &data_handler) ⇒ Object
- #file_via_connection(path, *args) ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #run_command_via_connection(cmd, &data_handler) ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
12 13 14 15 16 |
# File 'lib/train-awsssm/connection.rb', line 12 def initialize() super() end |
Instance Attribute Details
#ec2=(value) ⇒ Object
Sets the attribute ec2
10 11 12 |
# File 'lib/train-awsssm/connection.rb', line 10 def ec2=(value) @ec2 = value end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
9 10 11 |
# File 'lib/train-awsssm/connection.rb', line 9 def instance_id @instance_id end |
#instances=(value) ⇒ Object
Sets the attribute instances
10 11 12 |
# File 'lib/train-awsssm/connection.rb', line 10 def instances=(value) @instances = value end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/train-awsssm/connection.rb', line 9 def @options end |
#ssm=(value) ⇒ Object
Sets the attribute ssm
10 11 12 |
# File 'lib/train-awsssm/connection.rb', line 10 def ssm=(value) @ssm = value end |
Instance Method Details
#close ⇒ Object
18 19 20 |
# File 'lib/train-awsssm/connection.rb', line 18 def close logger.info format("[AWS-SSM] Closed connection to %s", [:host]) end |
#execute_on_channel(cmd, &data_handler) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/train-awsssm/connection.rb', line 47 def execute_on_channel(cmd, &data_handler) logger.debug format("[AWS-SSM] Command: '%s'", cmd) result = execute_command([:host], cmd) stdout = result.standard_output_content || "" stderr = result.standard_error_content || "" exit_status = result.response_code [exit_status, stdout, stderr] end |
#file_via_connection(path, *args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/train-awsssm/connection.rb', line 33 def file_via_connection(path, *args) if os.aix? Train::File::Remote::Aix.new(self, path, *args) elsif os.solaris? Train::File::Remote::Unix.new(self, path, *args) elsif os[:name] == "qnx" Train::File::Remote::Qnx.new(self, path, *args) elsif os.windows? Train::File::Remote::Windows.new(self, path, *args) else Train::File::Remote::Linux.new(self, path, *args) end end |
#run_command_via_connection(cmd, &data_handler) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/train-awsssm/connection.rb', line 26 def run_command_via_connection(cmd, &data_handler) logger.info format("[AWS-SSM] Sending command to %s", [:host]) exit_status, stdout, stderr = execute_on_channel(cmd, &data_handler) CommandResult.new(stdout, stderr, exit_status) end |
#uri ⇒ Object
22 23 24 |
# File 'lib/train-awsssm/connection.rb', line 22 def uri "aws-ssm://#{[:host]}/" end |