feature #1839: Add JAVA bindings for undeploy, rename UNDEPLOYING to SHUTDOWN_UNDEPLOY

This commit is contained in:
Ruben S. Montero committed 2013-04-03 00:28:06 +02:00
1 parent 728d043574
commit ae32c48183
6 files changed
+38 -23

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ public:
HOTPLUG_SAVEAS = 26,
HOTPLUG_SAVEAS_POWEROFF = 27,
HOTPLUG_SAVEAS_SUSPENDED = 28,
UNDEPLOYING = 29,
SHUTDOWN_UNDEPLOY = 29,
EPILOG_UNDEPLOY = 30,
PROLOG_UNDEPLOY = 31
};
+3 -3
View File
@@ -360,16 +360,16 @@ void LifeCycleManager::undeploy_action(int vid, bool hard)
VirtualMachineManager * vmm = nd.get_vmm();
//----------------------------------------------------
// UNDEPLOYING STATE
// SHUTDOWN_UNDEPLOY STATE
//----------------------------------------------------
vm->set_state(VirtualMachine::UNDEPLOYING);
vm->set_state(VirtualMachine::SHUTDOWN_UNDEPLOY);
vm->set_resched(false);
vmpool->update(vm);
vm->log("LCM",Log::INFO,"New VM state is UNDEPLOYING");
vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN_UNDEPLOY");
//----------------------------------------------------
+4 -4
View File
@@ -514,7 +514,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::UNDEPLOYING)
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
{
//----------------------------------------------------
// EPILOG_UNDEPLOY STATE
@@ -567,7 +567,7 @@ void LifeCycleManager::shutdown_failure_action(int vid)
if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::UNDEPLOYING )
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY )
{
//----------------------------------------------------
// RUNNING STATE FROM SHUTDOWN
@@ -959,7 +959,7 @@ void LifeCycleManager::cancel_success_action(int vid)
tm->trigger(TransferManager::EPILOG,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::UNDEPLOYING)
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
{
//----------------------------------------------------
// EPILOG_UNDEPLOY STATE
@@ -1011,7 +1011,7 @@ void LifeCycleManager::cancel_failure_action(int vid)
}
if ( vm->get_lcm_state() == VirtualMachine::CANCEL ||
vm->get_lcm_state() == VirtualMachine::UNDEPLOYING )
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY )
{
//----------------------------------------------------
// RUNNING STATE FROM CANCEL
@@ -58,7 +58,8 @@ public class VirtualMachine extends PoolElement{
"SUSPENDED",
"DONE",
"FAILED",
"POWEROFF" };
"POWEROFF",
"UNDEPLOYED" };
private static final String[] SHORT_VM_STATES =
{
@@ -70,7 +71,8 @@ public class VirtualMachine extends PoolElement{
"susp",
"done",
"fail",
"poff" };
"poff",
"unde" };
private static final String[] LCM_STATE =
{
@@ -102,7 +104,10 @@ public class VirtualMachine extends PoolElement{
"HOTPLUG_NIC",
"HOTPLUG_SAVEAS",
"HOTPLUG_SAVEAS_POWEROFF",
"HOTPLUG_SAVEAS_SUSPENDED" };
"HOTPLUG_SAVEAS_SUSPENDED",
"SHUTDOWN_UNDEPLOY",
"EPILOG_UNDEPLOY",
"PROLOG_UNDEPLOY" };
private static final String[] SHORT_LCM_STATES =
{
@@ -501,12 +506,13 @@ public class VirtualMachine extends PoolElement{
* <li>{@link VirtualMachine#poweroff()}</li>
* <li>{@link VirtualMachine#resched()}</li>
* <li>{@link VirtualMachine#unresched()}</li>
* <li>{@link VirtualMachine#undeploy(boolean)}</li>
* </ul>
*
* @param action The action name to be performed, can be:<br/>
* "shutdown", "hold", "release", "stop", "shutdown-hard", "suspend",
* "resume", "boot", "destroy", "destroy-recreate", "reboot", "resched",
* "unresched", "reboot-hard", "poweroff"
* "unresched", "reboot-hard", "poweroff", "undeploy", "undeploy-hard"
* @return If an error occurs the error message contains the reason.
*/
protected OneResponse action(String action)
@@ -832,6 +838,19 @@ public class VirtualMachine extends PoolElement{
return action(actionSt);
}
/**
* Undeploy a running VM, it preserve its resources and disk modifications.
* @param hard True to perform a hard (no acpi) shutdown, false for a
* graceful shutdown
* @return If an error occurs the error message contains the reason.
*/
public OneResponse undeploy(boolean hard)
{
String actionSt = hard ? "undeploy-hard" : "undeploy";
return action(actionSt);
}
/**
* Powers off a running VM.
* @return If an error occurs the error message contains the reason.
+3 -3
View File
@@ -54,7 +54,7 @@ module OpenNebula
SHUTDOWN CANCEL FAILURE CLEANUP_RESUBMIT UNKNOWN HOTPLUG SHUTDOWN_POWEROFF
BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED BOOT_STOPPED CLEANUP_DELETE
HOTPLUG_SNAPSHOT HOTPLUG_NIC HOTPLUG_SAVEAS HOTPLUG_SAVEAS_POWEROFF
HOTPLUG_SAVEAS_SUSPENDED UNDEPLOYING EPILOG_UNDEPLOY PROLOG_UNDEPLOY}
HOTPLUG_SAVEAS_SUSPENDED SHUTDOWN_UNDEPLOY EPILOG_UNDEPLOY PROLOG_UNDEPLOY}
SHORT_VM_STATES={
"INIT" => "init",
@@ -66,7 +66,7 @@ module OpenNebula
"DONE" => "done",
"FAILED" => "fail",
"POWEROFF" => "poff",
"UNDEPLOYING" => "unde"
"UNDEPLOYED"=> "unde"
}
SHORT_LCM_STATES={
@@ -98,7 +98,7 @@ module OpenNebula
"HOTPLUG_SAVEAS" => "hotp",
"HOTPLUG_SAVEAS_POWEROFF" => "hotp",
"HOTPLUG_SAVEAS_SUSPENDED" => "hotp",
"UNDEPLOYING" => "unde",
"SHUTDOWN_UNDEPLOY" => "shut",
"EPILOG_UNDEPLOY" => "epil",
"PROLOG_UNDEPLOY" => "prol"
}
+4 -8
View File
@@ -901,15 +901,11 @@ error_driver:
os.str("");
os << "cancel_action, error getting driver " << vm->get_vmm_mad();
error_common:
if ( vm->get_lcm_state() == VirtualMachine::CANCEL ||
vm->get_lcm_state() == VirtualMachine::UNDEPLOYING ) //not in DELETE
{
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
error_common://LifeCycleManager::cancel_failure_action will check state
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::CANCEL_FAILURE, vid);
}
lcm->trigger(LifeCycleManager::CANCEL_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();