mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Delete long-running VMs after 12 hours
This commit is contained in:
parent
d13a9fcf3a
commit
43047fbf80
1 changed files with 14 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require 'rbvmomi'
|
require 'rbvmomi'
|
||||||
require 'redis'
|
require 'redis'
|
||||||
|
require 'time'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
$:.unshift(File.dirname(__FILE__))
|
$:.unshift(File.dirname(__FILE__))
|
||||||
|
|
@ -306,6 +307,19 @@ def check_pool pool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# LONG-RUNNING
|
||||||
|
$redis.hkeys('vmware_host_pool__active__'+pool['name']).each do |vm|
|
||||||
|
running = (Time.now - Time.parse($redis.hget('vmware_host_pool__active__'+pool['name'], vm)))/60/60
|
||||||
|
if (running > 12)
|
||||||
|
$logger.log('d', "[!] [#{pool}] '#{vm}' reached end of TTL after 12 hours")
|
||||||
|
|
||||||
|
begin
|
||||||
|
destroy_vm(vm, pool['name'])
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# REPOPULATE
|
# REPOPULATE
|
||||||
total = $redis.scard('vmware_host_pool__ready__'+pool['name']) +
|
total = $redis.scard('vmware_host_pool__ready__'+pool['name']) +
|
||||||
$redis.scard('vmware_host_pool__pending__'+pool['name'])
|
$redis.scard('vmware_host_pool__pending__'+pool['name'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue