Module: Lab::Controllers::RemoteEsxiController
- Included in:
- VmController
- Defined in:
- lib/lab/controller/remote_esxi_controller.rb
Constant Summary collapse
- VIM_CMD =
Note that 3.5 was different (vmware-vim-cmd)
'vim-cmd'.freeze
Class Method Summary collapse
Class Method Details
.dir_list(basepath = nil) ⇒ Object
11 12 13 14 |
# File 'lib/lab/controller/remote_esxi_controller.rb', line 11 def self.dir_list(basepath=nil) # Does this method really even make sense for esxi? return "Unsupported :(" end |
.running_list(user, host) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lab/controller/remote_esxi_controller.rb', line 16 def self.running_list(user, host) user.gsub!(/(\W)*/, '') host.gsub!(/(\W)*/, '') # first get all registered vms registered_vms = self.get_vms(user, host) || [] running_vms = [] # now let's see which ones are running # TODO: this is ghetto, would be better not to connect repeatedly registered_vms.each do |vm| remote_cmd = "ssh #{user}@#{host} \"#{VIM_CMD} vmsvc/power.getstate #{vm[:id]}\"" raw = `#{remote_cmd}` running_vms << vm if raw =~ /Powered on/ end return running_vms end |