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
This commit is contained in:
Alessandro Pilotti
2012-10-31 19:38:55 +02:00
parent bbff58fdb7
commit dcc3b9c73d
3 changed files with 10 additions and 0 deletions

View File

@@ -103,6 +103,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
# Modules in which the mocks are going to be injected # Modules in which the mocks are going to be injected
from nova.virt.hyperv import baseops from nova.virt.hyperv import baseops
from nova.virt.hyperv import hostops
from nova.virt.hyperv import livemigrationops from nova.virt.hyperv import livemigrationops
from nova.virt.hyperv import snapshotops from nova.virt.hyperv import snapshotops
from nova.virt.hyperv import vmops from nova.virt.hyperv import vmops
@@ -112,6 +113,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
modules_to_test = [ modules_to_test = [
driver_hyperv, driver_hyperv,
baseops, baseops,
hostops,
vmops, vmops,
vmutils, vmutils,
volumeops, volumeops,
@@ -157,6 +159,14 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
self.assertEquals(dic['hypervisor_hostname'], platform.node()) 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): def test_list_instances(self):
num_vms = self._hypervutils.get_vm_count() num_vms = self._hypervutils.get_vm_count()
instances = self._conn.list_instances() instances = self._conn.list_instances()