mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Feature #3541: Update onedb upgrade and import-slave
This commit is contained in:
parent
833bf1a4d7
commit
1833424b6f
@ -470,6 +470,22 @@ EOT
|
||||
end
|
||||
end
|
||||
|
||||
slave_admins_elem = slave_doc.root.at_xpath("ADMINS")
|
||||
master_admins_elem = master_doc.root.at_xpath("ADMINS")
|
||||
|
||||
slave_admins_elem.xpath("ID").each do |id|
|
||||
user = users[id.text.to_i]
|
||||
|
||||
if !user.nil?
|
||||
user_id = user[:oid]
|
||||
|
||||
if master_admins_elem.at_xpath("ID [.=#{user_id}]").nil?
|
||||
master_admins_elem.add_child(
|
||||
master_doc.create_element("ID")).content = user_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
slave_template = slave_doc.root.at_xpath("TEMPLATE")
|
||||
master_template = master_doc.root.at_xpath("TEMPLATE")
|
||||
|
||||
@ -501,18 +517,34 @@ EOT
|
||||
users_elem = slave_doc.root.at_xpath("USERS")
|
||||
users_elem.remove
|
||||
|
||||
new_elem = slave_doc.create_element("USERS")
|
||||
new_users_elem = slave_doc.create_element("USERS")
|
||||
|
||||
users_elem.xpath("ID").each do |id|
|
||||
user = users[id.text.to_i]
|
||||
|
||||
if !user.nil?
|
||||
new_elem.add_child(slave_doc.create_element("ID")).
|
||||
new_users_elem.add_child(slave_doc.create_element("ID")).
|
||||
content = user[:oid]
|
||||
end
|
||||
end
|
||||
|
||||
slave_doc.root.add_child(new_elem)
|
||||
slave_doc.root.add_child(new_users_elem)
|
||||
|
||||
admins_elem = slave_doc.root.at_xpath("ADMINS")
|
||||
admins_elem.remove
|
||||
|
||||
new_admins_elem = slave_doc.create_element("ADMINS")
|
||||
|
||||
admins_elem.xpath("ID").each do |id|
|
||||
user = users[id.text.to_i]
|
||||
|
||||
if !user.nil?
|
||||
new_admins_elem.add_child(slave_doc.create_element("ID")).
|
||||
content = user[:oid]
|
||||
end
|
||||
end
|
||||
|
||||
slave_doc.root.add_child(new_admins_elem)
|
||||
|
||||
# Update resource providers
|
||||
slave_doc.root.xpath("RESOURCE_PROVIDER").each do |elem|
|
||||
|
@ -86,6 +86,40 @@ EOT
|
||||
end
|
||||
end
|
||||
|
||||
admin_v_elem = doc.at_xpath("/GROUP/TEMPLATE/GROUP_ADMIN_VIEWS")
|
||||
|
||||
if (!admin_v_elem.nil?)
|
||||
aux_e = doc.at_xpath("/GROUP/TEMPLATE/GROUP_ADMIN_DEFAULT_VIEW")
|
||||
aux_e.remove if !aux_e.nil?
|
||||
|
||||
doc.at_xpath("/GROUP/TEMPLATE").add_child(
|
||||
doc.create_element("GROUP_ADMIN_DEFAULT_VIEW")).
|
||||
add_child(Nokogiri::XML::CDATA.new(
|
||||
doc,
|
||||
admin_v_elem.text))
|
||||
end
|
||||
|
||||
admins_elem = doc.root.add_child( doc.create_element("ADMINS") )
|
||||
|
||||
elem = doc.at_xpath("/GROUP/TEMPLATE/GROUP_ADMINS")
|
||||
|
||||
if (!elem.nil?)
|
||||
elem.remove
|
||||
|
||||
elem.text.split(",").each do |uname|
|
||||
@db.fetch("SELECT oid FROM user_pool \
|
||||
WHERE name=\"#{uname.strip}\"") do |user_row|
|
||||
|
||||
# Check that user is part of this group first
|
||||
if !doc.at_xpath("/GROUP/USERS/ID[.=#{user_row[:oid]}]").nil?
|
||||
admins_elem.add_child(
|
||||
doc.create_element("ID") ).content =
|
||||
user_row[:oid]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
res_providers = doc.xpath("/GROUP/RESOURCE_PROVIDER")
|
||||
|
||||
res_providers.each do |provider|
|
||||
|
Loading…
Reference in New Issue
Block a user