class Kitchen::Transport::Train::Connection

Attributes

logger[R]

Public Class Methods

new(options = {}) { |self| ... } click to toggle source
# File lib/kitchen/transport/train.rb, line 32
def initialize(options = {})
  @options = options
  @logger = Kitchen.logger

  @backend = ::Train.create(options[:backend], options)
  @connection = @backend.connection

  yield self if block_given?
end

Public Instance Methods

execute(command) click to toggle source
# File lib/kitchen/transport/train.rb, line 42
def execute(command)
  return if command.nil?

  logger.debug("[Train/#{options[: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/#{options[:backend]} exited (#{command_result.exit_status}) for command: [#{command}]",
      command_result.exit_status
    )
  end
end
login_command() click to toggle source
# File lib/kitchen/transport/train.rb, line 61
def login_command
  raise ::Kitchen::UserError, "Interactive shells are not possible with the Train transport"
end