From f46afca3720c48d9baca5b2004fc24dedcbacdf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 26 Mar 2015 18:51:13 +0100 Subject: [PATCH] Feature #3654: Transitions to migrate suspended VMs (cherry picked from commit ee7bccf48a6852117091ae3051d219cd93addd3d) --- include/VirtualMachine.h | 8 +++++++- share/doc/states/states-complete.dot | 8 +++++++- share/doc/xsd/acct.xsd | 4 +++- share/doc/xsd/vm.xsd | 4 +++- .../java/src/org/opennebula/client/vm/VirtualMachine.java | 8 ++++++-- src/oca/ruby/opennebula/virtual_machine.rb | 4 ++++ src/sunstone/OpenNebulaVNC.rb | 2 ++ src/sunstone/public/js/opennebula.js | 6 +++++- src/sunstone/public/js/plugins/vms-tab.js | 4 ++++ src/tm/TransferManagerDriver.cc | 2 ++ 10 files changed, 43 insertions(+), 7 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index abf610d1f2..09f4297a90 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -148,7 +148,9 @@ public: EPILOG_STOP_FAILURE = 41, EPILOG_UNDEPLOY_FAILURE = 42, PROLOG_MIGRATE_POWEROFF = 43, - PROLOG_MIGRATE_POWEROFF_FAILURE = 44 + PROLOG_MIGRATE_POWEROFF_FAILURE = 44, + PROLOG_MIGRATE_SUSPEND = 45, + PROLOG_MIGRATE_SUSPEND_FAILURE = 46 }; static int lcm_state_from_str(string& st, LcmState& state) @@ -199,6 +201,8 @@ public: else if ( st == "EPILOG_UNDEPLOY_FAILURE") { state = EPILOG_UNDEPLOY_FAILURE; } else if ( st == "PROLOG_MIGRATE_POWEROFF") { state = PROLOG_MIGRATE_POWEROFF;} else if ( st == "PROLOG_MIGRATE_POWEROFF_FAILURE") { state = PROLOG_MIGRATE_POWEROFF_FAILURE;} + else if ( st == "PROLOG_MIGRATE_SUSPEND") { state = PROLOG_MIGRATE_SUSPEND;} + else if ( st == "PROLOG_MIGRATE_SUSPEND_FAILURE") { state = PROLOG_MIGRATE_SUSPEND_FAILURE;} else {return -1;} return 0; @@ -252,6 +256,8 @@ public: case EPILOG_UNDEPLOY_FAILURE: st = "EPILOG_UNDEPLOY_FAILURE"; break; case PROLOG_MIGRATE_POWEROFF: st = "PROLOG_MIGRATE_POWEROFF"; break; case PROLOG_MIGRATE_POWEROFF_FAILURE: st = "PROLOG_MIGRATE_POWEROFF_FAILURE"; break; + case PROLOG_MIGRATE_SUSPEND: st = "PROLOG_MIGRATE_SUSPEND"; break; + case PROLOG_MIGRATE_SUSPEND_FAILURE: st = "PROLOG_MIGRATE_SUSPEND_FAILURE"; break; } return st; diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 08daff19b5..3f1f6ac561 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -26,7 +26,7 @@ digraph OpenNebula { subgraph { rank = same; boot; boot_stopped; boot_undeploy; boot_suspended; boot_unknown; boot_poweroff; boot_migrate; boot_failure; boot_migrate_failure; color="white"} subgraph { rank = same; running; unknown; color="white"} subgraph { rank = same; pending; hold; color="white"} - subgraph { rank = same; prolog; prolog_failure; prolog_resume; prolog_migrate; prolog_migrate_failure; prolog_migrate_poweroff; prolog_migrate_poweroff_failure; prolog_undeploy; color="white" } + subgraph { rank = same; prolog; prolog_failure; prolog_resume; prolog_migrate; prolog_migrate_failure; prolog_migrate_poweroff; prolog_migrate_poweroff_failure; prolog_migrate_suspend; prolog_migrate_suspend_failure; prolog_undeploy; color="white" } subgraph { rank = same; hotplug_prolog_poweroff; hotplug_saveas_poweroff; hotplug_saveas_suspended; epilog_stop; epilog; epilog_undeploy; epilog_stop_failure; epilog_failure; epilog_undeploy_failure; hotplug_epilog_poweroff; color="white" } subgraph { rank = sink; done; failure; ANY; color="white" } @@ -85,6 +85,9 @@ digraph OpenNebula { poweroff -> prolog_migrate_poweroff [label="migrate"]; prolog_migrate_poweroff -> poweroff [style="dashed", color="blue"]; + suspended -> prolog_migrate_suspend [label="migrate"]; + prolog_migrate_suspend -> suspended [style="dashed", color="blue"]; + # hold pending -> hold [label="hold"]; @@ -193,6 +196,9 @@ digraph OpenNebula { prolog_migrate_poweroff -> prolog_migrate_poweroff_failure [label=" ", style="dotted", color="red"]; prolog_migrate_poweroff_failure -> prolog_migrate_poweroff [label="migrate"]; + prolog_migrate_suspend -> prolog_migrate_suspend_failure [label=" ", style="dotted", color="red"]; + prolog_migrate_suspend_failure -> prolog_migrate_suspend [label="migrate"]; + prolog_resume -> stopped [style="dotted", color="red"]; prolog_undeploy -> undeployed [style="dotted", color="red"]; diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd index a00cd8a2b5..249debe11e 100644 --- a/share/doc/xsd/acct.xsd +++ b/share/doc/xsd/acct.xsd @@ -157,7 +157,9 @@ EPILOG_STOP_FAILURE = 41, EPILOG_UNDEPLOY_FAILURE = 42, PROLOG_MIGRATE_POWEROFF = 43, - PROLOG_MIGRATE_POWEROFF_FAILURE = 44 + PROLOG_MIGRATE_POWEROFF_FAILURE = 44, + PROLOG_MIGRATE_SUSPEND = 45, + PROLOG_MIGRATE_SUSPEND_FAILURE = 46 --> diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd index ba9aa823b9..31ef56338e 100644 --- a/share/doc/xsd/vm.xsd +++ b/share/doc/xsd/vm.xsd @@ -90,7 +90,9 @@ EPILOG_STOP_FAILURE = 41, EPILOG_UNDEPLOY_FAILURE = 42, PROLOG_MIGRATE_POWEROFF = 43, - PROLOG_MIGRATE_POWEROFF_FAILURE = 44 + PROLOG_MIGRATE_POWEROFF_FAILURE = 44, + PROLOG_MIGRATE_SUSPEND = 45, + PROLOG_MIGRATE_SUSPEND_FAILURE = 46 --> diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index fe81ac5c28..e8a2c10615 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -121,7 +121,9 @@ public class VirtualMachine extends PoolElement{ "EPILOG_STOP_FAILURE", "EPILOG_UNDEPLOY_FAILURE", "PROLOG_MIGRATE_POWEROFF", - "PROLOG_MIGRATE_POWEROFF_FAILURE" + "PROLOG_MIGRATE_POWEROFF_FAILURE", + "PROLOG_MIGRATE_SUSPEND", + "PROLOG_MIGRATE_SUSPEND_FAILURE" }; private static final String[] SHORT_LCM_STATES = @@ -170,7 +172,9 @@ public class VirtualMachine extends PoolElement{ "fail", // EPILOG_STOP_FAILURE "fail", // EPILOG_UNDEPLOY_FAILURE "migr", // PROLOG_MIGRATE_POWEROFF - "fail" // PROLOG_MIGRATE_POWEROFF_FAILURE + "fail", // PROLOG_MIGRATE_POWEROFF_FAILURE + "migr", // PROLOG_MIGRATE_SUSPEND + "fail" // PROLOG_MIGRATE_SUSPEND_FAILURE }; /** diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 6db6d78f10..1c513b41dd 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -95,6 +95,8 @@ module OpenNebula EPILOG_UNDEPLOY_FAILURE PROLOG_MIGRATE_POWEROFF PROLOG_MIGRATE_POWEROFF_FAILURE + PROLOG_MIGRATE_SUSPEND + PROLOG_MIGRATE_SUSPEND_FAILURE } SHORT_VM_STATES={ @@ -155,6 +157,8 @@ module OpenNebula "EPILOG_UNDEPLOY_FAILURE" => "fail", "PROLOG_MIGRATE_POWEROFF" => "migr", "PROLOG_MIGRATE_POWEROFF_FAILURE" => "fail", + "PROLOG_MIGRATE_SUSPEND" => "migr", + "PROLOG_MIGRATE_SUSPEND_FAILURE" => "fail", } MIGRATE_REASON=%w{NONE ERROR USER} diff --git a/src/sunstone/OpenNebulaVNC.rb b/src/sunstone/OpenNebulaVNC.rb index ac96ece445..ce3a3349ae 100644 --- a/src/sunstone/OpenNebulaVNC.rb +++ b/src/sunstone/OpenNebulaVNC.rb @@ -77,6 +77,8 @@ VNC_STATES = [ #42, #EPILOG_UNDEPLOY_FAILURE #43, #PROLOG_MIGRATE_POWEROFF #44, #PROLOG_MIGRATE_POWEROFF_FAILURE + #45, #PROLOG_MIGRATE_SUSPEND + #46, #PROLOG_MIGRATE_SUSPEND_FAILURE ] class OpenNebulaVNC diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index a2d9304bc2..27ad91ffd0 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -163,6 +163,8 @@ var OpenNebula = { "FAILURE", // EPILOG_UNDEPLOY_FAILURE "MIGRATE", // PROLOG_MIGRATE_POWEROFF "FAILURE" // PROLOG_MIGRATE_POWEROFF_FAILURE + "MIGRATE", // PROLOG_MIGRATE_SUSPEND + "FAILURE" // PROLOG_MIGRATE_SUSPEND_FAILURE ][value]); break; case "IMAGE": @@ -962,7 +964,9 @@ var OpenNebula = { "EPILOG_STOP_FAILURE" : 41, "EPILOG_UNDEPLOY_FAILURE" : 42, "PROLOG_MIGRATE_POWEROFF" : 43, - "PROLOG_MIGRATE_POWEROFF_FAILURE" : 44 + "PROLOG_MIGRATE_POWEROFF_FAILURE" : 44, + "PROLOG_MIGRATE_SUSPEND" : 45, + "PROLOG_MIGRATE_SUSPEND_FAILURE" : 46 }, "create": function(params){ diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 38d0e025d7..fc624f29d6 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -169,6 +169,10 @@ var lcm_state_actions = { [], 44: //OpenNebula.VM.lcm_state.PROLOG_MIGRATE_POWEROFF_FAILURE: [], + 45: //OpenNebula.VM.lcm_state.PROLOG_MIGRATE_SUSPEND: + [], + 46: //OpenNebula.VM.lcm_state.PROLOG_MIGRATE_SUSPEND_FAILURE: + [], } //Permanent storage for last value of aggregated network usage diff --git a/src/tm/TransferManagerDriver.cc b/src/tm/TransferManagerDriver.cc index 456caebafd..9ab120ca64 100644 --- a/src/tm/TransferManagerDriver.cc +++ b/src/tm/TransferManagerDriver.cc @@ -122,6 +122,7 @@ void TransferManagerDriver::protocol(const string& message) const case VirtualMachine::PROLOG_RESUME: case VirtualMachine::PROLOG_UNDEPLOY: case VirtualMachine::PROLOG_MIGRATE_POWEROFF: + case VirtualMachine::PROLOG_MIGRATE_SUSPEND: lcm_action = LifeCycleManager::PROLOG_SUCCESS; break; @@ -176,6 +177,7 @@ void TransferManagerDriver::protocol(const string& message) const case VirtualMachine::PROLOG_RESUME: case VirtualMachine::PROLOG_UNDEPLOY: case VirtualMachine::PROLOG_MIGRATE_POWEROFF: + case VirtualMachine::PROLOG_MIGRATE_SUSPEND: lcm_action = LifeCycleManager::PROLOG_FAILURE; break;