mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-174) Reduce duplicate of on demand code introduced in POOLER-158 (#383)
* (POOLER-174) Reduce duplicate of on demand code introduced in POOLER-158 refactored every parsing of request of type 'pool_alias:pool:count' into a utility class, that is used by pool_manager and the api v1 class * add some metrics to the od request generation * fix rubocop offenses, we are now friends
This commit is contained in:
parent
2afc2a242b
commit
4ecd5dea51
4 changed files with 42 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'vmpooler/providers'
|
||||
require 'vmpooler/util/parsing'
|
||||
require 'spicy-proton'
|
||||
require 'resolv' # ruby standard lib
|
||||
|
||||
|
|
@ -1500,9 +1501,7 @@ module Vmpooler
|
|||
def vms_ready?(request_id, redis)
|
||||
catch :request_not_ready do
|
||||
request_hash = redis.hgetall("vmpooler__odrequest__#{request_id}")
|
||||
requested_platforms = request_hash['requested'].split(',')
|
||||
requested_platforms.each do |platform|
|
||||
platform_alias, pool, count = platform.split(':')
|
||||
Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, count|
|
||||
pools_filled = redis.scard("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
|
||||
throw :request_not_ready unless pools_filled.to_i == count.to_i
|
||||
end
|
||||
|
|
@ -1554,9 +1553,7 @@ module Vmpooler
|
|||
|
||||
def remove_vms_for_failed_request(request_id, expiration_ttl, redis)
|
||||
request_hash = redis.hgetall("vmpooler__odrequest__#{request_id}")
|
||||
requested_platforms = request_hash['requested'].split(',')
|
||||
requested_platforms.each do |platform|
|
||||
platform_alias, pool, _count = platform.split(':')
|
||||
Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
|
||||
pools_filled = redis.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
|
||||
redis.pipelined do
|
||||
pools_filled&.each do |vm|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue