Ensure all configured providers are loaded

Prior to this, providers that should have been loaded per the
provider_class key of the providers hash were not actually loaded.
This commit is contained in:
Gene Liverman 2021-12-10 15:09:13 -05:00
parent 7872bfe8fc
commit 45378d46b9
No known key found for this signature in database
GPG key ID: 3AF83985B6C857C6
2 changed files with 93 additions and 2 deletions

View file

@ -619,8 +619,21 @@ module Vmpooler
# @return [Array] - a list of used providers from the config file, defaults to the default providers
# ie. ["dummy"]
def used_providers
pools = config[:pools] || []
@used_providers ||= (pools.map { |pool| pool[:provider] || pool['provider'] }.compact + default_providers).uniq
# create an array of provider classes based on the config
if config[:providers]
config_provider_names = config[:providers].keys
config_providers = config_provider_names.map do |config_provider_name|
if config[:providers][config_provider_name] && config[:providers][config_provider_name]['provider_class']
config[:providers][config_provider_name]['provider_class'].to_s
else
config_provider_name.to_s
end
end.compact.uniq
else
config_providers = []
end
# return the unique array of providers from the config and VMPooler defaults
@used_providers ||= (config_providers + default_providers).uniq
end
# @return [Array] - returns a list of providers that should always be loaded