From 06abfef245997ccbf02b70b9b16c99abb3d01470 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 15 Mar 2013 19:13:39 +0100 Subject: [PATCH] feature #1797: change migrate and livemigrate in ruby OCA --- src/cli/onevm | 11 +++-------- src/oca/ruby/opennebula/virtual_machine.rb | 23 +++++++++------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 2d0afa1f2e..22a46bb539 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -400,15 +400,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do host_id = args[1] verbose = "migrating to #{host_id}" - params = [host_id] - params << options[:enforce] if !options[:enforce].nil? - helper.perform_actions(args[0],options,verbose) do |vm| - if options[:live] - vm.live_migrate(*params) - else - vm.migrate(*params) - end + vm.migrate( host_id, + options[:live]==true, + options[:enforce]==true) end end diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 4776e00ac9..dc7dede84b 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -326,32 +326,27 @@ module OpenNebula action('unresched') end - # Saves a running VM and starts it again in the specified host + # Moves a running VM to the specified host. With live=true the + # migration is done withdout downtime. # # @param host_id [Interger] The host id (hid) of the target host where # the VM will be migrated. + # @param live [true|false] If true the migration is done without + # downtime. Defaults to false # @param enforce [true|false] If it is set to true, the host capacity # will be checked, and the deployment will fail if the host is # overcommited. Defaults to false # # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def migrate(host_id, enforce=false) - return call(VM_METHODS[:migrate], @pe_id, host_id.to_i, false, enforce) + def migrate(host_id, live=false, enforce=false) + call(VM_METHODS[:migrate], @pe_id, host_id.to_i, live==true, + enforce) end - # Migrates a running VM to another host without downtime - # - # @param host_id [Interger] The host id (hid) of the target host where - # the VM will be migrated. - # @param enforce [true|false] If it is set to true, the host capacity - # will be checked, and the deployment will fail if the host is - # overcommited. Defaults to false - # - # @return [nil, OpenNebula::Error] nil in case of success, Error - # otherwise + # @deprecated use {#migrate} instead def live_migrate(host_id, enforce=false) - return call(VM_METHODS[:migrate], @pe_id, host_id.to_i, true, enforce) + migrate(host_id, true, enforce) end # Set the specified vm's disk to be saved in a new image