From e53d97a5ad5e4b64f8d271590405589e5a149117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 4 Apr 2013 16:07:10 +0200 Subject: [PATCH] Feature #1797: The action to wake up a poweroff VM is now 'resume' --- share/doc/states/states-complete.dot | 6 +++--- share/doc/states/states-simple.dot | 2 +- src/cli/onevm | 6 +++--- src/dm/DispatchManagerActions.cc | 16 +++++++++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index e34c972deb..ed5dafa4a5 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -91,6 +91,9 @@ digraph OpenNebula { suspended -> boot_suspended [label="resume"]; boot_suspended -> running [style="dashed"]; + poweroff -> boot_poweroff [label="resume"]; + boot_poweroff -> running [style="dashed"]; + # destroy ANY -> done [label="destroy"]; @@ -101,10 +104,7 @@ digraph OpenNebula { boot -> boot [label="boot"]; boot_suspended -> boot_suspended [label="boot"]; boot_stopped -> boot_stopped [label="boot"]; - - poweroff -> boot_poweroff [label="boot"]; boot_poweroff -> boot_poweroff [label="boot"]; - boot_poweroff -> running [style="dashed"]; unknown -> boot_unknown [label="boot"]; boot_unknown -> boot_unknown [label="boot"]; diff --git a/share/doc/states/states-simple.dot b/share/doc/states/states-simple.dot index f3ac7e7e69..65a567e25e 100644 --- a/share/doc/states/states-simple.dot +++ b/share/doc/states/states-simple.dot @@ -69,6 +69,7 @@ digraph OpenNebula { # resume stopped -> pending [label="resume"]; suspended -> boot [label="resume"]; + poweroff -> boot [label="resume"]; # delete ANY -> done [label="destroy"]; @@ -76,7 +77,6 @@ digraph OpenNebula { # restart unknown -> boot [label="boot"]; boot -> boot [label="boot"]; - poweroff -> boot [label="boot"]; # reboot running -> running [label="reboot"]; diff --git a/src/cli/onevm b/src/cli/onevm index eb3f0ad6d4..02de1522fb 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -344,7 +344,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do 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. + can be powered on with the 'onevm resume' command. States: RUNNING EOT @@ -432,7 +432,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do boot_desc = <<-EOT.unindent Boots the given VM. - States: UNKNOWN, BOOT, POWEROFF + States: UNKNOWN, BOOT EOT command :boot, boot_desc, [:range,:vmid_list], @@ -487,7 +487,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do resume_desc = <<-EOT.unindent Resumes the execution of the a saved VM - States: STOPPED, SUSPENDED + States: STOPPED, SUSPENDED, UNDEPLOYED, POWEROFF EOT command :resume, resume_desc, [:range,:vmid_list], diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 35e2d2a11d..4c6fdeaebb 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -572,12 +572,19 @@ int DispatchManager::resume( Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); - vmpool->update(vm); - vm->log("DiM", Log::INFO, "New VM state is ACTIVE."); lcm->trigger(LifeCycleManager::RESTORE,vid); } + else if (vm->get_state() == VirtualMachine::POWEROFF) + { + Nebula& nd = Nebula::instance(); + LifeCycleManager * lcm = nd.get_lcm(); + + vm->log("DiM", Log::INFO, "New VM state is ACTIVE."); + + lcm->trigger(LifeCycleManager::RESTART,vid); + } else { goto error; @@ -614,14 +621,13 @@ int DispatchManager::restart(int vid) oss << "Restarting VM " << vid; NebulaLog::log("DiM",Log::DEBUG,oss); - if ((vm->get_state() == VirtualMachine::ACTIVE && + if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT || vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN || vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF || vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED || vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED)) - || vm->get_state() == VirtualMachine::POWEROFF ) { Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); @@ -914,7 +920,7 @@ int DispatchManager::resubmit(int vid) { case VirtualMachine::POWEROFF: NebulaLog::log("DiM",Log::ERROR, - "Cannot resubmit a powered off VM. Restart it first"); + "Cannot resubmit a powered off VM. Resume it first"); rc = -2; break;