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:
parent
6959746c47
commit
c008a5cfac
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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? }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user