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

Better scope for the hook driver name, removed unused variable

This commit is contained in:
Ruben S. Montero 2010-07-08 18:49:37 +02:00
parent b14eefeeec
commit 53c06533d3
2 changed files with 32 additions and 33 deletions

View File

@ -31,20 +31,15 @@ class HookManager : public MadManager, public ActionListener
public:
HookManager(vector<const Attribute*>& _mads, VirtualMachinePool * _vmpool)
:MadManager(_mads),vmpool(_vmpool)
:MadManager(_mads),vmpool(_vmpool)
{
am.addListener(this);
};
~HookManager(){};
/**
* Generic name for the Hook driver
*/
static const char * hook_driver_name;
/**
* This functions starts the associated listener thread, and creates a
* This functions starts the associated listener thread, and creates a
* new thread for the Hook Manager. This thread will wait in
* an action loop till it receives ACTION_FINALIZE.
* @return 0 on success.
@ -61,12 +56,12 @@ public:
};
/**
*
*
*/
void load_mads(int uid=0);
/**
*
*
*/
void finalize()
{
@ -74,39 +69,43 @@ public:
};
/**
* Returns a pointer to a Information Manager MAD. The driver is
* Returns a pointer to a Information Manager MAD. The driver is
* searched by its name and owned by oneadmin with uid=0.
* @param name of the driver
* @return the Hook driver owned by uid 0, with attribute "NAME" equal to
* @return the Hook driver owned by uid 0, with attribute "NAME" equal to
* name or 0 in not found
*/
const HookManagerDriver * get()
{
string name("NAME");
string hook_name(hook_driver_name);
return static_cast<const HookManagerDriver *>
(MadManager::get(0,name,hook_driver_name));
};
private:
/**
* Generic name for the Hook driver
*/
static const char * hook_driver_name;
/**
* Pointer to the VirtualMachine Pool
*/
VirtualMachinePool * vmpool;
/**
* Thread id for the HookManager
*/
pthread_t hm_thread;
/**
* Action engine for the Manager
*/
ActionManager am;
/**
* Function to execute the Manager action loop method within a new pthread
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * hm_action_loop(void *arg);

View File

@ -34,28 +34,28 @@ extern "C" void * hm_action_loop(void *arg)
NebulaLog::log("HKM",Log::INFO,"Hook Manager started.");
hm = static_cast<HookManager *>(arg);
hm->am.loop(0,0);
NebulaLog::log("HKM",Log::INFO,"Hook Manager stopped.");
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void HookManager::load_mads(int uid)
void HookManager::load_mads(int uid)
{
HookManagerDriver * hm_mad;
ostringstream oss;
const VectorAttribute * vattr;
int rc;
NebulaLog::log("HKM",Log::INFO,"Loading Hook Manager driver.");
vattr = static_cast<const VectorAttribute *>(mad_conf[0]);
if ( vattr == 0 )
{
NebulaLog::log("HKM",Log::INFO,"Failed to load Hook Manager driver.");
@ -63,18 +63,18 @@ void HookManager::load_mads(int uid)
}
VectorAttribute hook_conf("HOOK_MAD",vattr->value());
hook_conf.replace("NAME",hook_driver_name);
hm_mad = new HookManagerDriver(0,hook_conf.value(),false,vmpool);
rc = add(hm_mad);
if ( rc == 0 )
{
oss.str("");
oss.str("");
oss << "\tHook Manager loaded";
NebulaLog::log("HKM",Log::INFO,oss);
}
}
@ -95,7 +95,7 @@ int HookManager::start()
}
NebulaLog::log("HKM",Log::INFO,"Starting Hook Manager...");
pthread_attr_init (&pattr);
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
@ -112,14 +112,14 @@ void HookManager::do_action(const string &action, void * arg)
if (action == ACTION_FINALIZE)
{
NebulaLog::log("HKM",Log::INFO,"Stopping Hook Manager...");
MadManager::stop();
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("HKM", Log::ERROR, oss);
}
}