1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

Merge branch 'master' of git.opennebula.org:one

This commit is contained in:
Daniel Molina 2011-07-12 15:33:10 +02:00
commit 86e65eb082
8 changed files with 124 additions and 35 deletions

View File

@ -231,10 +231,10 @@ public:
return "OpenNebula 2.3.0";
};
static int db_version()
static string db_version()
{
return 1;
};
return "2.9.80";
}
void start();

View File

@ -548,7 +548,7 @@ IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \
#-------------------------------------------------------------------------------
# Migration scripts for onedb command, to be installed under $LIB_LOCATION
#-------------------------------------------------------------------------------
ONEDB_MIGRATOR_FILES="src/onedb/1.rb \
ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \
src/onedb/onedb.rb \
src/onedb/onedb_backend.rb"

View File

@ -29,6 +29,35 @@ group :cloud do
gem 'thin', '1.2.7'
gem 'uuid'
gem 'curb'
gem 'sqlite3-ruby'
end
group :ozones_client do
gem 'json', '= 1.5.1'
end
group :ozones_server do
gem 'json', '= 1.5.1'
gem 'datamapper'
gem 'dm-sqlite-adapter'
gem 'dm-mysql-adapter'
end
group :ozones_server_mysql do
gem 'json', '= 1.5.1'
gem 'datamapper'
gem 'dm-mysql-adapter'
end
group :ozones_server_sqlite do
gem 'json', '= 1.5.1'
gem 'datamapper'
gem 'dm-sqlite-adapter'
end
group :dummy do
gem 'rake'
end

65
share/bundler/install_gems Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env ruby
PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server
ozones_server_mysql ozones_server_sqlite}
DEFAULT=%w{optional sunstone quota cloud ozones_server}
class String
def unindent(spaces=4)
self.gsub!(/^ {#{spaces}}/, '')
end
end
def try_library(name, error_message)
begin
require name.to_s
rescue LoadError
STDERR.puts error_message
exit -1
end
end
try_library :rubygems, <<-EOT.unindent
rubygems required to use this tool
Use one of these methods:
* Debian/Ubuntu
apt-get install rubygems libopenssl-ruby
* RHEL/CENTOS
yum install rubygems
* Specific rubygems package for your distro
* Follow the instructions from http://rubygems.org/pages/download
EOT
try_library :bundler, <<-EOT.unindent
bundler needed to install gems
execute this to install it:
[sudo] gem install bundler
EOT
if ARGV.length>0
packages=ARGV
else
packages=DEFAULT
end
no_packages=PACKAGES-packages
no_packages<<'dummy'
without="--without #{no_packages.join(' ')}"
command_string = "bundle #{without}"
puts command_string
#system command_string

View File

@ -635,7 +635,7 @@ void Nebula::bootstrap()
oss.str("");
oss << "CREATE TABLE db_versioning (oid INTEGER PRIMARY KEY, "
"version INTEGER, timestamp INTEGER, comment VARCHAR(256))";
"version VARCHAR(256), timestamp INTEGER, comment VARCHAR(256))";
db->exec(oss);
@ -656,7 +656,7 @@ int Nebula::check_db_version()
ostringstream oss;
int loaded_db_version = 0;
string loaded_db_version = "";
// Try to read latest version
set_callback( static_cast<Callbackable::Callback>(&Nebula::select_cb),
@ -670,7 +670,7 @@ int Nebula::check_db_version()
oss.str("");
unset_callback();
if( loaded_db_version == 0 )
if( loaded_db_version == "" )
{
// Table user_pool is present for all OpenNebula versions, and it
// always contains at least the oneadmin user.
@ -703,16 +703,13 @@ int Nebula::select_cb(void *_loaded_db_version, int num, char **values,
char **names)
{
istringstream iss;
int * loaded_db_version;
string * loaded_db_version;
loaded_db_version = static_cast<int *>(_loaded_db_version);
*loaded_db_version = 0;
loaded_db_version = static_cast<string *>(_loaded_db_version);
if ( (values[0]) && (num == 1) )
{
iss.str(values[0]);
iss >> *loaded_db_version;
*loaded_db_version = values[0];
}
return 0;

View File

@ -17,11 +17,11 @@ require "rexml/document"
module Migrator
def db_version
1
"2.9.80"
end
def one_version
"OpenNebula 2.3.0"
"OpenNebula 2.9.80"
end
def up
@ -292,7 +292,7 @@ module Migrator
# New tables in DB version 1
########################################################################
@db.run "CREATE TABLE db_versioning (oid INTEGER PRIMARY KEY, version INTEGER, timestamp INTEGER, comment VARCHAR(256));"
@db.run "CREATE TABLE db_versioning (oid INTEGER PRIMARY KEY, version VARCHAR(256), timestamp INTEGER, comment VARCHAR(256));"
@db.run "CREATE TABLE template_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, uid INTEGER, gid INTEGER, public INTEGER);"
@db.run "CREATE TABLE acl (oid INT PRIMARY KEY, user BIGINT, resource BIGINT, rights BIGINT);"

View File

@ -78,7 +78,7 @@ class OneDB
if(ops[:verbose])
puts "Version: #{version}"
time = version == 0 ? Time.now : Time.at(timestamp)
time = version == "2.0" ? Time.now : Time.at(timestamp)
puts "Timestamp: #{time.strftime("%m/%d %H:%M:%S")}"
puts "Comment: #{comment}"
else
@ -93,6 +93,8 @@ class OneDB
return 0
end
# max_version is ignored for now, as this is the first onedb release.
# May be used in next releases
def upgrade(max_version, ops)
version, timestamp, comment = @backend.read_db_version
@ -101,19 +103,18 @@ class OneDB
puts "#{version} : #{comment}"
puts ""
end
migrator_version = version + 1
result = nil
file = "#{RUBY_LIB_LOCATION}/onedb/#{migrator_version}.rb"
if File.exists?(file) &&
(max_version == nil || migrator_version <= max_version)
########################################################################
# For now, look for the only file we can migrate to, *_to_2.9.80.rb
########################################################################
result = nil
file = "#{RUBY_LIB_LOCATION}/onedb/#{version}_to_2.9.80.rb"
if File.exists?(file)
# At least one upgrade will be executed, make DB backup
backup(ops[:backup], ops)
end
while File.exists?(file) &&
(max_version == nil || migrator_version <= max_version)
puts " > Running migrator #{file}" if ops[:verbose]
@ -122,18 +123,15 @@ class OneDB
result = @backend.up
if !result
puts "Error while upgrading from #{migrator_version-1} to " <<
puts "Error while upgrading from #{version} to " <<
" #{@backend.db_version}"
return -1
end
puts " > Done" if ops[:verbose]
puts "" if ops[:verbose]
migrator_version += 1
file = "#{RUBY_LIB_LOCATION}/onedb/#{migrator_version}.rb"
end
# Modify db_versioning table
if result != nil
@backend.update_db_version(version)

View File

@ -21,7 +21,7 @@ class OneDBBacKEnd
def read_db_version
connect_db
version = 0
version = "2.0"
timestamp = 0
comment = ""
@ -32,7 +32,7 @@ class OneDBBacKEnd
comment = row[:comment]
end
return [version.to_i, timestamp, comment]
return [version, timestamp, comment]
rescue
# If the DB doesn't have db_version table, it means it is empty or a 2.x
@ -54,7 +54,7 @@ class OneDBBacKEnd
comment = "Could not read any previous db_versioning data, " <<
"assuming it is an OpenNebula 2.0 or 2.2 DB."
return [0, 0, comment]
return [version, timestamp, comment]
end
def history