Merge pull request #13 from sschneid/hostname_check

Add a check to 'check_ready_vm' to make sure hostname still matches
This commit is contained in:
Scott Schneider 2014-02-20 14:36:06 -08:00
commit cca063dc0f

View file

@ -103,7 +103,8 @@ def check_ready_vm vm, pool, ttl
)
$redis.hset('vmware_host_pool__vm__'+vm, 'check', Time.now)
host = $vsphere[pool].find_vm(vm)
host = $vsphere[pool].find_vm(vm) ||
$vsphere[pool].find_vm_heavy(vm)[vm]
if (host)
if (
@ -115,6 +116,16 @@ def check_ready_vm vm, pool, ttl
$logger.log('d', "[!] [#{pool}] '#{vm}' appears to be powered off, removed from 'ready' queue")
end
if (
(host.summary.guest) and
(host.summary.guest.hostName) and
(host.summary.guest.hostName != vm)
)
$redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm)
$logger.log('d', "[!] [#{pool}] '#{vm}' has mismatched hostname, removed from 'ready' queue")
end
else
$redis.srem('vmware_host_pool__ready__'+pool, vm)