diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 959f1a3aab..4930139778 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -94,6 +94,12 @@ class OneVMHelper < OpenNebulaHelper::OneHelper :description=> "Does not communicate with the guest OS" } + RECREATE = { + :name => "recreate", + :large => "--recreate", + :description=> "Resubmits a fresh VM" + } + def self.rname "VM" end diff --git a/src/cli/onevm b/src/cli/onevm index 0ffff221d9..11afe3663f 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -204,19 +204,27 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end - delete_desc = <<-EOT.unindent - Deletes the given VM + destroy_desc = <<-EOT.unindent + Deletes the given VM. Using --recreate resubmits the VM. + + Resubmits the VM to PENDING state. This is intended for VMs stuck in a + transient state. To re-deploy a fresh copy of the same VM, create a + Template and instantiate it, see 'onetemplate instantiate' States: ANY EOT - command :delete, delete_desc, [:range, :vmid_list], - :options => [OneVMHelper::SCHEDULE] do + command :destroy, destroy_desc, [:range, :vmid_list], + :options => [OneVMHelper::SCHEDULE, OneVMHelper::RECREATE] do + + command_name="destroy" + command_name<<"-recreate" if options[:recreate] + if (!options[:schedule].nil?) - helper.schedule_actions(args[0], options, @comm_name) + helper.schedule_actions(args[0], options, command_name) else helper.perform_actions(args[0],options,"deleted") do |vm| - vm.finalize + vm.destroy(options[:recreate]==true) end end end @@ -415,25 +423,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end - resubmit_desc = <<-EOT.unindent - Resubmits the VM to PENDING state. This is intended for VMs stuck in a - transient state. To re-deploy a fresh copy of the same VM, create a - Template and instantiate it, see 'onetemplate instantiate' - - States: ANY, except SUSPENDED or DONE - EOT - - command :resubmit, resubmit_desc, [:range,:vmid_list], - :options => [OneVMHelper::SCHEDULE] do - if (!options[:schedule].nil?) - helper.schedule_actions(args[0], options, @comm_name) - else - helper.perform_actions(args[0],options,"resubmiting") do |vm| - vm.resubmit - end - end - end - cancel_desc = <<-EOT.unindent Cancels the given VM. The process is checked by OpenNebula, so if the process fails the VM remains in running state. If the action diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index ea00fb1cb5..56aecb1f00 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -291,8 +291,17 @@ module OpenNebula end # Deletes a VM from the pool - def finalize - action('finalize') + def destroy(recreate=false) + if recreate + action('destroy-recreate') + else + action('destroy') + end + end + + # @deprecated use {#destroy} instead + def finalize(recreate=false) + destroy(recreate) end # Forces a re-deployment of a VM in UNKNOWN or BOOT state @@ -302,9 +311,9 @@ module OpenNebula alias_method :restart, :boot - # Resubmits a VM to PENDING state + # @deprecated use {#destroy} instead def resubmit - action('resubmit') + action('resubmit-recreate') end # Sets the re-scheduling flag for the VM