1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Feature #4215: Add migrator to 4.90.0

This commit is contained in:
Carlos Martín 2016-01-22 17:10:12 +01:00
parent e0ee90f34f
commit 1ae516a084
3 changed files with 92 additions and 2 deletions

View File

@ -408,7 +408,7 @@ public:
*/
static string local_db_version()
{
return "4.13.85";
return "4.90.0";
}
/**

View File

@ -1254,7 +1254,8 @@ ONEDB_LOCAL_MIGRATOR_FILES="src/onedb/local/4.5.80_to_4.7.80.rb \
src/onedb/local/4.9.80_to_4.10.3.rb \
src/onedb/local/4.10.3_to_4.11.80.rb \
src/onedb/local/4.11.80_to_4.13.80.rb \
src/onedb/local/4.13.80_to_4.13.85.rb"
src/onedb/local/4.13.80_to_4.13.85.rb \
src/onedb/local/4.13.85_to_4.90.0.rb"
ONEDB_PATCH_FILES="src/onedb/patches/4.14_monitoring.rb \
src/onedb/patches/history_times.rb"

View File

@ -0,0 +1,89 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'opennebula'
include OpenNebula
module Migrator
def db_version
"4.90.0"
end
def one_version
"OpenNebula 4.90.0"
end
def up
init_log_time()
# 4215
@db.run "CREATE TABLE vrouter_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
@db.transaction do
@db.fetch("SELECT oid,body FROM group_pool") do |row|
doc = Nokogiri::XML(row[:body],nil,NOKOGIRI_ENCODING){|c| c.default_xml.noblanks}
doc.root.xpath("ADMINS/ID").each do |uid|
user = Acl::USERS["UID"] | uid.text.to_i
resource = 354936097341440 | Acl::USERS["GID"] | row[:oid]
@db[:acl].where({
:user=>user, # #<uid>
:resource=>resource, # VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP/@<gid>
:rights=>3, # USE+MANAGE
:zone=>17179869184 # *
}).update(
# VM+NET+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VROUTER/@101
:resource => (1480836004184064 | Acl::USERS["GID"] | row[:oid]))
end
end
end
log_time()
@db.run "ALTER TABLE network_pool RENAME TO old_network_pool;"
@db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, pid INTEGER, UNIQUE(name,uid));"
@db.transaction do
@db.fetch("SELECT * FROM old_network_pool") do |row|
doc = Nokogiri::XML(row[:body],nil,NOKOGIRI_ENCODING){|c| c.default_xml.noblanks}
doc.root.add_child(doc.create_element("VROUTERS"))
@db[:network_pool].insert(
:oid => row[:oid],
:name => row[:name],
:body => doc.root.to_s,
:uid => row[:uid],
:gid => row[:gid],
:owner_u => row[:owner_u],
:group_u => row[:group_u],
:other_u => row[:other_u],
:cid => row[:cid],
:pid => row[:pid])
end
end
@db.run "DROP TABLE old_network_pool;"
log_time()
return true
end
end