class Cucumber::Chef::TestLab

Attributes

containers[RW]
provider[RW]

Public Class Methods

new(ui=ZTK::UI.new) click to toggle source
# File lib/cucumber/chef/test_lab.rb, line 32
def initialize(ui=ZTK::UI.new)
  @ui = ui

  @provider = Cucumber::Chef::Provider.new(@ui)
  @containers = Cucumber::Chef::Containers.new(@ui, self)
end

Public Instance Methods

bootstrap_ssh(options={}) click to toggle source
# File lib/cucumber/chef/test_lab.rb, line 41
def bootstrap_ssh(options={})
  if (!defined?(@bootstrap_ssh) || @bootstrap_ssh.nil?)
    @bootstrap_ssh ||= ZTK::SSH.new({:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout}.merge(options))

    @bootstrap_ssh.config.host_name = self.ip
    @bootstrap_ssh.config.port = self.port
    @bootstrap_ssh.config.user = Cucumber::Chef.bootstrap_user
    @bootstrap_ssh.config.keys = Cucumber::Chef.bootstrap_identity
  end
  @bootstrap_ssh
end
knife_cli(args, options={}) click to toggle source
# File lib/cucumber/chef/test_lab.rb, line 89
def knife_cli(args, options={})
  options = {:silence => true}.merge(options)

  arguments = Array.new
  arguments << "--user #{Cucumber::Chef::Config.user}"
  arguments << "--key #{Cucumber::Chef.chef_identity}"
  arguments << "--server-url https://#{self.ip}"
  arguments << "--disable-editing"
  arguments << "--yes"
  arguments << "-VV" if Cucumber::Chef.is_rc?

  command = Cucumber::Chef.build_command("knife", args, arguments)
  ZTK::Command.new.exec(command, options)
end
method_missing(method_name, *method_args) click to toggle source
Calls superclass method
# File lib/cucumber/chef/test_lab.rb, line 106
def method_missing(method_name, *method_args)
  if Cucumber::Chef::Provider::PROXY_METHODS.include?(method_name.to_s)
    result = @provider.send(method_name.to_sym, *method_args)
    splat = [method_name, *method_args].flatten.compact
    @ui.logger.debug { "TestLab: #{splat.inspect}=#{result.inspect}" }
    result
  else
    super(method_name, *method_args)
  end
end
proxy_ssh(container, options={}) click to toggle source
# File lib/cucumber/chef/test_lab.rb, line 69
def proxy_ssh(container, options={})
  container = container.to_sym
  @proxy_ssh ||= Hash.new
  if (!defined?(@proxy_ssh[container]) || @proxy_ssh[container].nil?)
    @proxy_ssh[container] ||= ZTK::SSH.new({:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout}.merge(options))

    @proxy_ssh[container].config.proxy_host_name = self.ip
    @proxy_ssh[container].config.proxy_port = Cucumber::Chef.lab_ssh_port || self.port
    @proxy_ssh[container].config.proxy_user = Cucumber::Chef.lab_user
    @proxy_ssh[container].config.proxy_keys = Cucumber::Chef.lab_identity

    @proxy_ssh[container].config.host_name = container
    @proxy_ssh[container].config.user = Cucumber::Chef.lxc_user
    @proxy_ssh[container].config.keys = Cucumber::Chef.lxc_identity
  end
  @proxy_ssh[container]
end
ssh(options={}) click to toggle source
# File lib/cucumber/chef/test_lab.rb, line 55
def ssh(options={})
  if (!defined?(@ssh) || @ssh.nil?)
    @ssh ||= ZTK::SSH.new({:ui => @ui, :timeout => Cucumber::Chef::Config.command_timeout}.merge(options))

    @ssh.config.host_name = self.ip
    @ssh.config.port = self.port
    @ssh.config.user = Cucumber::Chef.lab_user
    @ssh.config.keys = Cucumber::Chef.lab_identity
  end
  @ssh
end