mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
onedb: Add 3.0 migrator. It changes the tm_nfs drivers to tm_shared(cherry picked from commit 980222f28eb335ef0c4d66613664f4a99d9148dc)
This commit is contained in:
parent
a2ad103ad9
commit
0966f75254
@ -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"
|
||||
|
||||
|
48
src/onedb/2.9.90_to_3.0.rb
Normal file
48
src/onedb/2.9.90_to_3.0.rb
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user