mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Catch clonevm_task exceptions
This commit is contained in:
parent
601a500100
commit
b0105a1509
1 changed files with 16 additions and 8 deletions
|
|
@ -180,15 +180,20 @@ def clone_vm template, pool, folder, datastore
|
||||||
# Clone the VM
|
# Clone the VM
|
||||||
$logger.log('d', "[ ] [#{vm['template']}] '#{vm['hostname']}' is being cloned from '#{vm['template']}'")
|
$logger.log('d', "[ ] [#{vm['template']}] '#{vm['hostname']}' is being cloned from '#{vm['template']}'")
|
||||||
|
|
||||||
start = Time.now
|
begin
|
||||||
vm[vm['template']].CloneVM_Task(
|
start = Time.now
|
||||||
:folder => $vsphere[vm['template']].find_folder(folder),
|
vm[vm['template']].CloneVM_Task(
|
||||||
:name => vm['hostname'],
|
:folder => $vsphere[vm['template']].find_folder(folder),
|
||||||
:spec => spec
|
:name => vm['hostname'],
|
||||||
).wait_for_completion
|
:spec => spec
|
||||||
finish = '%.2f' % (Time.now-start)
|
).wait_for_completion
|
||||||
|
finish = '%.2f' % (Time.now-start)
|
||||||
|
|
||||||
$logger.log('s', "[+] [#{vm['template']}] '#{vm['hostname']}' cloned from '#{vm['template']}' in #{finish} seconds")
|
$logger.log('s', "[+] [#{vm['template']}] '#{vm['hostname']}' cloned from '#{vm['template']}' in #{finish} seconds")
|
||||||
|
rescue
|
||||||
|
$logger.log('s', "[!] [#{vm['template']}] '#{vm['hostname']}' clone appears to have failed")
|
||||||
|
$redis.srem('vmware_host_pool__pending__'+vm['template'], vm['hostname'])
|
||||||
|
end
|
||||||
|
|
||||||
$redis.decr('vmware_host_pool__tasks__clone')
|
$redis.decr('vmware_host_pool__tasks__clone')
|
||||||
|
|
||||||
|
|
@ -366,6 +371,9 @@ end
|
||||||
|
|
||||||
$logger.log('d', "starting vmware-host-pooler")
|
$logger.log('d', "starting vmware-host-pooler")
|
||||||
|
|
||||||
|
# Clear out the tasks manager, as we don't know about any tasks at this point
|
||||||
|
$redis.set('vmware_host_pool__tasks__clone', 0)
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
pools.each do |pool|
|
pools.each do |pool|
|
||||||
if (! $threads[pool['name']])
|
if (! $threads[pool['name']])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue