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

M #-: use defaults from network in Flow (#4538)

This commit is contained in:
Alejandro Huertas Herrero 2020-04-16 13:08:38 +02:00 committed by GitHub
parent 4a6dad81ec
commit 0b07f9d9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -528,6 +528,31 @@ post '/service_template/:id/action' do
networks = body['networks']
networks_values = merge_template['networks_values'] if merge_template
# Obtain defaults from template
unless networks_values
networks_values = []
begin
networks.each do |key, value|
net = {}
net[key] = {}
# Format of all available defaults
#
# Existing: "net": "M|network|| |id:0"
# Instantiate: "net": "M|network|| |template_id:1"
# Reserve: "net": "M|network|| |reserve_from:0"
value = value.split('||')[1].gsub('|', '').strip.split(':')
net[key][value[0]] = value[1]
networks_values << net
end
rescue StandardError
return internal_error('Wrong networks format', VALIDATION_EC)
end
end
if networks && !(networks.is_a? Hash)
return internal_error('Wrong networks format', VALIDATION_EC)
end