mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 11:22:55 +09:00
onedb: Add 3.0 migrator. It changes the tm_nfs drivers to tm_shared
This commit is contained in:
1 parent
9fc7f582e2
commit
980222f28e
2 files changed
+49
No files matched your search
@@ -653,6 +653,7 @@ IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \
|
||||
ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \
|
||||
src/onedb/2.9.80_to_2.9.85.rb \
|
||||
src/onedb/2.9.85_to_2.9.90.rb \
|
||||
src/onedb/2.9.90_to_3.0.rb \
|
||||
src/onedb/onedb.rb \
|
||||
src/onedb/onedb_backend.rb"
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# -------------------------------------------------------------------------- *
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# 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 "rexml/document"
|
||||
include REXML
|
||||
|
||||
module Migrator
|
||||
def db_version
|
||||
"3.0"
|
||||
end
|
||||
|
||||
def one_version
|
||||
"OpenNebula 3.0"
|
||||
end
|
||||
|
||||
def up
|
||||
# The tm_nfs driver has been renamed to tm_shared
|
||||
# CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));
|
||||
|
||||
@db.fetch("SELECT * FROM host_pool") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
source = nil
|
||||
doc.root.each_element("TM_MAD") { |e|
|
||||
if e.text.downcase == "tm_nfs"
|
||||
e.text = "tm_shared"
|
||||
|
||||
@db[:host_pool].filter(:oid => row[:oid]).update(
|
||||
:body => doc.root.to_s)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user