1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Bug #1036: Local hooks are now executed from $VAR_LOCATION/remotes/hooks. Remote hooks are still executed from the SCRIPTS_REMOTE_PATH.

This commit is contained in:
Ruben S. Montero 2011-12-19 23:35:46 +01:00
parent f41a20d4dd
commit 42cebe30c1
11 changed files with 56 additions and 25 deletions

View File

@ -37,7 +37,8 @@ class HostPool : public PoolSQL
public:
HostPool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location);
const string& hook_location,
const string& remotes_location);
~HostPool(){};

View File

@ -34,7 +34,8 @@ public:
VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location);
const string& hook_location,
const string& remotes_location);
~VirtualMachinePool(){};

View File

@ -88,9 +88,10 @@ public:
// Pools
// ------------------------------------------------------------------------
virtual VirtualMachinePool* create_vmpool(SqlDB* db, string hook_location);
virtual VirtualMachinePool* create_vmpool(SqlDB* db,
string hook_location, string vloc);
virtual HostPool* create_hpool(SqlDB* db, string hook_location);
virtual HostPool* create_hpool(SqlDB* db, string hook_location, string vloc);
virtual VirtualNetworkPool* create_vnpool(SqlDB* db,
string mac_prefix,

View File

@ -19,6 +19,7 @@
/* ************************************************************************** */
#include <stdexcept>
#include <sstream>
#include "HostPool.h"
#include "HostHook.h"
@ -30,7 +31,8 @@
HostPool::HostPool(SqlDB* db,
vector<const Attribute *> hook_mads,
const string& hook_location)
const string& hook_location,
const string& remotes_location)
: PoolSQL(db,Host::table)
{
// ------------------ Initialize Hooks fot the pool ----------------------
@ -88,8 +90,19 @@ HostPool::HostPool(SqlDB* db,
if (cmd[0] != '/')
{
cmd = hook_location + cmd;
}
ostringstream cmd_os;
if ( remote )
{
cmd_os << hook_location << "/" << cmd;
}
else
{
cmd_os << remotes_location << "/hooks/" << cmd;
}
cmd = cmd_os.str();
}
if ( on == "CREATE" )
{

View File

@ -155,7 +155,7 @@ protected:
{
vector<const Attribute *> hook;
return new HostPool(db,hook,"./");
return new HostPool(db,hook,"./", "./");
};
int allocate(int index)

View File

@ -42,7 +42,7 @@ public:
// Pools
// -----------------------------------------------------------
HostPool* create_hpool(SqlDB* db, string hook_location)
HostPool* create_hpool(SqlDB* db, string hook_location, string var_location)
{
map<string,string> hook_value;
VectorAttribute * hook;
@ -81,7 +81,7 @@ public:
host_hooks.push_back(hook);
return new HostPool(db, host_hooks, hook_location);
return new HostPool(db, host_hooks, hook_location, var_location);
}
};

View File

@ -280,15 +280,17 @@ void Nebula::start()
nebula_configuration->get("VM_HOOK", vm_hooks);
nebula_configuration->get("HOST_HOOK", host_hooks);
vmpool = new VirtualMachinePool(db, vm_hooks, hook_location);
hpool = new HostPool(db, host_hooks, hook_location);
vmpool = new VirtualMachinePool(db,
vm_hooks,
hook_location,
remotes_location);
hpool = new HostPool(db, host_hooks, hook_location, remotes_location);
nebula_configuration->get("MAC_PREFIX", mac_prefix);
nebula_configuration->get("NETWORK_SIZE", size);
vnpool = new VirtualNetworkPool(db,mac_prefix,size);
gpool = new GroupPool(db);
gpool = new GroupPool(db);
nebula_configuration->get("SESSION_EXPIRATION_TIME", expiration_time);
upool = new UserPool(db, expiration_time);
@ -301,7 +303,7 @@ void Nebula::start()
default_image_type,
default_device_prefix);
tpool = new VMTemplatePool(db);
tpool = new VMTemplatePool(db);
}
catch (exception&)
{

View File

@ -201,12 +201,12 @@ void Nebula::start()
if (tester->need_vm_pool)
{
vmpool = tester->create_vmpool(db,hook_location);
vmpool = tester->create_vmpool(db,hook_location,var_location);
}
if (tester->need_host_pool)
{
hpool = tester->create_hpool(db,hook_location);
hpool = tester->create_hpool(db,hook_location,var_location);
}
if (tester->need_vnet_pool)

View File

@ -18,16 +18,17 @@
NebulaTest* NebulaTest::the_tester;
VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location)
VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location,
string vloc)
{
vector<const Attribute *> hooks;
return new VirtualMachinePool(db, hooks, hook_location);
return new VirtualMachinePool(db, hooks, hook_location, vloc);
}
HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location)
HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location, string vloc)
{
vector<const Attribute *> hooks;
return new HostPool(db, hooks, hook_location);
return new HostPool(db, hooks, hook_location, vloc);
}
VirtualNetworkPool* NebulaTest::create_vnpool(SqlDB* db, string mac_prefix, int size)

View File

@ -26,7 +26,8 @@
VirtualMachinePool::VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location)
const string& hook_location,
const string& remotes_location)
: PoolSQL(db,VirtualMachine::table)
{
const VectorAttribute * vattr;
@ -82,8 +83,19 @@ VirtualMachinePool::VirtualMachinePool(SqlDB * db,
if (cmd[0] != '/')
{
cmd = hook_location + cmd;
}
ostringstream cmd_os;
if ( remote )
{
cmd_os << hook_location << "/" << cmd;
}
else
{
cmd_os << remotes_location << "/hooks/" << cmd;
}
cmd = cmd_os.str();
}
if ( on == "CREATE" )
{

View File

@ -85,7 +85,7 @@ class VirtualMachinePoolFriend : public VirtualMachinePool
{
public:
VirtualMachinePoolFriend(SqlDB * db, vector<const Attribute *> hook_mads):
VirtualMachinePool(db, hook_mads, "./")
VirtualMachinePool(db, hook_mads, "./", "./")
{};