summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-05-13 10:43:43 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-05-13 10:43:43 -0700
commit6d04d6e17f753e0573d37992576dedccccf9db93 (patch)
tree54f80b1aab5b69510045ec65d7dd4db8bbbf3659
parent19386db034b6144544aaed72aeab7e562f0087bc (diff)
downloadnova-6d04d6e17f753e0573d37992576dedccccf9db93.tar.gz
nova-6d04d6e17f753e0573d37992576dedccccf9db93.tar.xz
nova-6d04d6e17f753e0573d37992576dedccccf9db93.zip
started on integrating HostFilter
-rw-r--r--nova/scheduler/host_filter.py18
-rw-r--r--nova/scheduler/zone_aware_scheduler.py16
2 files changed, 30 insertions, 4 deletions
diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py
index 483f3225c..17f63d4a0 100644
--- a/nova/scheduler/host_filter.py
+++ b/nova/scheduler/host_filter.py
@@ -286,3 +286,21 @@ def choose_driver(driver_name=None):
if "%s.%s" % (driver.__module__, driver.__name__) == driver_name:
return driver()
raise exception.SchedulerHostFilterDriverNotFound(driver_name=driver_name)
+
+
+class HostFilterScheduler(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."""
+
+ def filter_hosts(self, num, specs):
+ """Filter the full host list (from the ZoneManager)"""
+ driver_name = specs.get("filter_driver", None)
+ driver = host_filter.choose_driver(driver_name)
+
+ # TODO(sandy): We're only using InstanceType-based specs
+ # currently. Later we'll need to snoop for more detailed
+ # host filter requests.
+ instance_type = specs['instance_type']
+ query = driver.instance_type_to_filter(query)
+ return driver.filter_hosts(self.zone_manager, query)
diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py
index b3d230bd2..fde8b6792 100644
--- a/nova/scheduler/zone_aware_scheduler.py
+++ b/nova/scheduler/zone_aware_scheduler.py
@@ -25,6 +25,7 @@ import operator
from nova import log as logging
from nova.scheduler import api
from nova.scheduler import driver
+from nova.scheduler import host_filter
LOG = logging.getLogger('nova.scheduler.zone_aware_scheduler')
@@ -36,7 +37,7 @@ class ZoneAwareScheduler(driver.Scheduler):
"""Call novaclient zone method. Broken out for testing."""
return api.call_zone_method(context, method, specs=specs)
- def schedule_run_instance(self, context, topic='compute', specs={},
+ def schedule_run_instance(self, context, instance_id, instance_type,
*args, **kwargs):
"""This method is called from nova.compute.api to provision
an instance. However we need to look at the parameters being
@@ -46,6 +47,9 @@ class ZoneAwareScheduler(driver.Scheduler):
to simply create the instance (either in this zone or
a child zone)."""
+ # TODO(sandy): We'll have to look for richer specs at some point.
+ specs = instance_type
+
if 'blob' in specs:
return self.provision_instance(context, topic, specs)
@@ -58,7 +62,7 @@ class ZoneAwareScheduler(driver.Scheduler):
"""Create the requested instance in this Zone or a child zone."""
pass
- def select(self, context, *args, **kwargs):
+ def select(self, context, specs, *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
@@ -80,9 +84,13 @@ class ZoneAwareScheduler(driver.Scheduler):
ordered by their fitness.
"""
- #TODO(sandy): extract these from args.
+ if topic != "compute":
+ raise NotImplemented(_("Zone Aware Scheduler only understands "
+ "Compute nodes (for now)"))
+
+ specs = args['instance_type']
+ #TODO(sandy): how to infer this from OS API params?
num_instances = 1
- specs = {}
# Filter local hosts based on requirements ...
host_list = self.filter_hosts(num_instances, specs)