From 0966f7525436a5656b9d05e1913fe19017524de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 26 Sep 2011 17:00:08 +0200 Subject: [PATCH] onedb: Add 3.0 migrator. It changes the tm_nfs drivers to tm_shared(cherry picked from commit 980222f28eb335ef0c4d66613664f4a99d9148dc) --- install.sh | 1 + src/onedb/2.9.90_to_3.0.rb | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/onedb/2.9.90_to_3.0.rb diff --git a/install.sh b/install.sh index d187f9b443..e6cdb3ea0a 100755 --- a/install.sh +++ b/install.sh @@ -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" diff --git a/src/onedb/2.9.90_to_3.0.rb b/src/onedb/2.9.90_to_3.0.rb new file mode 100644 index 0000000000..8692af3bfe --- /dev/null +++ b/src/onedb/2.9.90_to_3.0.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