From 80fb666fa276b78e87590bb06d3b932eeef48e0e Mon Sep 17 00:00:00 2001 From: Alessandro Pilotti Date: Wed, 31 Oct 2012 19:38:55 +0200 Subject: Fixes hypervisor based image filtering on Hyper-V Fixes Bug #1073547 Nova scheduler's ImagePropertiesFilter based filtering requires the "supported_instances" stat returned by the driver's get_host_stats method. This fix implements the get_host_stats method, providing also some refactoring in the process by adding a HostOps class. Change-Id: Ia6e73eb3e8ff0be028854fe4fd6d8e305fa1d504 --- ...vapi.HyperVAPITestCase.test_get_host_stats_shutil.p.gz | Bin 0 -> 290 bytes ...pervapi.HyperVAPITestCase.test_get_host_stats_wmi.p.gz | Bin 0 -> 888 bytes nova/tests/test_hypervapi.py | 10 ++++++++++ 3 files changed, 10 insertions(+) create mode 100644 nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_shutil.p.gz create mode 100644 nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_wmi.p.gz (limited to 'nova/tests') diff --git a/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_shutil.p.gz b/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_shutil.p.gz new file mode 100644 index 000000000..805931bbb Binary files /dev/null and b/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_shutil.p.gz differ diff --git a/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_wmi.p.gz b/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_wmi.p.gz new file mode 100644 index 000000000..e9852d038 Binary files /dev/null and b/nova/tests/hyperv/stubs/test_hypervapi.HyperVAPITestCase.test_get_host_stats_wmi.p.gz differ diff --git a/nova/tests/test_hypervapi.py b/nova/tests/test_hypervapi.py index 0ae65feaf..e3f9fde4c 100644 --- a/nova/tests/test_hypervapi.py +++ b/nova/tests/test_hypervapi.py @@ -103,6 +103,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase): # Modules in which the mocks are going to be injected from nova.virt.hyperv import baseops + from nova.virt.hyperv import hostops from nova.virt.hyperv import livemigrationops from nova.virt.hyperv import snapshotops from nova.virt.hyperv import vmops @@ -112,6 +113,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase): modules_to_test = [ driver_hyperv, baseops, + hostops, vmops, vmutils, volumeops, @@ -157,6 +159,14 @@ class HyperVAPITestCase(basetestcase.BaseTestCase): self.assertEquals(dic['hypervisor_hostname'], platform.node()) + def test_get_host_stats(self): + dic = self._conn.get_host_stats(True) + + self.assertEquals(dic['disk_total'], + dic['disk_used'] + dic['disk_available']) + self.assertEquals(dic['host_memory_total'], + dic['host_memory_overhead'] + dic['host_memory_free']) + def test_list_instances(self): num_vms = self._hypervutils.get_vm_count() instances = self._conn.list_instances() -- cgit