From 1985b176adff8252886c09f36c075af4144cb95f Mon Sep 17 00:00:00 2001 From: kirankv Date: Fri, 17 May 2013 07:14:44 -0700 Subject: Fix VMwareVCdriver reporting incorrect stats fix bug #1180779 VMware nova compute drivers VMwareESXDriver and VMwareVCDriver currently report stats for the column local_gb in MB instead of in GB The fix would be to modify vmwareapi/host.py to ensure the values reported for disk space are calculated in GB instead of MB. Fix is done by further dividing the existing MB value by 1024 to convert to GB. The unit tests to check for capacity and freespace have been modified to check for GB. Change-Id: I0610047ee2bddefe0ccb46568c0f48de4c0941af --- nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py | 7 ++++--- nova/virt/vmwareapi/fake.py | 5 +++-- nova/virt/vmwareapi/host.py | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py b/nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py index eda2c25f9..123a314c1 100644 --- a/nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py +++ b/nova/tests/virt/vmwareapi/test_vmwareapi_vm_util.py @@ -1,5 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# + +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # Copyright 2013 Canonical Corp. # All Rights Reserved. # @@ -41,8 +42,8 @@ class VMwareVMUtilTestCase(test.TestCase): fake_session([fake.Datastore()])) self.assertEquals(result[1], "fake-ds") - self.assertEquals(result[2], 1024 * 1024 * 1024) - self.assertEquals(result[3], 1024 * 1024 * 500) + self.assertEquals(result[2], 1024 * 1024 * 1024 * 1024) + self.assertEquals(result[3], 1024 * 1024 * 500 * 1024) def test_get_datastore_ref_and_name_without_datastore(self): diff --git a/nova/virt/vmwareapi/fake.py b/nova/virt/vmwareapi/fake.py index 86b6e5fc2..d8e2eb217 100644 --- a/nova/virt/vmwareapi/fake.py +++ b/nova/virt/vmwareapi/fake.py @@ -1,5 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # Copyright (c) 2012 VMware, Inc. # Copyright (c) 2011 Citrix Systems, Inc. # Copyright 2011 OpenStack Foundation @@ -255,8 +256,8 @@ class Datastore(ManagedObject): super(Datastore, self).__init__("Datastore") self.set("summary.type", "VMFS") self.set("summary.name", "fake-ds") - self.set("summary.capacity", 1024 * 1024 * 1024) - self.set("summary.freeSpace", 500 * 1024 * 1024) + self.set("summary.capacity", 1024 * 1024 * 1024 * 1024) + self.set("summary.freeSpace", 500 * 1024 * 1024 * 1024) class HostNetworkSystem(ManagedObject): diff --git a/nova/virt/vmwareapi/host.py b/nova/virt/vmwareapi/host.py index 8c62c5ce9..7abff5678 100644 --- a/nova/virt/vmwareapi/host.py +++ b/nova/virt/vmwareapi/host.py @@ -126,8 +126,8 @@ class HostState(object): "sockets": summary.hardware.numCpuPkgs, "threads": summary.hardware.numCpuThreads} } - data["disk_total"] = ds[2] / (1024 * 1024) - data["disk_available"] = ds[3] / (1024 * 1024) + data["disk_total"] = ds[2] / (1024 * 1024 * 1024) + data["disk_available"] = ds[3] / (1024 * 1024 * 1024) data["disk_used"] = data["disk_total"] - data["disk_available"] data["host_memory_total"] = summary.hardware.memorySize / (1024 * 1024) data["host_memory_free"] = data["host_memory_total"] - \ @@ -193,8 +193,8 @@ class VCState(object): "sockets": summary.hardware.numCpuPkgs, "threads": summary.hardware.numCpuThreads} } - data["disk_total"] = ds[2] / (1024 * 1024) - data["disk_available"] = ds[3] / (1024 * 1024) + data["disk_total"] = ds[2] / (1024 * 1024 * 1024) + data["disk_available"] = ds[3] / (1024 * 1024 * 1024) data["disk_used"] = data["disk_total"] - data["disk_available"] data["host_memory_total"] = summary.hardware.memorySize / (1024 * 1024) data["host_memory_free"] = data["host_memory_total"] -\ -- cgit