mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
M #-: add provision id to objects (#607)
This commit is contained in:
parent
e8ff50320e
commit
e073a4d497
@ -453,7 +453,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
||||
# @param options [Hash] User CLI options
|
||||
# @param args [Array] Operation arguments
|
||||
def host_operation(host, operation, options, args)
|
||||
p_id = host['TEMPLATE/PROVISION_ID']
|
||||
p_id = host['TEMPLATE/PROVISION/ID']
|
||||
|
||||
return OpenNebula::Error.new('No provision ID found') unless p_id
|
||||
|
||||
@ -510,9 +510,9 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
||||
OneProvision::OneProvisionLogger.info(msg)
|
||||
|
||||
if type != 'FLOWTEMPLATES'
|
||||
p_id = obj['TEMPLATE/PROVISION_ID']
|
||||
p_id = obj['TEMPLATE/PROVISION/ID']
|
||||
else
|
||||
p_id = JSON.parse(obj.template)['PROVISION_ID']
|
||||
p_id = JSON.parse(obj.template)['PROVISION']['ID']
|
||||
end
|
||||
|
||||
unless p_id
|
||||
|
@ -130,7 +130,7 @@ module OneProvision
|
||||
#
|
||||
# @return [Boolean] True if the ssh connection works
|
||||
def ansible_ssh(ansible_dir)
|
||||
# Note: We want only to check the working SSH connection, but
|
||||
# NOTE: We want only to check the working SSH connection, but
|
||||
# Ansible "ping" module requires also Python to be installed on
|
||||
# the remote side, otherwise fails. So we use only "raw"
|
||||
# module with simple command. Python should be
|
||||
@ -281,7 +281,7 @@ module OneProvision
|
||||
Driver.write_file_log("#{ansible_dir}/inventory", c)
|
||||
|
||||
# Generate "group_vars" file
|
||||
group_vars = { 'sys_ds_ids' => [], 'first_host' => ""}
|
||||
group_vars = { 'sys_ds_ids' => [], 'first_host' => '' }
|
||||
group_vars['first_host'] = hosts.first['name'] \
|
||||
unless hosts.empty?
|
||||
|
||||
@ -289,9 +289,10 @@ module OneProvision
|
||||
ds = Resource.object('datastores')
|
||||
ds.info(d['id'])
|
||||
next unless ds.one['TYPE'] == '1' # only system ds
|
||||
|
||||
group_vars['sys_ds_ids'] << d['id']
|
||||
end unless datastores.nil?
|
||||
|
||||
|
||||
c = YAML.dump(group_vars)
|
||||
fname = "#{ansible_dir}/group_vars.yml"
|
||||
Driver.write_file_log(fname, c)
|
||||
|
@ -171,7 +171,6 @@ module OneProvision
|
||||
ret = nil
|
||||
|
||||
@mutex.synchronize do
|
||||
|
||||
if @cache
|
||||
ret = @cache[object]
|
||||
end
|
||||
@ -183,8 +182,8 @@ module OneProvision
|
||||
raise OneProvisionLoopException, rc.message
|
||||
end
|
||||
|
||||
@cache = {} unless @cache
|
||||
@cache[object] = []
|
||||
@cache ||= {}
|
||||
@cache[object] = []
|
||||
|
||||
if FULL_CLUSTER.include?(object)
|
||||
path = 'infrastructure'
|
||||
@ -257,6 +256,9 @@ module OneProvision
|
||||
|
||||
puts "ID: #{self['ID']}"
|
||||
|
||||
# @id is used for template evaluation
|
||||
@id = self['ID']
|
||||
|
||||
# read provision file
|
||||
cfg.parse(true)
|
||||
|
||||
@ -279,9 +281,6 @@ module OneProvision
|
||||
|
||||
Mode.new_cleanup(true)
|
||||
|
||||
# @id is used for template evaluation
|
||||
@id = self['ID']
|
||||
|
||||
if skip != :all && hosts && !hosts.empty?
|
||||
# ask user to be patient, mandatory for now
|
||||
STDERR.puts 'WARNING: This operation can ' \
|
||||
@ -562,7 +561,8 @@ module OneProvision
|
||||
cfg[r].each do |x|
|
||||
Driver.retry_loop('Failed to create some resources',
|
||||
self) do
|
||||
obj = Resource.object(r, nil, x)
|
||||
x['provision']['id'] = @id
|
||||
obj = Resource.object(r, nil, x)
|
||||
|
||||
next if obj.nil?
|
||||
|
||||
@ -666,6 +666,7 @@ module OneProvision
|
||||
|
||||
h['provision']['index'] = idx + global_idx
|
||||
h['provision']['count'] = count
|
||||
h['provision']['id'] = @id
|
||||
|
||||
host = Resource.object('hosts', @provider, h)
|
||||
|
||||
|
@ -90,7 +90,7 @@ module OneProvision
|
||||
end
|
||||
|
||||
keys.each do |k|
|
||||
if !provider['connection'].has_key? k
|
||||
if !provider['connection'].key? k
|
||||
raise OneProvisionLoopException,
|
||||
"Missing provider connection attribute: '#{k}'"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user