diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 8519b8b5..2b0d9af7 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -292,11 +292,15 @@ def choose_driver(driver_name=None): class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): """The HostFilterScheduler uses the HostFilter drivers to filter hosts for weighing. The particular driver used may be passed in - as an argument or the default will be used.""" + as an argument or the default will be used. + + request_spec = {'filter_driver': , + 'instance_type': } + """ def filter_hosts(self, num, request_spec): """Filter the full host list (from the ZoneManager)""" - driver_name = request_spec.get("filter_driver", None) + driver_name = request_spec.get('filter_driver', None) driver = choose_driver(driver_name) # TODO(sandy): We're only using InstanceType-based specs @@ -309,4 +313,4 @@ class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): def weigh_hosts(self, num, request_spec, hosts): """Derived classes must override this method and return a lists of hosts in [{weight, hostname}] format.""" - return [] + return [dict(weight=1, hostname=hostname) for host, caps in hosts] diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 2fc5f1f8..614b1bb8 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -59,20 +59,25 @@ class ZoneAwareScheduler(driver.Scheduler): for item in build_plan: self.provision_instance(context, topic, item) + # Returning None short-circuits the routing to Compute (since + # we've already done it here) + return None + def provision_instance(context, topic, item): """Create the requested instance in this Zone or a child zone.""" - pass + return None def select(self, context, request_spec, *args, **kwargs): """Select returns a list of weights and zone/host information corresponding to the best hosts to service the request. Any child zone information has been encrypted so as not to reveal anything about the children.""" - return self._schedule(context, "compute", request_spec, *args, **kwargs) + return self._schedule(context, "compute", request_spec, + *args, **kwargs) # TODO(sandy): We're only focused on compute instances right now, # so we don't implement the default "schedule()" method required - # of Schedulers. + # of Schedulers. def schedule(self, context, topic, request_spec, *args, **kwargs): """The schedule() contract requires we return the one best-suited host for this request. diff --git a/nova/tests/test_host_filter.py b/nova/tests/test_host_filter.py index c029d41e..dd2325cc 100644 --- a/nova/tests/test_host_filter.py +++ b/nova/tests/test_host_filter.py @@ -85,9 +85,9 @@ class HostFilterTestCase(test.TestCase): 'nova.scheduler.host_filter.AllHostsFilter') # Test valid driver ... driver = host_filter.choose_driver( - 'nova.scheduler.host_filter.FlavorFilter') + 'nova.scheduler.host_filter.InstanceTypeFilter') self.assertEquals(driver._full_name(), - 'nova.scheduler.host_filter.FlavorFilter') + 'nova.scheduler.host_filter.InstanceTypeFilter') # Test invalid driver ... try: host_filter.choose_driver('does not exist') @@ -103,11 +103,12 @@ class HostFilterTestCase(test.TestCase): for host, capabilities in hosts: self.assertTrue(host.startswith('host')) - def test_flavor_driver(self): - driver = host_filter.FlavorFilter() + def test_instance_type_driver(self): + driver = host_filter.InstanceTypeFilter() # filter all hosts that can support 50 ram and 500 disk name, cooked = driver.instance_type_to_filter(self.instance_type) - self.assertEquals('nova.scheduler.host_filter.FlavorFilter', name) + self.assertEquals('nova.scheduler.host_filter.InstanceTypeFilter', + name) hosts = driver.filter_hosts(self.zone_manager, cooked) self.assertEquals(6, len(hosts)) just_hosts = [host for host, caps in hosts]