mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-11 04:58:16 +03:00
Merge branch 'feature-1839' into one-4.0
This commit is contained in:
commit
d368098c52
include
src
cli
dm
lcm
oca
rm
scheduler/src/pool
tm
vmm
@ -46,6 +46,7 @@ public:
|
||||
{
|
||||
SUSPEND_SUCCESS,/**< Send by LCM when a VM is suspended*/
|
||||
STOP_SUCCESS, /**< Send by LCM when a VM is stopped*/
|
||||
UNDEPLOY_SUCCESS, /**< Send by LCM when a VM is undeployed and saved*/
|
||||
POWEROFF_SUCCESS, /**< Send by LCM when a VM is powered off */
|
||||
DONE, /**< Send by LCM when a VM is shut down*/
|
||||
FAILED, /**< Send by LCM when one of the execution steps fails*/
|
||||
@ -130,6 +131,17 @@ public:
|
||||
int shutdown (
|
||||
int vid);
|
||||
|
||||
/**
|
||||
* Shuts down a VM, but it is saved in the system DS instead of destroyed.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param hard True to force the shutdown (cancel instead of shutdown)
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int undeploy (
|
||||
int vid,
|
||||
bool hard);
|
||||
|
||||
/**
|
||||
* Powers off a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
@ -396,6 +408,8 @@ private:
|
||||
|
||||
void stop_success_action(int vid);
|
||||
|
||||
void undeploy_success_action(int vid);
|
||||
|
||||
void poweroff_success_action(int vid);
|
||||
|
||||
void done_action(int vid);
|
||||
|
@ -84,6 +84,8 @@ public:
|
||||
MIGRATE, /**< Sent by the DM to migrate a VM to other host */
|
||||
LIVE_MIGRATE, /**< Sent by the DM to live-migrate a VM */
|
||||
SHUTDOWN, /**< Sent by the DM to shutdown a running VM */
|
||||
UNDEPLOY, /**< Sent by the DM to undeploy a running VM */
|
||||
UNDEPLOY_HARD, /**< Sent by the DM to force undeploy a running VM */
|
||||
POWEROFF, /**< Sent by the DM to power off a running VM */
|
||||
RESTART, /**< Sent by the DM to restart a deployed VM */
|
||||
DELETE, /**< Sent by the DM to delete a VM */
|
||||
@ -247,6 +249,8 @@ private:
|
||||
|
||||
void shutdown_action(int vid);
|
||||
|
||||
void undeploy_action(int vid, bool hard);
|
||||
|
||||
void poweroff_action(int vid);
|
||||
|
||||
void failure_action(VirtualMachine * vm);
|
||||
|
@ -58,7 +58,8 @@ public:
|
||||
SUSPENDED = 5,
|
||||
DONE = 6,
|
||||
FAILED = 7,
|
||||
POWEROFF = 8
|
||||
POWEROFF = 8,
|
||||
UNDEPLOYED = 9
|
||||
};
|
||||
|
||||
/**
|
||||
@ -94,7 +95,10 @@ public:
|
||||
HOTPLUG_NIC = 25,
|
||||
HOTPLUG_SAVEAS = 26,
|
||||
HOTPLUG_SAVEAS_POWEROFF = 27,
|
||||
HOTPLUG_SAVEAS_SUSPENDED = 28
|
||||
HOTPLUG_SAVEAS_SUSPENDED = 28,
|
||||
SHUTDOWN_UNDEPLOY = 29,
|
||||
EPILOG_UNDEPLOY = 30,
|
||||
PROLOG_UNDEPLOY = 31
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -319,6 +319,29 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
undeploy_desc = <<-EOT.unindent
|
||||
Shuts down the given VM. The VM is saved in the system Datastore.
|
||||
|
||||
With --hard it unplugs the VM.
|
||||
|
||||
States: RUNNING
|
||||
EOT
|
||||
|
||||
command :undeploy, undeploy_desc, [:range,:vmid_list],
|
||||
:options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
|
||||
|
||||
command_name='undeploy'
|
||||
command_name<<'-hard' if options[:hard]
|
||||
|
||||
if (!options[:schedule].nil?)
|
||||
helper.schedule_actions(args[0], options, command_name)
|
||||
else
|
||||
helper.perform_actions(args[0],options,"shutting down") do |vm|
|
||||
vm.undeploy(options[:hard]==true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
poweroff_desc = <<-EOT.unindent
|
||||
Powers off the given VM. The VM will remain in the poweroff state, and
|
||||
can be powered on with the 'onevm boot' command.
|
||||
|
@ -77,6 +77,10 @@ void DispatchManager::trigger(Actions action, int _vid)
|
||||
aname = "STOP_SUCCESS";
|
||||
break;
|
||||
|
||||
case UNDEPLOY_SUCCESS:
|
||||
aname = "UNDEPLOY_SUCCESS";
|
||||
break;
|
||||
|
||||
case POWEROFF_SUCCESS:
|
||||
aname = "POWEROFF_SUCCESS";
|
||||
break;
|
||||
@ -130,6 +134,10 @@ void DispatchManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
stop_success_action(vid);
|
||||
}
|
||||
else if (action == "UNDEPLOY_SUCCESS")
|
||||
{
|
||||
undeploy_success_action(vid);
|
||||
}
|
||||
else if (action == "POWEROFF_SUCCESS")
|
||||
{
|
||||
poweroff_success_action(vid);
|
||||
|
@ -209,6 +209,59 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::undeploy(
|
||||
int vid,
|
||||
bool hard)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
ostringstream oss;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
oss << "Undeploying VM " << vid;
|
||||
NebulaLog::log("DiM",Log::DEBUG,oss);
|
||||
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
LifeCycleManager * lcm = nd.get_lcm();
|
||||
|
||||
if (hard)
|
||||
{
|
||||
lcm->trigger(LifeCycleManager::UNDEPLOY_HARD,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm->trigger(LifeCycleManager::UNDEPLOY,vid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
oss.str("");
|
||||
oss << "Could not undeploy VM " << vid << ", wrong state.";
|
||||
NebulaLog::log("DiM",Log::ERROR,oss);
|
||||
|
||||
vm->unlock();
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::poweroff (
|
||||
int vid)
|
||||
{
|
||||
@ -497,7 +550,8 @@ int DispatchManager::resume(
|
||||
oss << "Resuming VM " << vid;
|
||||
NebulaLog::log("DiM",Log::DEBUG,oss);
|
||||
|
||||
if (vm->get_state() == VirtualMachine::STOPPED )
|
||||
if (vm->get_state() == VirtualMachine::STOPPED ||
|
||||
vm->get_state() == VirtualMachine::UNDEPLOYED )
|
||||
{
|
||||
vm->set_state(VirtualMachine::PENDING);
|
||||
|
||||
@ -804,6 +858,7 @@ int DispatchManager::finalize(
|
||||
break;
|
||||
|
||||
case VirtualMachine::STOPPED:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
tm->trigger(TransferManager::EPILOG_DELETE_STOP,vid);
|
||||
finalize_cleanup(vm);
|
||||
break;
|
||||
@ -878,6 +933,7 @@ int DispatchManager::resubmit(int vid)
|
||||
|
||||
case VirtualMachine::HOLD: // Move the VM to PENDING in any of these
|
||||
case VirtualMachine::STOPPED:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
vm->set_state(VirtualMachine::PENDING);
|
||||
|
||||
|
@ -98,6 +98,46 @@ void DispatchManager::stop_success_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void DispatchManager::undeploy_success_action(int vid)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((vm->get_state() == VirtualMachine::ACTIVE) &&
|
||||
(vm->get_lcm_state() == VirtualMachine::EPILOG_UNDEPLOY ||
|
||||
vm->get_lcm_state() == VirtualMachine::PROLOG_UNDEPLOY))
|
||||
{
|
||||
vm->set_state(VirtualMachine::UNDEPLOYED);
|
||||
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->log("DiM", Log::INFO, "New VM state is UNDEPLOYED");
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "undeploy_success action received but VM " << vid
|
||||
<< " not in ACTIVE state";
|
||||
NebulaLog::log("DiM",Log::ERROR,oss);
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void DispatchManager::poweroff_success_action(int vid)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
@ -53,6 +53,11 @@ void LifeCycleManager::deploy_action(int vid)
|
||||
vm_state = VirtualMachine::PROLOG_RESUME;
|
||||
tm_action = TransferManager::PROLOG_RESUME;
|
||||
}
|
||||
else if (vm->get_previous_reason() == History::NONE)
|
||||
{
|
||||
vm_state = VirtualMachine::PROLOG_UNDEPLOY;
|
||||
tm_action = TransferManager::PROLOG_RESUME;
|
||||
}
|
||||
}
|
||||
|
||||
vm->set_state(vm_state);
|
||||
@ -334,6 +339,60 @@ void LifeCycleManager::shutdown_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::undeploy_action(int vid, bool hard)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
VirtualMachineManager * vmm = nd.get_vmm();
|
||||
|
||||
//----------------------------------------------------
|
||||
// SHUTDOWN_UNDEPLOY STATE
|
||||
//----------------------------------------------------
|
||||
|
||||
vm->set_state(VirtualMachine::SHUTDOWN_UNDEPLOY);
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN_UNDEPLOY");
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
if (hard)
|
||||
{
|
||||
vmm->trigger(VirtualMachineManager::CANCEL,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM", Log::ERROR, "undeploy_action, VM in a wrong state.");
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -750,6 +809,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
|
||||
{
|
||||
case VirtualMachine::PROLOG:
|
||||
case VirtualMachine::PROLOG_RESUME:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY:
|
||||
vm->set_prolog_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
@ -859,6 +919,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
|
||||
break;
|
||||
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::EPILOG_UNDEPLOY:
|
||||
case VirtualMachine::EPILOG:
|
||||
vm->set_epilog_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
@ -232,6 +232,14 @@ void LifeCycleManager::trigger(Actions action, int _vid)
|
||||
aname = "SHUTDOWN";
|
||||
break;
|
||||
|
||||
case UNDEPLOY:
|
||||
aname = "UNDEPLOY";
|
||||
break;
|
||||
|
||||
case UNDEPLOY_HARD:
|
||||
aname = "UNDEPLOY_HARD";
|
||||
break;
|
||||
|
||||
case RESTART:
|
||||
aname = "RESTART";
|
||||
break;
|
||||
@ -441,6 +449,14 @@ void LifeCycleManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
shutdown_action(vid);
|
||||
}
|
||||
else if (action == "UNDEPLOY")
|
||||
{
|
||||
undeploy_action(vid, false);
|
||||
}
|
||||
else if (action == "UNDEPLOY_HARD")
|
||||
{
|
||||
undeploy_action(vid, true);
|
||||
}
|
||||
else if (action == "RESTART")
|
||||
{
|
||||
restart_action(vid);
|
||||
|
@ -514,6 +514,32 @@ void LifeCycleManager::shutdown_success_action(int vid)
|
||||
|
||||
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// EPILOG_UNDEPLOY STATE
|
||||
//----------------------------------------------------
|
||||
|
||||
vm->set_state(VirtualMachine::EPILOG_UNDEPLOY);
|
||||
|
||||
vm->delete_snapshots();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_epilog_stime(the_time);
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
|
||||
vm->set_reason(History::NONE);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is EPILOG_UNDEPLOY");
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
tm->trigger(TransferManager::EPILOG_STOP,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"shutdown_success_action, VM in a wrong state");
|
||||
@ -540,7 +566,8 @@ 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::SHUTDOWN_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY )
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// RUNNING STATE FROM SHUTDOWN
|
||||
@ -588,7 +615,8 @@ void LifeCycleManager::prolog_success_action(int vid)
|
||||
|
||||
lcm_state = vm->get_lcm_state();
|
||||
|
||||
if (lcm_state == VirtualMachine::PROLOG)
|
||||
if (lcm_state == VirtualMachine::PROLOG ||
|
||||
lcm_state == VirtualMachine::PROLOG_UNDEPLOY )
|
||||
{
|
||||
action = VirtualMachineManager::DEPLOY;
|
||||
}
|
||||
@ -696,6 +724,39 @@ void LifeCycleManager::prolog_failure_action(int vid)
|
||||
|
||||
dm->trigger(DispatchManager::STOP_SUCCESS,vid);
|
||||
}
|
||||
else if ( state == VirtualMachine::PROLOG_UNDEPLOY )
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// UNDEPLOY STATE FROM PROLOG_UNDEPLOY
|
||||
//----------------------------------------------------
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
DispatchManager * dm = nd.get_dm();
|
||||
|
||||
int cpu,mem,disk;
|
||||
|
||||
vm->set_prolog_etime(the_time);
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_etime(the_time);
|
||||
|
||||
vm->set_vm_info();
|
||||
|
||||
vm->set_reason(History::NONE);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->get_requirements(cpu,mem,disk);
|
||||
|
||||
hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk);
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
dm->trigger(DispatchManager::UNDEPLOY_SUCCESS,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"prolog_failure_action, VM in a wrong state");
|
||||
@ -734,6 +795,10 @@ void LifeCycleManager::epilog_success_action(int vid)
|
||||
{
|
||||
action = DispatchManager::STOP_SUCCESS;
|
||||
}
|
||||
else if ( state == VirtualMachine::EPILOG_UNDEPLOY )
|
||||
{
|
||||
action = DispatchManager::UNDEPLOY_SUCCESS;
|
||||
}
|
||||
else if ( state == VirtualMachine::EPILOG )
|
||||
{
|
||||
action = DispatchManager::DONE;
|
||||
@ -834,6 +899,7 @@ void LifeCycleManager::epilog_failure_action(int vid)
|
||||
dm->trigger(DispatchManager::RESUBMIT, vid);
|
||||
}
|
||||
else if ( vm->get_lcm_state() == VirtualMachine::EPILOG_STOP ||
|
||||
vm->get_lcm_state() == VirtualMachine::EPILOG_UNDEPLOY ||
|
||||
vm->get_lcm_state() == VirtualMachine::EPILOG )
|
||||
{
|
||||
vm->set_epilog_etime(the_time);
|
||||
@ -893,6 +959,32 @@ void LifeCycleManager::cancel_success_action(int vid)
|
||||
|
||||
tm->trigger(TransferManager::EPILOG,vid);
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// EPILOG_UNDEPLOY STATE
|
||||
//----------------------------------------------------
|
||||
|
||||
vm->set_state(VirtualMachine::EPILOG_UNDEPLOY);
|
||||
|
||||
vm->delete_snapshots();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_epilog_stime(the_time);
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
|
||||
vm->set_reason(History::NONE);
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->log("LCM", Log::INFO, "New VM state is EPILOG_UNDEPLOY");
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
tm->trigger(TransferManager::EPILOG_STOP,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"cancel_success_action, VM in a wrong state");
|
||||
@ -918,7 +1010,8 @@ void LifeCycleManager::cancel_failure_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::CANCEL )
|
||||
if ( vm->get_lcm_state() == VirtualMachine::CANCEL ||
|
||||
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.
|
||||
|
@ -47,14 +47,14 @@ module OpenNebula
|
||||
}
|
||||
|
||||
VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED
|
||||
POWEROFF}
|
||||
POWEROFF UNDEPLOYED}
|
||||
|
||||
LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND
|
||||
SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG
|
||||
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}
|
||||
HOTPLUG_SAVEAS_SUSPENDED SHUTDOWN_UNDEPLOY EPILOG_UNDEPLOY PROLOG_UNDEPLOY}
|
||||
|
||||
SHORT_VM_STATES={
|
||||
"INIT" => "init",
|
||||
@ -65,7 +65,8 @@ module OpenNebula
|
||||
"SUSPENDED" => "susp",
|
||||
"DONE" => "done",
|
||||
"FAILED" => "fail",
|
||||
"POWEROFF" => "poff"
|
||||
"POWEROFF" => "poff",
|
||||
"UNDEPLOYED"=> "unde"
|
||||
}
|
||||
|
||||
SHORT_LCM_STATES={
|
||||
@ -96,7 +97,10 @@ module OpenNebula
|
||||
"HOTPLUG_NIC" => "hotp",
|
||||
"HOTPLUG_SAVEAS" => "hotp",
|
||||
"HOTPLUG_SAVEAS_POWEROFF" => "hotp",
|
||||
"HOTPLUG_SAVEAS_SUSPENDED" => "hotp"
|
||||
"HOTPLUG_SAVEAS_SUSPENDED" => "hotp",
|
||||
"SHUTDOWN_UNDEPLOY" => "shut",
|
||||
"EPILOG_UNDEPLOY" => "epil",
|
||||
"PROLOG_UNDEPLOY" => "prol"
|
||||
}
|
||||
|
||||
MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL}
|
||||
@ -210,6 +214,11 @@ module OpenNebula
|
||||
action(hard ? 'shutdown-hard' : 'shutdown')
|
||||
end
|
||||
|
||||
# Shuts down an already deployed VM, saving its state in the system DS
|
||||
def undeploy(hard=false)
|
||||
action(hard ? 'undeploy-hard' : 'undeploy')
|
||||
end
|
||||
|
||||
# Powers off a running VM
|
||||
def poweroff
|
||||
action('poweroff')
|
||||
|
@ -381,6 +381,14 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
{
|
||||
rc = dm->poweroff(id);
|
||||
}
|
||||
else if (action == "undeploy")
|
||||
{
|
||||
rc = dm->undeploy(id, false);
|
||||
}
|
||||
else if (action == "undeploy-hard")
|
||||
{
|
||||
rc = dm->undeploy(id, true);
|
||||
}
|
||||
|
||||
switch (rc)
|
||||
{
|
||||
@ -1246,6 +1254,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
case VirtualMachine::PENDING:
|
||||
case VirtualMachine::HOLD:
|
||||
case VirtualMachine::FAILED:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
break;
|
||||
|
||||
case VirtualMachine::STOPPED:
|
||||
@ -1423,6 +1432,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
case VirtualMachine::HOLD:
|
||||
case VirtualMachine::FAILED:
|
||||
case VirtualMachine::POWEROFF:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
ret = vm->resize(ncpu, nmemory, nvcpu, error_str);
|
||||
|
||||
if (ret != 0)
|
||||
|
@ -295,10 +295,12 @@ int VirtualMachineXML::parse_action_name(string& action_st)
|
||||
one_util::tolower(action_st);
|
||||
|
||||
if ( action_st != "shutdown"
|
||||
&& action_st != "shutdown-hard"
|
||||
&& action_st != "undeploy"
|
||||
&& action_st != "undeploy-hard"
|
||||
&& action_st != "hold"
|
||||
&& action_st != "release"
|
||||
&& action_st != "stop"
|
||||
&& action_st != "shutdown-hard"
|
||||
&& action_st != "suspend"
|
||||
&& action_st != "resume"
|
||||
&& action_st != "boot"
|
||||
|
@ -122,11 +122,13 @@ void TransferManagerDriver::protocol(
|
||||
case VirtualMachine::PROLOG:
|
||||
case VirtualMachine::PROLOG_MIGRATE:
|
||||
case VirtualMachine::PROLOG_RESUME:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY:
|
||||
lcm_action = LifeCycleManager::PROLOG_SUCCESS;
|
||||
break;
|
||||
|
||||
case VirtualMachine::EPILOG:
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::EPILOG_UNDEPLOY:
|
||||
case VirtualMachine::CLEANUP_RESUBMIT:
|
||||
lcm_action = LifeCycleManager::EPILOG_SUCCESS;
|
||||
break;
|
||||
@ -165,11 +167,13 @@ void TransferManagerDriver::protocol(
|
||||
case VirtualMachine::PROLOG:
|
||||
case VirtualMachine::PROLOG_MIGRATE:
|
||||
case VirtualMachine::PROLOG_RESUME:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY:
|
||||
lcm_action = LifeCycleManager::PROLOG_FAILURE;
|
||||
break;
|
||||
|
||||
case VirtualMachine::EPILOG:
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::EPILOG_UNDEPLOY:
|
||||
case VirtualMachine::CLEANUP_RESUBMIT:
|
||||
lcm_action = LifeCycleManager::EPILOG_FAILURE;
|
||||
break;
|
||||
|
@ -901,14 +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 ) //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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user