Class: VagrantPlugins::Abiquo::Actions::ReadSSHInfo
- Inherits:
-
Object
- Object
- VagrantPlugins::Abiquo::Actions::ReadSSHInfo
- Includes:
- Helpers::Abiquo
- Defined in:
- lib/vagrant_abiquo/actions/read_ssh_info.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ReadSSHInfo
constructor
A new instance of ReadSSHInfo.
Methods included from Helpers::Abiquo
#apply_state, #attach_net, #create_vapp, #create_vm, #deploy, #get_network, #get_template, #get_vapp, #get_vdc, #get_vm, #poweroff, #poweron, #reset, #update, #vapp_name
Constructor Details
#initialize(app, env) ⇒ ReadSSHInfo
Returns a new instance of ReadSSHInfo.
9 10 11 12 13 |
# File 'lib/vagrant_abiquo/actions/read_ssh_info.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::abiquo::ssh_info') end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant_abiquo/actions/read_ssh_info.rb', line 15 def call(env) vm = get_vm(env[:abiquo_client], @machine.id) return nil if vm.nil? || vm.state != 'ON' ip ||= vm.link(:nics).get.first.ip if @machine.config.ssh.username.nil? template = vm.link(:virtualmachinetemplate).get username = template.loginUser.nil? ? 'root' : template.loginUser else username = @machine.config.ssh.username end env[:machine_ssh_info] = { :host => ip, :port => 22, :username => username } @app.call(env) end |