(maint) Support any vmpooler for ABS via vmpooler_fallback

Before this change, the fallback vmpooler for ABS had to be named
'vmpooler' and it only supported one. With this new code, users can
set a key within an 'abs' service type called vmpooler_fallback that
points to any other service configured in the ~/.vmfloaty.yml config
file. If not set, the appropriate error message is returned, with
an example configuration.
Added the various use cases for the config to the unit tests
This commit is contained in:
Samuel Beaulieu 2020-09-16 11:23:01 -05:00
parent 512adb4af1
commit 5333158bdc
4 changed files with 74 additions and 13 deletions

View file

@ -210,7 +210,7 @@ class ABS
end
# Retrieve an OS from ABS.
def self.retrieve(verbose, os_types, token, url, user, options, _ondemand = nil)
def self.retrieve(verbose, os_types, token, url, user, config, _ondemand = nil)
#
# Contents of post must be like:
#
@ -231,7 +231,7 @@ class ABS
conn.headers['X-AUTH-TOKEN'] = token if token
saved_job_id = DateTime.now.strftime('%Q')
vmpooler_config = Utils.get_vmpooler_service_config
vmpooler_config = Utils.get_vmpooler_service_config(config['vmpooler_fallback'])
req_obj = {
:resources => os_types,
:job => {
@ -243,15 +243,15 @@ class ABS
:vm_token => vmpooler_config['token'] # request with this token, on behalf of this user
}
if options['priority']
req_obj[:priority] = if options['priority'] == 'high'
if config['priority']
req_obj[:priority] = if config['priority'] == 'high'
1
elsif options['priority'] == 'medium'
elsif config['priority'] == 'medium'
2
elsif options['priority'] == 'low'
elsif config['priority'] == 'low'
3
else
options['priority'].to_i
config['priority'].to_i
end
end