mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-20 14:03:36 +03:00
Bug #2586: Better nokogiri formatting options
This commit is contained in:
parent
49b897fc4c
commit
45d60eb8f8
@ -56,7 +56,7 @@ module Migrator
|
||||
|
||||
# Aggregate information of the RUNNING vms
|
||||
@db.fetch("SELECT oid,body FROM vm_pool WHERE state<>6") do |row|
|
||||
vm_doc = Nokogiri::XML(row[:body])
|
||||
vm_doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
state = vm_doc.root.at_xpath('STATE').text.to_i
|
||||
lcm_state = vm_doc.root.at_xpath('LCM_STATE').text.to_i
|
||||
|
@ -291,7 +291,7 @@ module Migrator
|
||||
end
|
||||
|
||||
@db.fetch("SELECT * FROM old_user_pool WHERE oid>0") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
set_default_quotas(doc)
|
||||
|
||||
@ -329,7 +329,7 @@ module Migrator
|
||||
end
|
||||
|
||||
@db.fetch("SELECT * FROM old_group_pool WHERE oid>0") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
set_default_quotas(doc)
|
||||
|
||||
@ -452,7 +452,7 @@ module Migrator
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
user_template = doc.create_element("USER_TEMPLATE")
|
||||
|
||||
e = doc.root.at_xpath("TEMPLATE")
|
||||
@ -509,7 +509,7 @@ module Migrator
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_template_pool") do |row|
|
||||
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
template = doc.root.at_xpath("TEMPLATE")
|
||||
|
||||
@ -559,7 +559,7 @@ module Migrator
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
if ( row[:state] != 6 ) # DONE
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
nic_id = 0
|
||||
|
||||
|
@ -49,7 +49,7 @@ module Migrator
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.xpath("HISTORY_RECORDS/HISTORY").each do |e|
|
||||
update_history(e)
|
||||
@ -79,7 +79,7 @@ module Migrator
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_history") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.xpath("/HISTORY").each do |e|
|
||||
update_history(e)
|
||||
|
@ -49,7 +49,7 @@ module Migrator
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_user_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.at_xpath("TEMPLATE").
|
||||
add_child(doc.create_element("TOKEN_PASSWORD")).
|
||||
@ -80,7 +80,7 @@ module Migrator
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_datastore_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.add_child(doc.create_element("TOTAL_MB")).content = "0"
|
||||
doc.root.add_child(doc.create_element("FREE_MB")).content = "0"
|
||||
|
@ -90,7 +90,7 @@ module Migrator
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_user_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
g_elem = doc.create_element("GROUPS")
|
||||
g_elem.add_child(doc.create_element("ID")).content = row[:gid].to_s
|
||||
@ -140,7 +140,7 @@ module Migrator
|
||||
end
|
||||
|
||||
@db.fetch("SELECT * FROM old_group_pool WHERE oid>0") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
redo_vm_quotas(doc, "gid=#{row[:oid]}")
|
||||
|
||||
@ -235,7 +235,7 @@ http://opennebula.org/documentation:rel4.4:upgrade
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.xpath("HISTORY_RECORDS/HISTORY").each do |e|
|
||||
update_history(e)
|
||||
@ -265,7 +265,7 @@ http://opennebula.org/documentation:rel4.4:upgrade
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_history") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.xpath("/HISTORY").each do |e|
|
||||
update_history(e)
|
||||
@ -293,7 +293,7 @@ http://opennebula.org/documentation:rel4.4:upgrade
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_host_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.at_xpath("HOST_SHARE").
|
||||
add_child(doc.create_element("DATASTORES"))
|
||||
@ -362,7 +362,7 @@ http://opennebula.org/documentation:rel4.4:upgrade
|
||||
vol_used = 0
|
||||
|
||||
@db.fetch("SELECT body FROM vm_pool WHERE #{where_filter} AND state<>6") do |vm_row|
|
||||
vmdoc = Nokogiri::XML(vm_row[:body])
|
||||
vmdoc = Nokogiri::XML(vm_row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
# VM quotas
|
||||
vmdoc.root.xpath("TEMPLATE/CPU").each { |e|
|
||||
|
@ -735,7 +735,7 @@ module OneDBFsck
|
||||
|
||||
# Aggregate information of the RUNNING vms
|
||||
@db.fetch("SELECT oid,body FROM vm_pool WHERE state<>6") do |row|
|
||||
vm_doc = Nokogiri::XML(row[:body])
|
||||
vm_doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
state = vm_doc.root.at_xpath('STATE').text.to_i
|
||||
lcm_state = vm_doc.root.at_xpath('LCM_STATE').text.to_i
|
||||
@ -1070,7 +1070,7 @@ module OneDBFsck
|
||||
|
||||
@db.transaction do
|
||||
@db[:leases].each do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
used = (doc.root.at_xpath('USED').text == "1")
|
||||
vid = doc.root.at_xpath('VID').text.to_i
|
||||
@ -1237,7 +1237,7 @@ module OneDBFsck
|
||||
end
|
||||
|
||||
@db.fetch("SELECT * FROM old_user_pool WHERE oid>0") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
calculate_quotas(doc, "uid=#{row[:oid]}", "User")
|
||||
|
||||
@ -1273,7 +1273,7 @@ module OneDBFsck
|
||||
end
|
||||
|
||||
@db.fetch("SELECT * FROM old_group_pool WHERE oid>0") do |row|
|
||||
doc = Nokogiri::XML(row[:body])
|
||||
doc = Nokogiri::XML(row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
calculate_quotas(doc, "gid=#{row[:oid]}", "Group")
|
||||
|
||||
@ -1327,7 +1327,7 @@ module OneDBFsck
|
||||
img_usage = {}
|
||||
|
||||
@db.fetch("SELECT body FROM vm_pool WHERE #{where_filter} AND state<>6") do |vm_row|
|
||||
vmdoc = Nokogiri::XML(vm_row[:body])
|
||||
vmdoc = Nokogiri::XML(vm_row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
# VM quotas
|
||||
vmdoc.root.xpath("TEMPLATE/CPU").each { |e|
|
||||
@ -1512,7 +1512,7 @@ module OneDBFsck
|
||||
ds_usage = {}
|
||||
|
||||
@db.fetch("SELECT body FROM image_pool WHERE #{where_filter}") do |img_row|
|
||||
img_doc = Nokogiri::XML(img_row[:body])
|
||||
img_doc = Nokogiri::XML(img_row[:body]){|c| c.default_xml.noblanks}
|
||||
|
||||
img_doc.root.xpath("DATASTORE_ID").each { |e|
|
||||
ds_usage[e.text] = [0,0] if ds_usage[e.text].nil?
|
||||
|
Loading…
x
Reference in New Issue
Block a user