1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

M #-: add inputs into provider (#598)

This commit is contained in:
Alejandro Huertas Herrero 2021-01-07 15:59:23 +01:00 committed by GitHub
parent 6959746c47
commit c008a5cfac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 21 deletions

View File

@ -105,6 +105,14 @@ module OneProvision
conn
end
# Gets inputs information
def inputs
# Dummy case
return unless @body
@body['inputs'] || []
end
# Gets provider type
def type
# Dummy case
@ -148,12 +156,19 @@ module OneProvision
# @return [JSON] Document information in JSON format
def to_json(template)
document = {}
skip = %w[provider connection registration_time plain]
# Create document JSON
document['provider'] = template['provider']
document['connection'] = template['connection']
document['registration_time'] = Time.now.to_i
template.each do |key, value|
next if skip.include?(key)
document[key] = value
end
document.to_json
end

View File

@ -206,27 +206,27 @@ module OneProvision
config = config[:config]
cfg = ProvisionConfig.new(config, inputs)
cfg.validate
cfg.load
# read provider information
unless provider
provider = Provision.read_provider(cfg)
provider = Provider.by_name(@client, provider)
end
return provider if OpenNebula.is_error?(provider)
unless provider
return OpenNebula::Error.new('No provider found')
end
@provider = provider
cfg['inputs'] = cfg['inputs'] | provider.inputs
cfg.validate(false)
begin
# Create configuration object
cfg = ProvisionConfig.new(config, inputs)
cfg.load
# read provider information
unless provider
provider = Provision.read_provider(cfg)
provider = Provider.by_name(@client, provider)
end
return provider if OpenNebula.is_error?(provider)
unless provider
return OpenNebula::Error.new('No provider found')
end
@provider = provider
allocate(cfg, provider)
info

View File

@ -282,8 +282,10 @@ module OneProvision
# Parse it to merge different sections
# Check specific attributes
# Check all evaluation rules
def validate
self.load
#
# @param check_load [Boolean] True to check yaml load operacion
def validate(check_load = true)
self.load if check_load
@config.delete_if {|_k, v| v.nil? }