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

Feature #2092: Put hybrid checks in do_action for better coding understanding

This commit is contained in:
Tino Vazquez 2013-10-09 15:41:16 +02:00
parent ab85640c56
commit c783b963f4

View File

@ -148,7 +148,11 @@ void TransferManager::trigger(Actions action, int _vid)
void TransferManager::do_action(const string &action, void * arg)
{
int vid;
int vid;
VirtualMachine * vm;
Host * host;
bool host_is_hybrid;
Nebula& nd = Nebula::instance();
if (arg == 0)
{
@ -159,41 +163,118 @@ void TransferManager::do_action(const string &action, void * arg)
delete static_cast<int *>(arg);
vm = vmpool->get(vid,true);
if (vm == 0)
{
return;
}
host = hpool->get(vm->get_hid(),true);
host_is_hybrid=host->isHybrid();
vm->unlock();
host->unlock();
if (action == "PROLOG")
{
prolog_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else
{
prolog_action(vid);
}
}
else if (action == "PROLOG_MIGR")
{
prolog_migr_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else
{
prolog_migr_action(vid);
}
}
else if (action == "PROLOG_RESUME")
{
prolog_resume_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else
{
prolog_resume_action(vid);
}
}
else if (action == "EPILOG")
{
epilog_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_action(vid);
}
}
else if (action == "EPILOG_STOP")
{
epilog_stop_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_stop_action(vid);
}
}
else if (action == "EPILOG_DELETE")
{
epilog_delete_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_delete_action(vid);
}
}
else if (action == "EPILOG_DELETE_STOP")
{
epilog_delete_stop_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_delete_stop_action(vid);
}
}
else if (action == "EPILOG_DELETE_PREVIOUS")
{
epilog_delete_previous_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_delete_previous_action(vid);
}
}
else if (action == "EPILOG_DELETE_BOTH")
{
epilog_delete_both_action(vid);
if (host_is_hybrid)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else
{
epilog_delete_both_action(vid);
}
}
else if (action == "CHECKPOINT")
{
@ -436,8 +517,6 @@ void TransferManager::prolog_action(int vid)
string error_str;
VirtualMachine * vm;
Host * host;
bool host_is_hybrid;
Nebula& nd = Nebula::instance();
const TransferManagerDriver * tm_md;
@ -464,17 +543,6 @@ void TransferManager::prolog_action(int vid)
int uid = vm->get_uid();
vm->unlock();
host = hpool->get(vm->get_hid(),true);
host_is_hybrid=host->isHybrid();
host->unlock();
if (host_is_hybrid)
{
vm->unlock();
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
return;
}
User * user = Nebula::instance().get_upool()->get(uid, true);
if (user != 0)
@ -1053,9 +1121,6 @@ void TransferManager::epilog_action(int vid)
VirtualMachine * vm;
Nebula& nd = Nebula::instance();
Host * host;
bool host_is_hybrid;
const TransferManagerDriver * tm_md;
vector<const Attribute *> attrs;
@ -1076,17 +1141,6 @@ void TransferManager::epilog_action(int vid)
goto error_history;
}
host = hpool->get(vm->get_hid(),true);
host_is_hybrid=host->isHybrid();
host->unlock();
if (host_is_hybrid)
{
vm->unlock();
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
return;
}
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
tm_md = get();