mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-02 09:47:00 +03:00
Feature #1631: Add a new ACTION filed to each History
This commit is contained in:
parent
d368098c52
commit
a942853917
@ -37,6 +37,189 @@ public:
|
||||
CANCEL /** < The VM was migrated because of an explicit cancel */
|
||||
};
|
||||
|
||||
|
||||
enum VMAction
|
||||
{
|
||||
MIGRATE_ACTION,
|
||||
LIVE_MIGRATE_ACTION,
|
||||
SHUTDOWN_ACTION,
|
||||
SHUTDOWN_HARD_ACTION,
|
||||
UNDEPLOY_ACTION,
|
||||
UNDEPLOY_HARD_ACTION,
|
||||
HOLD_ACTION,
|
||||
RELEASE_ACTION,
|
||||
STOP_ACTION,
|
||||
SUSPEND_ACTION,
|
||||
RESUME_ACTION,
|
||||
BOOT_ACTION,
|
||||
DESTROY_ACTION,
|
||||
DESTROY_RECREATE_ACTION,
|
||||
REBOOT_ACTION,
|
||||
REBOOT_HARD_ACTION,
|
||||
RESCHED_ACTION,
|
||||
UNRESCHED_ACTION,
|
||||
POWEROFF_ACTION,
|
||||
NONE_ACTION
|
||||
};
|
||||
|
||||
string action_to_str(VMAction action)
|
||||
{
|
||||
string st;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MIGRATE_ACTION:
|
||||
st = "migrate";
|
||||
break;
|
||||
case LIVE_MIGRATE_ACTION:
|
||||
st = "migrate-live";
|
||||
break;
|
||||
case SHUTDOWN_ACTION:
|
||||
st = "shutdown";
|
||||
break;
|
||||
case SHUTDOWN_HARD_ACTION:
|
||||
st = "shutdown-hard";
|
||||
break;
|
||||
case UNDEPLOY_ACTION:
|
||||
st = "undeploy";
|
||||
break;
|
||||
case UNDEPLOY_HARD_ACTION:
|
||||
st = "undeploy-hard";
|
||||
break;
|
||||
case HOLD_ACTION:
|
||||
st = "hold";
|
||||
break;
|
||||
case RELEASE_ACTION:
|
||||
st = "release";
|
||||
break;
|
||||
case STOP_ACTION:
|
||||
st = "stop";
|
||||
break;
|
||||
case SUSPEND_ACTION:
|
||||
st = "suspend";
|
||||
break;
|
||||
case RESUME_ACTION:
|
||||
st = "resume";
|
||||
break;
|
||||
case BOOT_ACTION:
|
||||
st = "boot";
|
||||
break;
|
||||
case DESTROY_ACTION:
|
||||
st = "destroy";
|
||||
break;
|
||||
case DESTROY_RECREATE_ACTION:
|
||||
st = "destroy-recreate";
|
||||
break;
|
||||
case REBOOT_ACTION:
|
||||
st = "reboot";
|
||||
break;
|
||||
case REBOOT_HARD_ACTION:
|
||||
st = "reboot-hard";
|
||||
break;
|
||||
case RESCHED_ACTION:
|
||||
st = "resched";
|
||||
break;
|
||||
case UNRESCHED_ACTION:
|
||||
st = "unresched";
|
||||
break;
|
||||
case POWEROFF_ACTION:
|
||||
st = "poweroff";
|
||||
break;
|
||||
case NONE_ACTION:
|
||||
st = "none";
|
||||
break;
|
||||
}
|
||||
|
||||
return st;
|
||||
};
|
||||
|
||||
int action_from_str(string& st, VMAction& action)
|
||||
{
|
||||
if (st == "migrate")
|
||||
{
|
||||
action = MIGRATE_ACTION;
|
||||
}
|
||||
else if (st == "migrate-live")
|
||||
{
|
||||
action = LIVE_MIGRATE_ACTION;
|
||||
}
|
||||
else if (st == "shutdown")
|
||||
{
|
||||
action = SHUTDOWN_ACTION;
|
||||
}
|
||||
else if (st == "shutdown-hard")
|
||||
{
|
||||
action = SHUTDOWN_HARD_ACTION;
|
||||
}
|
||||
else if (st == "undeploy")
|
||||
{
|
||||
action = UNDEPLOY_ACTION;
|
||||
}
|
||||
else if (st == "undeploy-hard")
|
||||
{
|
||||
action = UNDEPLOY_HARD_ACTION;
|
||||
}
|
||||
else if (st == "hold")
|
||||
{
|
||||
action = HOLD_ACTION;
|
||||
}
|
||||
else if (st == "release")
|
||||
{
|
||||
action = RELEASE_ACTION;
|
||||
}
|
||||
else if (st == "stop")
|
||||
{
|
||||
action = STOP_ACTION;
|
||||
}
|
||||
else if (st == "suspend")
|
||||
{
|
||||
action = SUSPEND_ACTION;
|
||||
}
|
||||
else if (st == "resume")
|
||||
{
|
||||
action = RESUME_ACTION;
|
||||
}
|
||||
else if (st == "boot")
|
||||
{
|
||||
action = BOOT_ACTION;
|
||||
}
|
||||
else if (st == "destroy")
|
||||
{
|
||||
action = DESTROY_ACTION;
|
||||
}
|
||||
else if (st == "destroy-recreate")
|
||||
{
|
||||
action = DESTROY_RECREATE_ACTION;
|
||||
}
|
||||
else if (st == "reboot")
|
||||
{
|
||||
action = REBOOT_ACTION;
|
||||
}
|
||||
else if (st == "reboot-hard")
|
||||
{
|
||||
action = REBOOT_HARD_ACTION;
|
||||
}
|
||||
else if (st == "resched")
|
||||
{
|
||||
action = RESCHED_ACTION;
|
||||
}
|
||||
else if (st == "unresched")
|
||||
{
|
||||
action = UNRESCHED_ACTION;
|
||||
}
|
||||
else if (st == "poweroff")
|
||||
{
|
||||
action = POWEROFF_ACTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = NONE_ACTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
History(int oid, int _seq = -1);
|
||||
|
||||
History(
|
||||
@ -111,6 +294,8 @@ private:
|
||||
|
||||
MigrationReason reason;
|
||||
|
||||
VMAction action;
|
||||
|
||||
string vm_info;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -497,14 +497,23 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reason that originated the VM migration in the previous host
|
||||
* @return the migration reason to leave this host
|
||||
* Returns the reason that closed the history record in the previous host
|
||||
* @return the reason to close the history record in the previous host
|
||||
*/
|
||||
const History::MigrationReason get_previous_reason() const
|
||||
{
|
||||
return previous_history->reason;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the action that closed the history record in the previous host
|
||||
* @return the action that closed the history record in the previous host
|
||||
*/
|
||||
const History::VMAction get_previous_history_action() const
|
||||
{
|
||||
return previous_history->action;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get host id where the VM is or is going to execute. The hasHistory()
|
||||
* function MUST be called before this one.
|
||||
@ -630,8 +639,8 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the reason that originated the VM migration
|
||||
* @param _reason migration reason to leave this host
|
||||
* Sets the reason that closed the history record
|
||||
* @param _reason reason to close the history record
|
||||
*/
|
||||
void set_reason(History::MigrationReason _reason)
|
||||
{
|
||||
@ -639,14 +648,33 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the reason that originated the VM migration in the previous host
|
||||
* @param _reason migration reason to leave this host
|
||||
* Sets the reason that closed the history record in the previous host
|
||||
* @param _reason reason to close the history record in the previous host
|
||||
*/
|
||||
void set_previous_reason(History::MigrationReason _reason)
|
||||
{
|
||||
previous_history->reason=_reason;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the action that closed the history record
|
||||
* @param action that closed the history record
|
||||
*/
|
||||
void set_history_action(History::VMAction action)
|
||||
{
|
||||
history->action = action;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the action that closed the history record in the previous host
|
||||
* @param action that closed the history record in the previous host
|
||||
*/
|
||||
/*
|
||||
void set_previous_history_action(History::VMAction action)
|
||||
{
|
||||
previous_history->action = action;
|
||||
};
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
// Template
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -120,6 +120,10 @@ void LifeCycleManager::suspend_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::SUSPEND_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is SAVE_SUSPEND");
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -166,6 +170,10 @@ void LifeCycleManager::stop_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::STOP_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is SAVE_STOP");
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -215,6 +223,8 @@ void LifeCycleManager::migrate_action(int vid)
|
||||
|
||||
vm->set_stime(time(0));
|
||||
|
||||
vm->set_history_action(History::MIGRATE_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->get_requirements(cpu,mem,disk);
|
||||
@ -271,6 +281,8 @@ void LifeCycleManager::live_migrate_action(int vid)
|
||||
|
||||
vm->set_stime(time(0));
|
||||
|
||||
vm->set_history_action(History::LIVE_MIGRATE_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->get_requirements(cpu,mem,disk);
|
||||
@ -323,6 +335,10 @@ void LifeCycleManager::shutdown_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::SHUTDOWN_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN");
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -375,12 +391,18 @@ void LifeCycleManager::undeploy_action(int vid, bool hard)
|
||||
|
||||
if (hard)
|
||||
{
|
||||
vm->set_history_action(History::UNDEPLOY_HARD_ACTION);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::CANCEL,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->set_history_action(History::UNDEPLOY_ACTION);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
|
||||
}
|
||||
|
||||
vmpool->update_history(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -423,6 +445,10 @@ void LifeCycleManager::poweroff_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::POWEROFF_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN_POWEROFF");
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -525,6 +551,10 @@ void LifeCycleManager::cancel_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::SHUTDOWN_HARD_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New state is CANCEL");
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -786,10 +816,12 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
|
||||
if (dispose)
|
||||
{
|
||||
vm->set_state(VirtualMachine::CLEANUP_DELETE);
|
||||
vm->set_history_action(History::DESTROY_ACTION);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->set_state(VirtualMachine::CLEANUP_RESUBMIT);
|
||||
vm->set_history_action(History::DESTROY_RECREATE_ACTION);
|
||||
}
|
||||
|
||||
vm->set_resched(false);
|
||||
|
@ -222,6 +222,10 @@ void LifeCycleManager::save_failure_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::NONE_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "Fail to save VM state."
|
||||
" Assuming that the VM is still RUNNING (will poll VM).");
|
||||
|
||||
@ -577,6 +581,10 @@ void LifeCycleManager::shutdown_failure_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::NONE_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "Fail to shutdown VM."
|
||||
" Assuming that the VM is still RUNNING (will poll VM).");
|
||||
|
||||
@ -1021,6 +1029,10 @@ void LifeCycleManager::cancel_failure_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_history_action(History::NONE_ACTION);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "Fail to cancel VM."
|
||||
" Assuming that the VM is still RUNNING (will poll VM).");
|
||||
|
||||
|
@ -56,6 +56,7 @@ History::History(
|
||||
epilog_stime(0),
|
||||
epilog_etime(0),
|
||||
reason(NONE),
|
||||
action(NONE_ACTION),
|
||||
vm_info("<VM/>"){};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -89,6 +90,7 @@ History::History(
|
||||
epilog_stime(0),
|
||||
epilog_etime(0),
|
||||
reason(NONE),
|
||||
action(NONE_ACTION),
|
||||
vm_info(_vm_info)
|
||||
{
|
||||
non_persistent_data();
|
||||
@ -307,7 +309,8 @@ string& History::to_xml(string& xml, bool database) const
|
||||
"<RETIME>" << running_etime << "</RETIME>"<<
|
||||
"<ESTIME>" << epilog_stime << "</ESTIME>"<<
|
||||
"<EETIME>" << epilog_etime << "</EETIME>"<<
|
||||
"<REASON>" << reason << "</REASON>";
|
||||
"<REASON>" << reason << "</REASON>"<<
|
||||
"<ACTION>" << action << "</ACTION>";
|
||||
|
||||
if ( database )
|
||||
{
|
||||
@ -327,7 +330,7 @@ string& History::to_xml(string& xml, bool database) const
|
||||
|
||||
int History::rebuild_attributes()
|
||||
{
|
||||
int int_reason;
|
||||
int int_reason, int_action;
|
||||
int rc = 0;
|
||||
|
||||
rc += xpath(seq , "/HISTORY/SEQ", -1);
|
||||
@ -347,8 +350,10 @@ int History::rebuild_attributes()
|
||||
rc += xpath(epilog_stime , "/HISTORY/ESTIME", 0);
|
||||
rc += xpath(epilog_etime , "/HISTORY/EETIME", 0);
|
||||
rc += xpath(int_reason , "/HISTORY/REASON", 0);
|
||||
rc += xpath(int_action , "/HISTORY/ACTION", 0);
|
||||
|
||||
reason = static_cast<MigrationReason>(int_reason);
|
||||
action = static_cast<VMAction>(int_action);
|
||||
|
||||
non_persistent_data();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user