mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Fewer vSphere queries = better
This commit is contained in:
parent
bc20975fba
commit
c3b6215961
1 changed files with 5 additions and 3 deletions
|
|
@ -29,8 +29,10 @@ $redis = Redis.new
|
||||||
# Check the state of a VM
|
# Check the state of a VM
|
||||||
def check_vm vm, pool
|
def check_vm vm, pool
|
||||||
Thread.new {
|
Thread.new {
|
||||||
if ($vsphere_helper.find_vms(vm)[vm])
|
host = $vsphere_helper.find_vms(vm)[vm]
|
||||||
if ($vsphere_helper.find_vms(vm)[vm].summary.guest.hostName == vm)
|
|
||||||
|
if (host)
|
||||||
|
if (host.summary.guest.hostName == vm)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Socket.getaddrinfo(vm, nil)
|
Socket.getaddrinfo(vm, nil)
|
||||||
|
|
@ -43,7 +45,7 @@ def check_vm vm, pool
|
||||||
|
|
||||||
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
||||||
else
|
else
|
||||||
if ((((Time.now - $vsphere_helper.find_vms(vm)[vm].runtime.bootTime)/60).to_s[/^\d+\.\d{1}/].to_f) > 10)
|
if ((((Time.now - host.runtime.bootTime)/60).to_s[/^\d+\.\d{1}/].to_f) > 10)
|
||||||
$redis.srem('vmware_host_pool__pending__'+pool, vm)
|
$redis.srem('vmware_host_pool__pending__'+pool, vm)
|
||||||
$redis.sadd('vmware_host_pool__completed__'+pool, vm)
|
$redis.sadd('vmware_host_pool__completed__'+pool, vm)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue