From e4e3104f26b1038d8f05959361650adaa54969e1 Mon Sep 17 00:00:00 2001 From: Jaime Melis <j.melis@fdi.ucm.es> Date: Fri, 22 Oct 2010 18:01:32 +0200 Subject: [PATCH 01/15] bug #372: global read permissions for disk file --- src/tm_mad/nfs/tm_clone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/nfs/tm_clone.sh index f1a904ab6c..7ee131ce12 100755 --- a/src/tm_mad/nfs/tm_clone.sh +++ b/src/tm_mad/nfs/tm_clone.sh @@ -55,5 +55,5 @@ http://*) ;; esac -exec_and_log "chmod a+w $DST_PATH" +exec_and_log "chmod a+rw $DST_PATH" From 7e6f14f4aff1186473c63dc70504f72ee8d21d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= <tinova@fdi.ucm.es> Date: Tue, 26 Oct 2010 11:40:58 +0200 Subject: [PATCH 02/15] Change typo in one script --- share/scripts/one | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/scripts/one b/share/scripts/one index df90024a5a..24135ebdc9 100755 --- a/share/scripts/one +++ b/share/scripts/one @@ -89,7 +89,7 @@ start() if [ -z "$ONE_AUTH" ]; then echo "You should have ONE_AUTH set the first time you start" echo "OpenNebula as it is used to set the credentials for" - echo "the adminitrator user." + echo "the administrator user." exit 1 fi fi From 0b42b5efe898d73e313ff1e1dca7232607600986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= <tinova@fdi.ucm.es> Date: Wed, 27 Oct 2010 13:10:51 +0200 Subject: [PATCH 03/15] bug #373: Fix bad LocalCommand.run call --- src/im_mad/im_sh/one_im_sh.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/im_mad/im_sh/one_im_sh.rb b/src/im_mad/im_sh/one_im_sh.rb index c2ab321cef..79714d2934 100755 --- a/src/im_mad/im_sh/one_im_sh.rb +++ b/src/im_mad/im_sh/one_im_sh.rb @@ -64,7 +64,7 @@ class InformationManager < OpenNebulaDriver end cmd_string = "#{@cmd_path}/run_probes #{@hypervisor} #{host}" - monitor_exe = LocalCommand.run(cmd_string, host, log_method(id)) + monitor_exe = LocalCommand.run(cmd_string, log_lambda) if monitor_exe.code == 0 send_message("MONITOR", RESULT[:success], number, monitor_exe.stdout) From 094ae8b0183f0cfab863c83dfd7c5103ed58507a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= <tinova@fdi.ucm.es> Date: Thu, 28 Oct 2010 19:54:09 +0200 Subject: [PATCH 04/15] Typo in oneimage saveas description --- src/cli/onevm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/onevm b/src/cli/onevm index e454e20cc5..43c2e3edbf 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -353,7 +353,7 @@ Commands: onevm resume <vm_id> * saveas (Set the specified vms disk to be saved in a new image (image_name) - when the vm shutdowns) + when the vm shuts down) onevm saveas <vm_id> <disk_id> <image_name> (Set a different type for the new Image) From eb3bd9e6dfc62a82bf9c36c0b839cbd131af6c2d Mon Sep 17 00:00:00 2001 From: Jaime Melis <j.melis@fdi.ucm.es> Date: Thu, 28 Oct 2010 20:50:17 +0200 Subject: [PATCH 05/15] bug #380: Fixed correct path for read_configuration method --- src/im_mad/im_ssh/one_im_ssh.rb | 2 +- src/mad/ruby/ActionManager.rb | 2 +- src/vmm_mad/ssh/one_vmm_ssh.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index 0ab0b31794..57dd1514c8 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -49,7 +49,7 @@ class InformationManager < OpenNebulaDriver @config = read_configuration @hypervisor = hypervisor - @remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one' + @remote_dir = @config['SCRIPTS_REMOTE_DIR'] # register actions register_action(:MONITOR, method("action_monitor")) diff --git a/src/mad/ruby/ActionManager.rb b/src/mad/ruby/ActionManager.rb index a7feb2893c..2c7a1b4cd5 100644 --- a/src/mad/ruby/ActionManager.rb +++ b/src/mad/ruby/ActionManager.rb @@ -183,7 +183,7 @@ private if ENV['ONE_LOCATION'] one_config=ENV['ONE_LOCATION']+'/var/config' else - one_config='/var/log/one/config' + one_config='/var/lib/one/config' end config=Hash.new diff --git a/src/vmm_mad/ssh/one_vmm_ssh.rb b/src/vmm_mad/ssh/one_vmm_ssh.rb index ed37db0fee..014eda5090 100755 --- a/src/vmm_mad/ssh/one_vmm_ssh.rb +++ b/src/vmm_mad/ssh/one_vmm_ssh.rb @@ -47,7 +47,7 @@ class SshDriver < VirtualMachineDriver @config = read_configuration @hypervisor = hypervisor - @remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one' + @remote_dir = @config['SCRIPTS_REMOTE_DIR'] end # ------------------------------------------------------------------------ # From 827795d6face7932c592c48b6053bcaea9579f14 Mon Sep 17 00:00:00 2001 From: Jaime Melis <j.melis@fdi.ucm.es> Date: Thu, 28 Oct 2010 21:12:36 +0200 Subject: [PATCH 06/15] fixed vmcontext example for CentOS: updated start priority of script --- share/scripts/centos-5/net-vmcontext/vmcontext | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/scripts/centos-5/net-vmcontext/vmcontext b/share/scripts/centos-5/net-vmcontext/vmcontext index a8ec7663dc..e68bb2ffa9 100755 --- a/share/scripts/centos-5/net-vmcontext/vmcontext +++ b/share/scripts/centos-5/net-vmcontext/vmcontext @@ -1,6 +1,6 @@ #!/bin/bash # -# chkconfig: 2345 10 90 +# chkconfig: 2345 9 90 # description: network reconfigure # # -------------------------------------------------------------------------- # From e3d82b69e9eeb4d152e085a22b2fb9f789430af6 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 29 Oct 2010 18:50:57 +0200 Subject: [PATCH 07/15] feature #348: Xen DISKs can now use a custom driver (tap:aio:, file:, ...) --- src/vmm/XenDriver.cc | 39 +++++++++++++++++++++++++++----- src/vmm_mad/ssh/vmm_ssh_xen.conf | 3 ++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index 53894ffd8d..a744f5519d 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -49,6 +49,8 @@ int XenDriver::deployment_description( string target = ""; string ro = ""; string type = ""; + string driver = ""; + string default_driver = ""; string mode; const VectorAttribute * nic; @@ -216,6 +218,13 @@ int XenDriver::deployment_description( num = vm->get_template_attribute("DISK",attrs); + get_default("DISK","DRIVER",default_driver); + + if (default_driver.empty()) + { + default_driver = "tap:aio:"; + } + file << "disk = [" << endl; for (int i=0; i < num ;i++) @@ -230,6 +239,7 @@ int XenDriver::deployment_description( target = disk->vector_value("TARGET"); type = disk->vector_value("TYPE"); ro = disk->vector_value("READONLY"); + driver = disk->vector_value("DRIVER"); if ( target.empty() ) { @@ -253,13 +263,20 @@ int XenDriver::deployment_description( } } - if ( type == "BLOCK" ) + if ( !driver.empty() ) { - file << " 'phy:"; + file << " '" << driver; } else { - file << " 'tap:aio:"; + if ( type == "BLOCK" ) + { + file << " 'phy:"; + } + else + { + file << " '" << default_driver; + } } file << vm->get_remote_dir() << "/disk." << i << "," @@ -278,12 +295,22 @@ int XenDriver::deployment_description( { context = dynamic_cast<const VectorAttribute *>(attrs[0]); target = context->vector_value("TARGET"); + driver = context->vector_value("DRIVER"); if ( !target.empty() ) { - file << " " - << "'tap:aio:" << vm->get_remote_dir() << "/disk." << num <<"," - << target << "," + file << " '"; + + if ( !driver.empty() ) + { + file << driver; + } + else + { + file << default_driver; + } + + file << vm->get_remote_dir() << "/disk." << num <<","<< target <<"," << "r'," << endl; } else diff --git a/src/vmm_mad/ssh/vmm_ssh_xen.conf b/src/vmm_mad/ssh/vmm_ssh_xen.conf index 573d8209fa..8d41b2770b 100644 --- a/src/vmm_mad/ssh/vmm_ssh_xen.conf +++ b/src/vmm_mad/ssh/vmm_ssh_xen.conf @@ -5,9 +5,10 @@ # - os [kernel,initrd,root,kernel_cmd] # - memory # - vcpu +# - disk[driver] #VCPU = 1 #MEMORY = 128 #OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", kernel_cmd="ro" ] CREDIT = 256 - +DISK = [ driver = "tap:aio:" ] From b6d4a7a925300be8a3387c5a112fec6600fb5a3a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 29 Oct 2010 19:18:56 +0200 Subject: [PATCH 08/15] feature #356: Disk format can be now specified for KVM using the driver attribute, also this is supported for CONTEXT --- src/vmm/LibVirtDriverKVM.cc | 45 +++++++++++++++++++++++++++++++- src/vmm_mad/ssh/vmm_ssh_kvm.conf | 10 +++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index f40ebbca98..4fdd14a4c1 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -49,6 +49,8 @@ int LibVirtDriver::deployment_description_kvm( string target = ""; string bus = ""; string ro = ""; + string driver = ""; + string default_driver = ""; bool readonly; const VectorAttribute * nic; @@ -245,6 +247,13 @@ int LibVirtDriver::deployment_description_kvm( file << "\t\t<emulator>/usr/bin/kvm</emulator>" << endl; } + get_default("DISK","DRIVER",default_driver); + + if (default_driver.empty()) + { + default_driver = "raw"; + } + num = vm->get_template_attribute("DISK",attrs); for (int i=0; i < num ;i++) @@ -260,6 +269,7 @@ int LibVirtDriver::deployment_description_kvm( target = disk->vector_value("TARGET"); ro = disk->vector_value("READONLY"); bus = disk->vector_value("BUS"); + driver = disk->vector_value("DRIVER"); if (target.empty()) { @@ -278,6 +288,8 @@ int LibVirtDriver::deployment_description_kvm( } } + // ---- Disk type and source for the image ---- + if (type.empty() == false) { transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); @@ -302,8 +314,12 @@ int LibVirtDriver::deployment_description_kvm( << i << "'/>" << endl; } + // ---- target device to map the disk ---- + file << "\t\t\t<target dev='" << target << "'"; + // ---- bus ---- + if (!bus.empty()) { file << " bus='" << bus << "'/>" << endl; @@ -313,11 +329,26 @@ int LibVirtDriver::deployment_description_kvm( file << "/>" << endl; } + // ---- readonly attribute for the disk ---- + if (readonly) { file << "\t\t\t<readonly/>" << endl; } + // ---- Image Format using qemu driver ---- + + file << "\t\t\t<driver name='qemu' type='"; + + if ( !driver.empty() ) + { + file << driver << "'/>" << endl; + } + else + { + file << default_driver << "'/>" << endl; + } + file << "\t\t</disk>" << endl; } @@ -331,6 +362,7 @@ int LibVirtDriver::deployment_description_kvm( { context = dynamic_cast<const VectorAttribute *>(attrs[0]); target = context->vector_value("TARGET"); + driver = context->vector_value("DRIVER"); if ( !target.empty() ) { @@ -339,6 +371,18 @@ int LibVirtDriver::deployment_description_kvm( << num << "'/>" << endl; file << "\t\t\t<target dev='" << target << "'/>" << endl; file << "\t\t\t<readonly/>" << endl; + + file << "\t\t\t<driver name='qemu' type='"; + + if ( !driver.empty() ) + { + file << driver << "'/>" << endl; + } + else + { + file << default_driver << "'/>" << endl; + } + file << "\t\t</disk>" << endl; } else @@ -587,4 +631,3 @@ error_disk: file.close(); return -1; } - diff --git a/src/vmm_mad/ssh/vmm_ssh_kvm.conf b/src/vmm_mad/ssh/vmm_ssh_kvm.conf index 7ba58ee1f4..17b50215d5 100644 --- a/src/vmm_mad/ssh/vmm_ssh_kvm.conf +++ b/src/vmm_mad/ssh/vmm_ssh_kvm.conf @@ -6,13 +6,11 @@ # - cpu # - vcpu # - features [acpi, pae] +# - disk [driver ] #VCPU = 1 #MEMORY = 128 -#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", boot=hd,kernel_cmd="ro"] -OS = [ boot = "hd" ] +OS = [ boot = "hd" ] +FEATURES = [ PAE = "no", ACPI = "yes" ] -FEATURES = [ - PAE=no, - ACPI=yes -] +DISK = [ driver = "raw" ] From 317c30d7f20091bf5266d290690a6489b44566d7 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 29 Oct 2010 20:46:05 +0200 Subject: [PATCH 09/15] feature #356 #348: Support for the DRIVER attribute in the Image repository --- src/image/Image.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/image/Image.cc b/src/image/Image.cc index 2a8e837254..3924c389b2 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -434,9 +434,9 @@ int Image::drop(SqlDB * db) ostream& operator<<(ostream& os, Image& image) { - string image_str; + string image_str; - os << image.to_xml(image_str); + os << image.to_xml(image_str); return os; } @@ -571,20 +571,25 @@ int Image::disk_attribute( VectorAttribute * disk, { string bus; string target; + string driver; ostringstream iid; *img_type = type; bus = disk->vector_value("BUS"); target = disk->vector_value("TARGET"); + driver = disk->vector_value("DRIVER"); iid << oid; string template_bus; string template_target; string prefix; + string template_driver; get_template_attribute("BUS", template_bus); get_template_attribute("TARGET", template_target); + get_template_attribute("DRIVER", template_driver); + get_template_attribute("DEV_PREFIX", prefix); //-------------------------------------------------------------------------- @@ -612,7 +617,16 @@ int Image::disk_attribute( VectorAttribute * disk, } else if (!template_bus.empty()) { - new_disk.insert(make_pair("BUS",template_bus)); + new_disk.insert(make_pair("BUS",template_bus)); + } + + if (!driver.empty()) + { + new_disk.insert(make_pair("DRIVER",driver)); + } + else if (!template_driver.empty()) + { + new_disk.insert(make_pair("DRIVER",template_driver)); } //--------------------------------------------------------------------------- @@ -714,4 +728,3 @@ string Image::sha1_digest(const string& pass) /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ - From 3527cad6f270e28abb1ced780243e6ab95c9abf3 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 29 Oct 2010 23:00:38 +0200 Subject: [PATCH 10/15] Support for type in vif (Xen). Now Windows guests can use the Network manager easily --- src/vmm/XenDriver.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index a744f5519d..01b528d5c2 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -57,6 +57,7 @@ int XenDriver::deployment_description( string mac = ""; string bridge = ""; + string model = ""; const VectorAttribute * graphics; @@ -347,10 +348,17 @@ int XenDriver::deployment_description( mac = nic->vector_value("MAC"); bridge = nic->vector_value("BRIDGE"); + model = nic->vector_value("MODEL"); + + if( !model.empty() ) + { + file << "type=" << model; + pre_char = ','; + } if( !mac.empty() ) { - file << "mac=" << mac; + file << pre_char << "mac=" << mac; pre_char = ','; } From 586ad87a8a4f4d82928115dd5316f29f5a4cce1a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 29 Oct 2010 23:26:52 +0200 Subject: [PATCH 11/15] Adds default to SRCIPTS_REMOTE_DIR if not set in oned.conf --- src/nebula/NebulaTemplate.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index a38f592fd2..c9c1a5bd17 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -52,6 +52,7 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location) # PORT # DB # VNC_BASE_PORT +# SCRIPTS_REMOTE_DIR #******************************************************************************* */ // MONITOR_INTERVAL @@ -94,6 +95,13 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location) attribute = new SingleAttribute("PORT",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + //SCRIPTS_REMOTE_DIR + value = "/var/tmp/one"; + + attribute = new SingleAttribute("SCRIPTS_REMOTE_DIR",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + /* #******************************************************************************* # Physical Networks configuration @@ -188,4 +196,3 @@ int NebulaTemplate::load_configuration() return 0; } - From af3ed5d9d81963c9d66dd844d3c26cb4b9a71e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= <tinova@fdi.ucm.es> Date: Thu, 4 Nov 2010 19:05:19 +0100 Subject: [PATCH 12/15] Fix for bug #391: Now attributes are not asked for text attribute --- src/oca/ruby/OpenNebula/XMLUtils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oca/ruby/OpenNebula/XMLUtils.rb b/src/oca/ruby/OpenNebula/XMLUtils.rb index 48bb2fd373..71dbd99789 100644 --- a/src/oca/ruby/OpenNebula/XMLUtils.rb +++ b/src/oca/ruby/OpenNebula/XMLUtils.rb @@ -86,7 +86,7 @@ module OpenNebula attribute = element.attr(name) - value = attribute.text if attribute != nil + value = attribute if attribute != nil else element=@xml.elements[key.to_s.upcase] From 5f6b326c52a53fbc709c1c35bf1a301b1593a775 Mon Sep 17 00:00:00 2001 From: Jaime Melis <j.melis@fdi.ucm.es> Date: Mon, 8 Nov 2010 19:35:42 +0100 Subject: [PATCH 13/15] bug #382: ISO tmp path for context does not work in system wide installations --- src/tm_mad/lvm/tm_context.sh | 6 +++++- src/tm_mad/ssh/tm_context.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tm_mad/lvm/tm_context.sh b/src/tm_mad/lvm/tm_context.sh index b420be348a..417c82e78d 100755 --- a/src/tm_mad/lvm/tm_context.sh +++ b/src/tm_mad/lvm/tm_context.sh @@ -42,7 +42,11 @@ DST_PATH=`arg_path $DST` DST_DIR=`dirname $DST_PATH` DST_FILE=`basename $DST_PATH` DST_HASH=`echo -n $DST | $MD5SUM | $AWK '{print $1}'` -TMP_DIR="$ONE_LOCATION/var/$DST_HASH" +if [ -z "$ONE_LOCATION" ]; then + TMP_DIR="/var/lib/one/$DST_HASH" +else + TMP_DIR="$ONE_LOCATION/var/$DST_HASH" +fi ISO_DIR="$TMP_DIR/isofiles" diff --git a/src/tm_mad/ssh/tm_context.sh b/src/tm_mad/ssh/tm_context.sh index b420be348a..417c82e78d 100755 --- a/src/tm_mad/ssh/tm_context.sh +++ b/src/tm_mad/ssh/tm_context.sh @@ -42,7 +42,11 @@ DST_PATH=`arg_path $DST` DST_DIR=`dirname $DST_PATH` DST_FILE=`basename $DST_PATH` DST_HASH=`echo -n $DST | $MD5SUM | $AWK '{print $1}'` -TMP_DIR="$ONE_LOCATION/var/$DST_HASH" +if [ -z "$ONE_LOCATION" ]; then + TMP_DIR="/var/lib/one/$DST_HASH" +else + TMP_DIR="$ONE_LOCATION/var/$DST_HASH" +fi ISO_DIR="$TMP_DIR/isofiles" From 33e01f53b16726cb5db74d99242c03f12123b542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= <cmartins@fdi.ucm.es> Date: Wed, 10 Nov 2010 18:44:13 +0100 Subject: [PATCH 14/15] Feature #377: MySQL port is now defined in oned.conf --- include/MySqlDB.h | 2 ++ include/test/PoolTest.h | 2 +- share/etc/oned.conf | 3 +++ src/nebula/Nebula.cc | 16 +++++++++++++++- src/pool/test/pool.cc | 2 +- src/sql/MySqlDB.cc | 3 ++- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/MySqlDB.h b/include/MySqlDB.h index 94ff2055ab..f0d1e1d302 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -44,6 +44,7 @@ class MySqlDB : public SqlDB public: MySqlDB(const string& server, + const int& port, const string& user, const string& password, char * database); @@ -109,6 +110,7 @@ public: MySqlDB( string server, + int port, string user, string password, char * database) diff --git a/include/test/PoolTest.h b/include/test/PoolTest.h index 91a90654cf..c2324cbebb 100644 --- a/include/test/PoolTest.h +++ b/include/test/PoolTest.h @@ -98,7 +98,7 @@ public: { if (mysql) { - db = new MySqlDB("localhost","oneadmin","oneadmin",NULL); + db = new MySqlDB("localhost",0,"oneadmin","oneadmin",NULL); ostringstream oss1; oss1 << "DROP DATABASE IF EXISTS " << db_name; diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 35dfd523e1..94da223341 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -19,6 +19,8 @@ # DB: Configuration attributes for the database backend # backend : can be sqlite or mysql (default is sqlite) # server : (mysql) host name or an IP address for the MySQL server +# port : (mysql) port for the connection to the server. +# If set to 0, the default port is used. # user : (mysql) user's MySQL login ID # passwd : (mysql) the password for user # db_name : (mysql) the database name @@ -44,6 +46,7 @@ DB = [ backend = "sqlite" ] # Sample configuration for MySQL # DB = [ backend = "mysql", # server = "localhost", +# port = 0, # user = "oneadmin", # passwd = "oneadmin", # db_name = "opennebula" ] diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 1f3c31f63b..74a1a87974 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -141,6 +141,8 @@ void Nebula::start() bool db_is_sqlite = true; string server = "localhost"; + string port_str; + int port = 0; string user = "oneadmin"; string passwd = "oneadmin"; string db_name = "opennebula"; @@ -164,6 +166,18 @@ void Nebula::start() server = value; } + istringstream is; + + port_str = db->vector_value("PORT"); + + is.str(port_str); + is >> port; + + if( is.fail() ) + { + port = 0; + } + value = db->vector_value("USER"); if (!value.empty()) { @@ -194,7 +208,7 @@ void Nebula::start() { ostringstream oss; - db = new MySqlDB(server,user,passwd,0); + db = new MySqlDB(server,port,user,passwd,0); oss << "CREATE DATABASE IF NOT EXISTS " << db_name; rc = db->exec(oss); diff --git a/src/pool/test/pool.cc b/src/pool/test/pool.cc index f12e95cb3f..f2641c46ee 100644 --- a/src/pool/test/pool.cc +++ b/src/pool/test/pool.cc @@ -72,7 +72,7 @@ public: if (mysql) { - db = new MySqlDB("localhost","oneadmin","oneadmin",NULL); + db = new MySqlDB("localhost",0,"oneadmin","oneadmin",NULL); ostringstream oss1; oss1 << "DROP DATABASE IF EXISTS " << db_name; diff --git a/src/sql/MySqlDB.cc b/src/sql/MySqlDB.cc index 7e6ad4b257..f390e1f461 100644 --- a/src/sql/MySqlDB.cc +++ b/src/sql/MySqlDB.cc @@ -24,6 +24,7 @@ MySqlDB::MySqlDB( const string& server, + const int& port, const string& user, const string& password, char * database) @@ -37,7 +38,7 @@ MySqlDB::MySqlDB( // Connect to the server if (!mysql_real_connect(db, server.c_str(), user.c_str(), - password.c_str(), database, 0, NULL, 0)) + password.c_str(), database, port, NULL, 0)) { throw runtime_error("Could not open database."); } From 7d4dbdf10ed194a1b51b7eac38b9bd6f0ad90854 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Fri, 12 Nov 2010 23:40:27 +0100 Subject: [PATCH 15/15] feature #377:Minor cosmetic changes --- include/MySqlDB.h | 5 ++--- src/nebula/Nebula.cc | 11 +++++------ src/sql/MySqlDB.cc | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/MySqlDB.h b/include/MySqlDB.h index f0d1e1d302..decec7b728 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -44,10 +44,10 @@ class MySqlDB : public SqlDB public: MySqlDB(const string& server, - const int& port, + int port, const string& user, const string& password, - char * database); + char * database); ~MySqlDB(); @@ -129,4 +129,3 @@ public: #endif #endif /*MYSQL_DB_H_*/ - diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 74a1a87974..6871a80ec0 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -42,11 +42,11 @@ void Nebula::start() int fd; sigset_t mask; int signal; - char hn[80]; + char hn[80]; if ( gethostname(hn,79) != 0 ) { - throw runtime_error("Error getting hostname"); + throw runtime_error("Error getting hostname"); } hostname = hn; @@ -81,9 +81,9 @@ void Nebula::start() try { - string log_fname; - int log_level_int; - Log::MessageType clevel = Log::ERROR; + string log_fname; + int log_level_int; + Log::MessageType clevel = Log::ERROR; log_fname = log_location + "oned.log"; @@ -563,4 +563,3 @@ void Nebula::start() NebulaLog::log("ONE", Log::INFO, "All modules finalized, exiting.\n"); } - diff --git a/src/sql/MySqlDB.cc b/src/sql/MySqlDB.cc index f390e1f461..d6697fe810 100644 --- a/src/sql/MySqlDB.cc +++ b/src/sql/MySqlDB.cc @@ -24,10 +24,10 @@ MySqlDB::MySqlDB( const string& server, - const int& port, + int port, const string& user, const string& password, - char * database) + char * database) { // Initialize the MySQL library