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

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

This commit is contained in:
Pavel Czerný 2022-07-28 11:24:11 +02:00 committed by GitHub
parent 75f241110e
commit 665e2bb802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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|