mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
'vm_checktime' sets interval for check_ready_vm
This commit is contained in:
parent
1e6ca05d14
commit
62cbc5a6ff
1 changed files with 32 additions and 22 deletions
|
|
@ -32,8 +32,9 @@ if (defined? $config[:config]['graphite'])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set some defaults
|
# Set some defaults
|
||||||
$config[:config]['task_limit'] ||= 10
|
$config[:config]['task_limit'] ||= 10
|
||||||
$config[:config]['vm_lifetime'] ||= 24
|
$config[:config]['vm_checktime'] ||= 15
|
||||||
|
$config[:config]['vm_lifetime'] ||= 24
|
||||||
$config[:redis] ||= Hash.new
|
$config[:redis] ||= Hash.new
|
||||||
$config[:redis]['server'] ||= 'localhost'
|
$config[:redis]['server'] ||= 'localhost'
|
||||||
|
|
||||||
|
|
@ -96,29 +97,38 @@ def check_ready_vm vm, pool, ttl
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (host)
|
check_stamp = $redis.hget('vmware_host_pool__vm__'+vm, 'check')
|
||||||
if (
|
|
||||||
(host.runtime) and
|
|
||||||
(host.runtime.powerState) and
|
|
||||||
(host.runtime.powerState != 'poweredOn')
|
|
||||||
)
|
|
||||||
$redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm)
|
|
||||||
|
|
||||||
$logger.log('d', "[!] [#{pool}] '#{vm}' appears to be powered off, removed from 'ready' queue")
|
if (
|
||||||
|
(! check_stamp) or
|
||||||
|
((Time.now - Time.parse(clone_stamp)) > $config[:config]['vm_checktime'])
|
||||||
|
)
|
||||||
|
$redis.hset('vmware_host_pool__vm__'+vm, 'check', Time.now)
|
||||||
|
|
||||||
|
if (host)
|
||||||
|
if (
|
||||||
|
(host.runtime) and
|
||||||
|
(host.runtime.powerState) and
|
||||||
|
(host.runtime.powerState != 'poweredOn')
|
||||||
|
)
|
||||||
|
$redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm)
|
||||||
|
|
||||||
|
$logger.log('d', "[!] [#{pool}] '#{vm}' appears to be powered off, removed from 'ready' queue")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
$redis.srem('vmware_host_pool__ready__'+pool, vm)
|
||||||
|
|
||||||
|
$logger.log('s', "[!] [#{pool}] '#{vm}' not found in vCenter inventory, removed from 'ready' queue")
|
||||||
end
|
end
|
||||||
else
|
|
||||||
$redis.srem('vmware_host_pool__ready__'+pool, vm)
|
|
||||||
|
|
||||||
$logger.log('s', "[!] [#{pool}] '#{vm}' not found in vCenter inventory, removed from 'ready' queue")
|
begin
|
||||||
end
|
Timeout::timeout(5) {
|
||||||
|
TCPSocket.new vm, 22
|
||||||
begin
|
}
|
||||||
Timeout::timeout(5) {
|
rescue
|
||||||
TCPSocket.new vm, 22
|
if ($redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm))
|
||||||
}
|
$logger.log('d', "[!] [#{pool}] '#{vm}' is unreachable, removed from 'ready' queue")
|
||||||
rescue
|
end
|
||||||
if ($redis.smove('vmware_host_pool__ready__'+pool, 'vmware_host_pool__completed__'+pool, vm))
|
|
||||||
$logger.log('d', "[!] [#{pool}] '#{vm}' is unreachable, removed from 'ready' queue")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue