check_ready_vm fixups

- Correct key name ('check', not 'clone')
- Correct timestamp math (minutes, not seconds)
- Only search for the host in vSphere if we're actually doing a check
This commit is contained in:
Scott Schneider 2014-02-19 09:38:05 -08:00
parent 62cbc5a6ff
commit e7559c515e

View file

@ -87,8 +87,6 @@ end
def check_ready_vm vm, pool, ttl def check_ready_vm vm, pool, ttl
Thread.new { Thread.new {
host = $vsphere[pool].find_vm(vm)
if (ttl > 0) if (ttl > 0)
if ((((Time.now - host.runtime.bootTime)/60).to_s[/^\d+\.\d{1}/].to_f) > ttl) if ((((Time.now - host.runtime.bootTime)/60).to_s[/^\d+\.\d{1}/].to_f) > ttl)
$redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm) $redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm)
@ -101,10 +99,12 @@ def check_ready_vm vm, pool, ttl
if ( if (
(! check_stamp) or (! check_stamp) or
((Time.now - Time.parse(clone_stamp)) > $config[:config]['vm_checktime']) (((Time.now - Time.parse(check_stamp))/60) > $config[:config]['vm_checktime'])
) )
$redis.hset('vmware_host_pool__vm__'+vm, 'check', Time.now) $redis.hset('vmware_host_pool__vm__'+vm, 'check', Time.now)
host = $vsphere[pool].find_vm(vm)
if (host) if (host)
if ( if (
(host.runtime) and (host.runtime) and