Add a variable that makes a little more clear the intent of excluding request_id from payload in generate_ondemand_request

This commit is contained in:
kirby@puppetlabs.com 2020-05-12 11:47:45 -07:00
parent 8ffcafdc99
commit 75b966e9d4

View file

@ -345,7 +345,8 @@ module Vmpooler
def generate_ondemand_request(payload)
result = { 'ok': false }
if too_many_requested?(payload.reject { |k, _v| k == 'request_id' })
requested_instances = payload.reject { |k, _v| k == 'request_id' }
if too_many_requested?(requested_instances)
result['message'] = "requested amount of instances exceeds the maximum #{config['max_ondemand_instances_per_request']}"
status 403
return result
@ -365,7 +366,7 @@ module Vmpooler
status 201
platforms_with_aliases = []
payload.reject { |k, _v| k == 'request_id' }.each do |poolname, count|
requested_instances.each do |poolname, count|
selection = evaluate_template_aliases(poolname, count)
selection.map { |selected_pool, selected_pool_count| platforms_with_aliases << "#{poolname}:#{selected_pool}:#{selected_pool_count}" }
end