Skip to content

Commit

Permalink
B OpenNebula#1710: network fsck takes reserved networks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Huertas committed May 31, 2019
1 parent 7466813 commit 097e270
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/onedb/fsck/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def calculate_leases(address_range, oid, addrs, p_vnet, p_ar)
address_range.at_xpath('SIZE').text.to_i.times do |index|
lease = get_lease(oid, addrs[:mac], addrs[:ip], addrs[:ipv6], index)

counters[:vnet][p_vnet][:ar_leases][p_ar][mac] = lease
counters[:vnet][p_vnet][:ar_leases][p_ar][lease[:mac_index]] = lease
end
end

Expand Down
17 changes: 17 additions & 0 deletions src/onedb/fsck/quotas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def calculate_quotas(doc, filter, resource)

queries << "SELECT body FROM vm_pool WHERE #{filter} AND state<>6"
queries << "SELECT body FROM vrouter_pool WHERE #{filter}"
queries << "SELECT body FROM network_pool WHERE #{filter}"

calculate_vnet_quotas(doc, queries, resource)

Expand Down Expand Up @@ -466,6 +467,22 @@ def calculate_vnet_quotas(doc, queries, resource)
end
end

# Calculate quotas for reserved networks
@db.fetch(queries[2]) do |vnet_row|
vnet_doc = nokogiri_doc(vnet_row[:body])

vnet_doc.xpath('VNET/AR_POOL').each do |ar|
parent_id = ar.xpath('AR/PARENT_NETWORK_AR_ID')
parent_id = parent_id.text unless parent_id.nil?
size = ar.xpath('AR/SIZE').text.to_i

if !parent_id.nil?
vnet_usage[parent_id] = 0 if vnet_usage[parent_id].nil?
vnet_usage[parent_id] += size
end
end
end

net_quota = nil
doc.root.xpath('NETWORK_QUOTA').each {|e| net_quota = e }

Expand Down

0 comments on commit 097e270

Please sign in to comment.