diff --git a/src/cli/onevm b/src/cli/onevm index 11afe3663f..2d0afa1f2e 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -304,16 +304,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do shutdown_desc = <<-EOT.unindent Shuts down the given VM. The VM life cycle will end. + With --hard it unplugs the VM. + States: RUNNING EOT command :shutdown, shutdown_desc, [:range,:vmid_list], - :options => [OneVMHelper::SCHEDULE] do + :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do + + command_name='shutdown' + command_name<<'-hard' if options[:hard] + 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,"shutting down") do |vm| - vm.shutdown + vm.shutdown(options[:hard]==true) end end end @@ -423,25 +429,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do 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 - succeeds the VMDIR in the remote machine is not deleted - - States: RUNNING - EOT - - command :cancel, cancel_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,"canceling") do |vm| - vm.cancel - end - end - end - stop_desc = <<-EOT.unindent Stops a running VM. The VM state is saved and transferred back to the front-end along with the disk files diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 56aecb1f00..4776e00ac9 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -205,8 +205,8 @@ module OpenNebula end # Shutdowns an already deployed VM - def shutdown - action('shutdown') + def shutdown(hard=false) + action(hard ? 'shutdown-hard' : 'shutdown') end # Powers off a running VM @@ -224,9 +224,9 @@ module OpenNebula reboot(true) end - # Cancels a running VM + # @deprecated use {#shutdown} def cancel - action('cancel') + shutdown(true) end # Sets a VM to hold state, scheduler will not deploy it