mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Store 'clone' timestamps in Redis database
Using redis keys to store clone timestamps will allow for a global TTL for VMs in the 'pending' pool; failed clones should be cleaned up and retried after a set period of time (eg. 15m).
This commit is contained in:
parent
5f62a4eee0
commit
55ada2d80e
2 changed files with 105 additions and 10 deletions
|
|
@ -100,6 +100,62 @@ class VsphereHelper
|
|||
|
||||
|
||||
|
||||
def find_vm_heavy vmname
|
||||
begin
|
||||
@connection.serviceInstance.CurrentTime
|
||||
rescue
|
||||
initialize()
|
||||
end
|
||||
|
||||
vmname = vmname.is_a?(Array) ? vmname : [ vmname ]
|
||||
containerView = get_base_vm_container_from @connection
|
||||
propertyCollector = @connection.propertyCollector
|
||||
|
||||
objectSet = [{
|
||||
:obj => containerView,
|
||||
:skip => true,
|
||||
:selectSet => [ RbVmomi::VIM::TraversalSpec.new({
|
||||
:name => 'gettingTheVMs',
|
||||
:path => 'view',
|
||||
:skip => false,
|
||||
:type => 'ContainerView'
|
||||
}) ]
|
||||
}]
|
||||
|
||||
propSet = [{
|
||||
:pathSet => [ 'name' ],
|
||||
:type => 'VirtualMachine'
|
||||
}]
|
||||
|
||||
results = propertyCollector.RetrievePropertiesEx({
|
||||
:specSet => [{
|
||||
:objectSet => objectSet,
|
||||
:propSet => propSet
|
||||
}],
|
||||
:options => { :maxObjects => nil }
|
||||
})
|
||||
|
||||
vms = {}
|
||||
results.objects.each do |result|
|
||||
name = result.propSet.first.val
|
||||
next unless vmname.include? name
|
||||
vms[name] = result.obj
|
||||
end
|
||||
|
||||
while results.token do
|
||||
results = propertyCollector.ContinueRetrievePropertiesEx({:token => results.token})
|
||||
results.objects.each do |result|
|
||||
name = result.propSet.first.val
|
||||
next unless vmname.include? name
|
||||
vms[name] = result.obj
|
||||
end
|
||||
end
|
||||
|
||||
vms
|
||||
end
|
||||
|
||||
|
||||
|
||||
def get_base_vm_container_from connection
|
||||
begin
|
||||
connection.serviceInstance.CurrentTime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue