1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00
The issue is caused by a wrong handling of hash keys in oneflow logic
that assumes vnet IDs are stored in the first position.

co-authored-by: Victor Palma <vpalma@opennebula.io>
co-authored-by: shurkys <shurkys@gmail.com>
This commit is contained in:
Ruben S. Montero 2024-05-10 10:55:00 +02:00
parent f4330598c6
commit 0d1ac37583
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -298,7 +298,7 @@ module OpenNebula
@body['networks_values'].each do |vnet|
vnet.each do |_, net|
next if net.keys.first == 'id' && !deploy
next if net.key?('id') && !deploy
ret << net['id'].to_i
end
@ -635,24 +635,21 @@ module OpenNebula
end
def deploy_networks(deploy = true)
if deploy
body = JSON.parse(self['TEMPLATE/BODY'])
else
body = @body
end
body = if deploy
JSON.parse(self['TEMPLATE/BODY'])
else
@body
end
return if body['networks_values'].nil?
body['networks_values'].each do |vnet|
vnet.each do |name, net|
key = net.keys.first
next if net.key?('id')
case key
when 'id'
next
when 'template_id'
if net.key?('template_id')
rc = create_vnet(name, net)
when 'reserve_from'
elsif net.key?('reserve_from')
rc = reserve(name, net)
end
@ -678,18 +675,14 @@ module OpenNebula
vnets.each do |vnet|
vnet.each do |_, net|
key = net.keys.first
next unless ['template_id', 'reserve_from'].include?(key)
next unless net.key?('template_id') || net.key?('reserve_from')
rc = OpenNebula::VirtualNetwork.new_with_id(
net['id'],
@client
).delete
next unless OpenNebula.is_error?(rc)
vnets_failed << net['id']
vnets_failed << net['id'] if OpenNebula.is_error?(rc)
end
end