From 8696b216a2959a4f64e612f14181c5d76cd2aef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 11 Jan 2011 18:50:29 +0100 Subject: [PATCH] Features #457 & #455: Resubmit action for VMs added to the RM and CLI --- src/cli/onevm | 22 +++++++++++++++++++++- src/oca/ruby/OpenNebula/VirtualMachine.rb | 7 ++++++- src/rm/RequestManagerAction.cc | 4 ++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 43c2e3edbf..0a60ac44ed 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -362,9 +362,12 @@ Commands: * delete (Deletes a VM from the pool and DB) onevm delete -* restart (Resubmits the VM after failure) +* restart (Forces a re-deployment of a VM in UNKNOWN or BOOT state) onevm restart +* resubmit (Resubmits a VM to PENDING state) + onevm resubmit + * list (Shows VMs in the pool) onevm list where filter_flag can be @@ -673,6 +676,23 @@ when "restart" end end +when "resubmit" + check_parameters("resubmit", 1) + args=expand_args(ARGV) + + args.each do |param| + vm_id=get_vm_id(param) + + vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client) + + result=vm.resubmit + if is_successful?(result) + puts "Resubmitting VM" if ops[:verbose] + else + break + end + end + when "list" ops.merge!(get_user_flags) if !ops[:xml] diff --git a/src/oca/ruby/OpenNebula/VirtualMachine.rb b/src/oca/ruby/OpenNebula/VirtualMachine.rb index b65fece375..d3eb85351c 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachine.rb +++ b/src/oca/ruby/OpenNebula/VirtualMachine.rb @@ -179,11 +179,16 @@ module OpenNebula action('finalize') end - # Resubmits the VM after failure + # Forces a re-deployment of a VM in UNKNOWN or BOOT state def restart action('restart') end + # Resubmits a VM to PENDING state + def resubmit + action('resubmit') + end + # Saves a running VM and starts it again in the specified host def migrate(host_id) return Error.new('ID not defined') if !@pe_id diff --git a/src/rm/RequestManagerAction.cc b/src/rm/RequestManagerAction.cc index 11ff2f1b9e..d5fd07230b 100644 --- a/src/rm/RequestManagerAction.cc +++ b/src/rm/RequestManagerAction.cc @@ -120,6 +120,10 @@ void RequestManager::VirtualMachineAction::execute( { rc = dm->finalize(vid); } + else if (action == "resubmit") + { + rc = dm->resubmit(vid); + } else { rc = -3;