feature #1013: Abstraction of current Allocate and Remove hooks

This commit is contained in:
Ruben S. Montero committed 2012-10-07 23:20:28 +02:00
1 parent a6c1f37159
commit 43d552aea2
7 files changed
+137 -141

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ lib_name='nebula_hm'
# Sources to generate the library
source_files=[
'Hook.cc',
'HookManager.cc',
'HookManagerDriver.cc'
]
+1 -64
View File
@@ -18,69 +18,6 @@
#include "Host.h"
#include "Nebula.h"
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static void parse_host_arguments(Host *host, string& parsed)
{
size_t found;
found = parsed.find("$HID");
if ( found !=string::npos )
{
ostringstream oss;
oss << host->get_oid();
parsed.replace(found,4,oss.str());
}
found = parsed.find("$TEMPLATE");
if ( found != string::npos )
{
string templ;
parsed.replace(found,9,host->to_xml64(templ));
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void HostAllocateHook::do_hook(void *arg)
{
Host * host;
string parsed_args = args;
host = static_cast<Host *>(arg);
if ( host == 0 )
{
return;
}
parse_host_arguments(host,parsed_args);
Nebula& ne = Nebula::instance();
HookManager * hm = ne.get_hm();
const HookManagerDriver * hmd = hm->get();
if ( hmd != 0 )
{
if ( remote == true )
{
hmd->execute(host->get_oid(),
name,
host->get_name(),
cmd,
parsed_args);
}
else
{
hmd->execute(host->get_oid(),name,cmd,parsed_args);
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
@@ -172,7 +109,7 @@ void HostStateHook::do_hook(void *arg)
{
string parsed_args = args;
parse_host_arguments(host,parsed_args);
parse_hook_arguments(host, HID_HOOK_NAME, parsed_args);
Nebula& ne = Nebula::instance();
HookManager * hm = ne.get_hm();
+1 -1
View File
@@ -36,7 +36,6 @@ env.Prepend(LIBS=[
'nebula_vmm',
'nebula_lcm',
'nebula_im',
'nebula_hm',
'nebula_rm',
'nebula_dm',
'nebula_tm',
@@ -55,6 +54,7 @@ env.Prepend(LIBS=[
'nebula_vm',
'nebula_vmtemplate',
'nebula_document',
'nebula_hm',
'nebula_common',
'nebula_sql',
'nebula_log',
+1 -54
View File
@@ -21,59 +21,6 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static void parse_vm_arguments(VirtualMachine *vm, string& parsed)
{
size_t found;
found = parsed.find("$VMID");
if ( found !=string::npos )
{
ostringstream oss;
oss << vm->get_oid();
parsed.replace(found,5,oss.str());
}
found = parsed.find("$TEMPLATE");
if ( found != string::npos )
{
string templ;
parsed.replace(found,9,vm->to_xml64(templ));
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void VirtualMachineAllocateHook::do_hook(void *arg)
{
VirtualMachine * vm;
string parsed_args = args;
vm = static_cast<VirtualMachine *>(arg);
if ( vm == 0 )
{
return;
}
parse_vm_arguments(vm, parsed_args);
Nebula& ne = Nebula::instance();
HookManager * hm = ne.get_hm();
const HookManagerDriver * hmd = hm->get();
if ( hmd != 0 )
{
hmd->execute(vm->get_oid(),name,cmd,parsed_args);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
map<int,VirtualMachineStateMapHook::VmStates>
VirtualMachineStateMapHook::vm_states;
@@ -167,7 +114,7 @@ void VirtualMachineStateHook::do_hook(void *arg)
{
string parsed_args = args;
parse_vm_arguments(vm,parsed_args);
parse_hook_arguments(vm, VMID_HOOK_NAME, parsed_args);
Nebula& ne = Nebula::instance();
HookManager * hm = ne.get_hm();