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

B #5935: onedb fsck rm network quota with empty ID (#2254)

(cherry picked from commit 665e2bb802391d173036f7095cd0055cab73ebbc)
This commit is contained in:
Pavel Czerný 2022-07-28 11:24:11 +02:00 committed by Ruben S. Montero
parent 04bbc74a1a
commit 34630f1128
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -487,18 +487,20 @@ module OneDBFsck
end
end
net_quota = nil
doc.root.xpath('NETWORK_QUOTA').each {|e| net_quota = e }
net_quota = doc.root.xpath('NETWORK_QUOTA').remove
if net_quota.nil?
net_quota = doc.root.add_child(doc.create_element('NETWORK_QUOTA'))
end
new_net_quota = doc.root.add_child(doc.create_element('NETWORK_QUOTA'))
net_quota = new_net_quota if net_quota.nil?
net_quota.xpath('NETWORK').each do |net_elem|
# The ID should exists, just in case it's missing it doesn't make
# sense to check this LEASES
next unless net_elem.at_xpath('ID')
# Check ID exists
unless net_elem.at_xpath('ID')
log_error("#{resource} #{oid} quotas: NETWORK doesn't have ID")
next
end
# Check leases
vnet_id = net_elem.at_xpath('ID').text
leases_used = vnet_usage.delete(vnet_id)
@ -513,6 +515,8 @@ module OneDBFsck
"\tis\t#{leases_used}")
e.content = leases_used.to_s
end
new_net_quota.add_child(net_elem)
end
vnet_usage.each do |vnet_id, leases_used|