Class: Kitchen::Transport::Train::Connection
- Inherits:
-
Base::Connection
- Object
- Base::Connection
- Kitchen::Transport::Train::Connection
- Extended by:
- Forwardable
- Defined in:
- lib/kitchen/transport/train.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #credentials_file ⇒ Object
- #execute(command) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Connection
constructor
A new instance of Connection.
- #login_command ⇒ Object
- #train_uri ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Connection
Returns a new instance of Connection.
32 33 34 35 36 37 38 39 40 |
# File 'lib/kitchen/transport/train.rb', line 32 def initialize( = {}) @options = @logger = Kitchen.logger @backend = ::Train.create([:backend], ) @connection = @backend.connection yield self if block_given? end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
30 31 32 |
# File 'lib/kitchen/transport/train.rb', line 30 def logger @logger end |
Instance Method Details
#credentials_file ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/kitchen/transport/train.rb', line 46 def credentials_file instance_name = @connection.[:instance_name] config = @backend.instance_variable_get(:@connection_options) config.compact! config.transform_values! { |v| v.is_a?(Symbol) ? v.to_s : v } # Some configuration variables vary between transports config[:host] = config[:hostname] = @connection.[:host] config[:key_files] = @connection.[:key_files] # Due to a long-standing bug in TestKitchen, standard platforms will override # kitchen.yml `user` settings, so this transport introduces an "train_user" override. # See https://github.com/test-kitchen/kitchen-ec2/pull/273 config[:user] = config[:username] = @connection.[:train_user] || @connection.[:user] require "toml-rb" unless defined?(TomlRB) "['#{instance_name}']\n" + TomlRB.dump(config) end |
#execute(command) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/kitchen/transport/train.rb', line 67 def execute(command) return if command.nil? logger.debug("[Train/#{[:backend]}] Execute (#{command})") command_result = @connection.run_command(command) if command_result.exit_status == 0 logger.info(command_result.stdout) else logger.error(command_result.stderr) raise Transport::ConnectionFailed.new( "Train/#{[:backend]} exited (#{command_result.exit_status}) for command: [#{command}]", command_result.exit_status ) end end |
#login_command ⇒ Object
86 87 88 |
# File 'lib/kitchen/transport/train.rb', line 86 def login_command raise ::Kitchen::UserError, "Interactive shells are not possible with the Train transport" end |
#train_uri ⇒ Object
42 43 44 |
# File 'lib/kitchen/transport/train.rb', line 42 def train_uri @connection.uri end |