mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Merge pull request #469 from puppetlabs/tag_vm_user
(maint) Adding a provider method tag_vm_user
This commit is contained in:
commit
7872bfe8fc
3 changed files with 41 additions and 0 deletions
|
|
@ -294,6 +294,12 @@ module Vmpooler
|
|||
move_vm_queue(pool, vm, 'running', 'completed', redis, 'is listed as running, but has no checkouttime data. Removing from running')
|
||||
end
|
||||
|
||||
# tag VM if not tagged yet, this ensures the method is only called once
|
||||
unless redis.hget("vmpooler__vm__#{vm}", 'user_tagged')
|
||||
success = provider.tag_vm_user(pool, vm)
|
||||
redis.hset("vmpooler__vm__#{vm}", 'user_tagged', 'true') if success
|
||||
end
|
||||
|
||||
throw :stop_checking if provider.vm_ready?(pool, vm)
|
||||
|
||||
throw :stop_checking if provider.get_vm(pool, vm)
|
||||
|
|
|
|||
|
|
@ -212,6 +212,22 @@ module Vmpooler
|
|||
raise("#{self.class.name} does not implement vm_ready?")
|
||||
end
|
||||
|
||||
# tag_vm_user This method is called once we know who is using the VM (it is running). This method enables seeing
|
||||
# who is using what in the provider pools.
|
||||
# This method should be implemented in the providers, if it is not implemented, this base method will be called
|
||||
# and should be a noop. The implementation should check if the vm has a user (as per redis) and add a new tag
|
||||
# with the information.
|
||||
# inputs
|
||||
# [String] pool_name : Name of the pool
|
||||
# [String] vm_name : Name of the VM to check if ready
|
||||
# returns
|
||||
# [Boolean] : true if successful, false if an error occurred and it should retry
|
||||
def tag_vm_user(_pool_name, _vm_name)
|
||||
# noop by design. If the provider does not implement this method, this base method is called (because inherited)
|
||||
# and should basically do nothing.
|
||||
true
|
||||
end
|
||||
|
||||
# inputs
|
||||
# [String] pool_name : Name of the pool
|
||||
# [String] vm_name : Name of the VM to check if it exists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue