From 04874dbf7a2b8247a497e59a9d9e10e34af0dfe0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 2 Aug 2010 11:24:01 +0200 Subject: [PATCH] bug #295: Hooks can be specified without absolute path. Adjusted share location for system-wide installations --- include/Nebula.h | 3 +++ include/PoolSQL.h | 2 +- include/VirtualMachinePool.h | 4 +++- install.sh | 2 +- src/nebula/Nebula.cc | 2 +- src/vm/VirtualMachinePool.cc | 8 +++++++- src/vm/test/VirtualMachinePoolTest.cc | 2 +- 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index e44038cef8..44e41f503f 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -236,6 +236,7 @@ private: etc_location = "/etc/one/"; log_location = "/var/log/one/"; var_location = "/var/lib/one/"; + hook_location= "/usr/share/one/hooks/"; } else { @@ -250,6 +251,7 @@ private: etc_location = nebula_location + "etc/"; log_location = nebula_location + "var/"; var_location = nebula_location + "var/"; + hook_location= nebula_location + "share/hooks/"; } }; @@ -345,6 +347,7 @@ private: string etc_location; string log_location; string var_location; + string hook_location; string hostname; // --------------------------------------------------------------- diff --git a/include/PoolSQL.h b/include/PoolSQL.h index 74ffb85fe5..a7f57685aa 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -46,7 +46,7 @@ public: * @param table the name of the table supporting the pool (to set the oid * counter). If null the OID counter is not updated. */ - PoolSQL(SqlDB * _db, const char * table=0); + PoolSQL(SqlDB * _db, const char * table); virtual ~PoolSQL(); diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h index fe8ca25bae..711008cfde 100644 --- a/include/VirtualMachinePool.h +++ b/include/VirtualMachinePool.h @@ -32,7 +32,9 @@ class VirtualMachinePool : public PoolSQL { public: - VirtualMachinePool(SqlDB * db, vector hook_mads); + VirtualMachinePool(SqlDB * db, + vector hook_mads, + const string& hook_location); ~VirtualMachinePool(){}; diff --git a/install.sh b/install.sh index 6618c3cad1..92d6416afc 100755 --- a/install.sh +++ b/install.sh @@ -99,7 +99,7 @@ if [ -z "$ROOT" ] ; then RUN_LOCATION="/var/run/one" LOCK_LOCATION="/var/lock/one" INCLUDE_LOCATION="/usr/include" - SHARE_LOCATION="/usr/share/doc/opennebula" + SHARE_LOCATION="/usr/share/one" if [ "$CLIENT" = "no" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \ diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index d6ab6b64d3..d03a9da6d8 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -224,7 +224,7 @@ void Nebula::start() nebula_configuration->get("VM_HOOK", vm_hooks); - vmpool = new VirtualMachinePool(db, vm_hooks); + vmpool = new VirtualMachinePool(db, vm_hooks,hook_location); hpool = new HostPool(db); nebula_configuration->get("MAC_PREFIX", mac_prefix); diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index bc1a744c24..6d542ce0f3 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -25,7 +25,8 @@ /* -------------------------------------------------------------------------- */ VirtualMachinePool::VirtualMachinePool(SqlDB * db, - vector hook_mads) + vector hook_mads, + const string& hook_location) : PoolSQL(db,VirtualMachine::table) { const VectorAttribute * vattr; @@ -79,6 +80,11 @@ VirtualMachinePool::VirtualMachinePool(SqlDB * db, } } + if (cmd[0] != '/') + { + cmd = hook_location + cmd; + } + if ( on == "CREATE" ) { VirtualMachineAllocateHook * hook; diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 04ce70247e..f116bc90dd 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -87,7 +87,7 @@ class VirtualMachinePoolFriend : public VirtualMachinePool { public: VirtualMachinePoolFriend(SqlDB * db, vector hook_mads): - VirtualMachinePool(db, hook_mads) + VirtualMachinePool(db, hook_mads, "./") {};