From 19e90ec530d284ff97af6136d4e648e57aba7dc9 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 24 Feb 2013 00:57:55 +0100 Subject: [PATCH] feature #1722: Use the right units for host update. Fix enforce in onevm command --- include/Host.h | 2 +- src/cli/onevm | 4 ++-- src/rm/RequestManagerVirtualMachine.cc | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/Host.h b/include/Host.h index 38605c5c86..31cc4477d2 100644 --- a/include/Host.h +++ b/include/Host.h @@ -339,7 +339,7 @@ public: */ bool test_capacity(int cpu, int mem, int disk) { - return host_share.test(cpu,mem,disk); + return host_share.test(cpu, mem, disk); } /** diff --git a/src/cli/onevm b/src/cli/onevm index 5c46178a7d..950358345d 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -670,12 +670,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :resize, resize_desc, :vmid, :options => - OpenNebulaHelper::CAPACITY_OPTIONS_VM + [ENFORCE]do + OpenNebulaHelper::CAPACITY_OPTIONS_VM + [ENFORCE] do cpu = options[:cpu] || 0 memory = options[:memory] || 0 vcpu = options[:vcpu] || 0 - enforce = options[:enforce] || true + enforce = options[:enforce] || false helper.perform_action(args[0], options, "Resizing VM") do |vm| vm.resize(cpu, memory, vcpu, enforce) diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 73f338b8a6..7f4ce72b2d 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -1241,6 +1241,9 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, if (hid != -1) { + int dcpu_host = (int) (dcpu * 100);//now in 100% + int dmem_host = dmemory * 1024; //now in Kilobytes + host = hpool->get(hid, true); if (host == 0) @@ -1254,7 +1257,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, return ; } - if ( enforce && host->test_capacity(dcpu, dmemory, 0) == false ) + if ( enforce && host->test_capacity(dcpu_host, dmem_host, 0) == false) { ostringstream oss; @@ -1270,7 +1273,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, return; } - host->update_capacity(dcpu, dmemory, 0); + host->update_capacity(dcpu_host, dmem_host, 0); hpool->update(host);