lib/vagrant-vcenter/action/read_state.rb in vagrant-vcenter-0.2.1 vs lib/vagrant-vcenter/action/read_state.rb in vagrant-vcenter-0.3.0
- old
+ new
@@ -14,10 +14,15 @@
env[:machine_state_id] = read_state(env)
@app.call env
end
def read_state(env)
+ if env[:machine].id.nil?
+ @logger.info('VM is not created yet')
+ return :not_created
+ end
+
# FIXME: this part needs some cleanup
config = env[:machine].provider_config
# FIXME: Raise a correct exception
dc = config.vcenter_cnx.serviceInstance.find_datacenter(
@@ -25,16 +30,11 @@
root_vm_folder = dc.vmFolder
vm = root_vm_folder.findByUuid(env[:machine].id)
- #@logger.debug("Current power state: #{vm.runtime.powerState}")
+ # @logger.debug("Current power state: #{vm.runtime.powerState}")
vm_name = env[:machine].name
-
- if env[:machine].id.nil?
- @logger.info("VM [#{vm_name}] is not created yet")
- return :not_created
- end
if vm.runtime.powerState == 'poweredOff'
@logger.info("VM [#{vm_name}] is stopped")
return :stopped
elsif vm.runtime.powerState == 'poweredOn'