Class: PowerOnVMCommand

Inherits:
BaseCommand show all
Defined in:
bin/esx

Instance Method Summary collapse

Instance Method Details

#executeObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'bin/esx', line 134

def execute
  begin
    host = ESX::Host.connect address, user, password, true, {:free_license=>free_license?}
    host.virtual_machines.each do |vm|
      if vm.name == vm_name and vm.power_state != 'poweredOn'
        print "Powering On VM #{vm_name}... "
        vm.power_on
        puts "Done."
      end
    end
  rescue Exception => e
    $stderr.puts "Can't connect to the host #{address}."
    if debug?
      $stderr.puts e.message
    end
    exit 1
  end
end