From 28dae143b58ab311b9cd6d00b2819bcf34db32d9 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 14 Mar 2013 17:23:18 +0100 Subject: [PATCH] feature #1797: changed reboot in the CLI and ruby oca --- src/cli/one_helper/onevm_helper.rb | 8 +++++- src/cli/onevm | 29 +++++++--------------- src/oca/ruby/opennebula/virtual_machine.rb | 9 +++---- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 1fd20b9c93..959f1a3aab 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -83,11 +83,17 @@ class OneVMHelper < OpenNebulaHelper::OneHelper } LIVE = { - :name =>"live", + :name => "live", :large => "--live", :description => "Do the action with the VM running" } + HARD = { + :name => "hard", + :large => "--hard", + :description=> "Does not communicate with the guest OS" + } + def self.rname "VM" end diff --git a/src/cli/onevm b/src/cli/onevm index 049431d657..1422cdecd3 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -332,33 +332,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do Reboots the given VM, this is equivalent to execute the reboot command from the VM console. + The VM will be ungracefully rebooted if --hard is used. + States: RUNNING EOT command :reboot, reboot_desc, [:range,:vmid_list], - :options => [OneVMHelper::SCHEDULE] do + :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do + + command_name='reboot' + 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,"rebooting") do |vm| - vm.reboot - end - end - end - - reset_desc = <<-EOT.unindent - Resets the given VM - - States: RUNNING - EOT - - command :reset, reset_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,"resetting") do |vm| - vm.reset + vm.reboot(options[:hard]) end end end diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 058b90ea97..b83a23316a 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -215,14 +215,11 @@ module OpenNebula end # Reboots an already deployed VM - def reboot - action('reboot') + def reboot(hard=false) + action(hard ? 'reboot-hard' : 'reboot') end - # Resets an already deployed VM - def reset - action('reset') - end + alias_method :reset, :reboot # Cancels a running VM def cancel