diff --git a/src/cli/onevm b/src/cli/onevm index bf6c4dd074..933d2202d4 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -111,6 +111,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do OpenNebulaHelper.rname_to_id(arg, "USER") end + set :format, :datastoreid, OpenNebulaHelper.rname_to_id_desc("DATASTORE") do |arg| + OpenNebulaHelper.rname_to_id(arg, "DATASTORE") + end + set :format, :vmid, OneVMHelper.to_id_desc do |arg| helper.to_id(arg) end @@ -413,17 +417,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do States: PENDING EOT - command :deploy, deploy_desc, [:range,:vmid_list], :hostid, + command :deploy, deploy_desc, [:range,:vmid_list], :hostid, [:datastoreid,nil], :options=>[ENFORCE] do host_id = args[1] verbose = "deploying in host #{host_id}" + enforce = options[:enforce].nil? ? false : options[:enforce] + ds_id = args[2].nil? ? -1 : args[2] + helper.perform_actions(args[0],options,verbose) do |vm| - if !options[:enforce].nil? - vm.deploy(host_id, options[:enforce]) - else - vm.deploy(host_id) - end + vm.deploy(host_id, enforce, ds_id) end end diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index 9d479a8f68..baa6da3b33 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -491,11 +491,13 @@ public class VirtualMachine extends PoolElement{ * @param enforce 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 + * @param dsId The System Datastore where to deploy the VM. To use the + * default, set it to -1 * @return If an error occurs the error message contains the reason. */ - public OneResponse deploy(int hostId, boolean enforce) + public OneResponse deploy(int hostId, boolean enforce, int dsId) { - return client.call(DEPLOY, id, hostId, enforce); + return client.call(DEPLOY, id, hostId, enforce, dsId); } /** @@ -507,7 +509,7 @@ public class VirtualMachine extends PoolElement{ */ public OneResponse deploy(int hostId) { - return deploy(hostId, false); + return deploy(hostId, false, -1); } /** diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 6f1ce2536a..9939fabd72 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -216,11 +216,13 @@ module OpenNebula # @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 + # @param ds_id [Integer] The System Datastore where to deploy the VM. To + # use the default, set it to -1 # # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def deploy(host_id, enforce=false) - return call(VM_METHODS[:deploy], @pe_id, host_id.to_i, enforce) + def deploy(host_id, enforce=false, ds_id=-1) + return call(VM_METHODS[:deploy], @pe_id, host_id.to_i, enforce, ds_id) end # Shutdowns an already deployed VM