mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Don't operate on 'host' object if it doesn't exist
This commit is contained in:
parent
32fee4e0b1
commit
c17637c8b1
1 changed files with 11 additions and 7 deletions
|
|
@ -115,20 +115,24 @@ loop do
|
||||||
$redis.srem('vmware_host_pool__completed__'+pool['name'], vm)
|
$redis.srem('vmware_host_pool__completed__'+pool['name'], vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
start = Time.now
|
|
||||||
host = vsphere_helper.find_vms(vm)[vm]
|
host = vsphere_helper.find_vms(vm)[vm]
|
||||||
|
|
||||||
if host.runtime
|
if (
|
||||||
|
(host) and
|
||||||
|
(host.runtime)
|
||||||
|
)
|
||||||
|
start = Time.now
|
||||||
|
|
||||||
if host.runtime.powerState == 'poweredOn'
|
if host.runtime.powerState == 'poweredOn'
|
||||||
logger.log('d', "[ ] '#{vm}' is being shut down")
|
logger.log('d', "[ ] '#{vm}' is being shut down")
|
||||||
host.PowerOffVM_Task.wait_for_completion
|
host.PowerOffVM_Task.wait_for_completion
|
||||||
end
|
end
|
||||||
|
|
||||||
|
host.Destroy_Task.wait_for_completion
|
||||||
|
finish = '%.2f' % (Time.now-start)
|
||||||
|
|
||||||
|
logger.log('s', "[-] '#{vm}' destroyed in #{finish} seconds")
|
||||||
end
|
end
|
||||||
|
|
||||||
host.Destroy_Task.wait_for_completion
|
|
||||||
finish = '%.2f' % (Time.now-start)
|
|
||||||
|
|
||||||
logger.log('s', "[-] '#{vm}' destroyed in #{finish} seconds")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bring the pool up to the desired size
|
# Bring the pool up to the desired size
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue