diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-02-24 15:23:15 -0800 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-02-24 15:23:15 -0800 |
| commit | 47bbfaab52642f3ff79bcdefb8d705fb02b549f9 (patch) | |
| tree | 19084b28052ab37a6d7b9415e4eaf24689ad3f97 /nova/scheduler | |
| parent | c8df2602fd8f4f2cb7716e6283f3779c6895a479 (diff) | |
| download | nova-47bbfaab52642f3ff79bcdefb8d705fb02b549f9.tar.gz nova-47bbfaab52642f3ff79bcdefb8d705fb02b549f9.tar.xz nova-47bbfaab52642f3ff79bcdefb8d705fb02b549f9.zip | |
new tests
Diffstat (limited to 'nova/scheduler')
| -rw-r--r-- | nova/scheduler/api.py | 37 | ||||
| -rw-r--r-- | nova/scheduler/zone_manager.py | 3 |
2 files changed, 21 insertions, 19 deletions
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index ac38350ed..fcff2f146 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -25,34 +25,37 @@ FLAGS = flags.FLAGS LOG = logging.getLogger('nova.scheduler.api') -class API: - """API for interacting with the scheduler.""" +def _call_scheduler(method, context, params=None): + """Generic handler for RPC calls to the scheduler. - def _call_scheduler(self, method, context, params=None): - """Generic handler for RPC calls to the scheduler. + :param params: Optional dictionary of arguments to be passed to the + scheduler worker - :param params: Optional dictionary of arguments to be passed to the - scheduler worker + :retval: Result returned by scheduler worker + """ + if not params: + params = {} + queue = FLAGS.scheduler_topic + kwargs = {'method': method, 'args': params} + return rpc.call(context, queue, kwargs) - :retval: Result returned by scheduler worker - """ - if not params: - params = {} - queue = FLAGS.scheduler_topic - kwargs = {'method': method, 'args': params} - return rpc.call(context, queue, kwargs) - def get_zone_list(self, context): +class API: + """API for interacting with the scheduler.""" + + @classmethod + def get_zone_list(cls, context): """Return a list of zones assoicated with this zone.""" - items = self._call_scheduler('get_zone_list', context) + items = _call_scheduler('get_zone_list', context) for item in items: item['api_url'] = item['api_url'].replace('\\/', '/') return items - def get_zone_capabilities(self, context, service=None): + @classmethod + def get_zone_capabilities(cls, context, service=None): """Returns a dict of key, value capabilities for this zone, or for a particular class of services running in this zone.""" - return self._call_scheduler('get_zone_capabilities', context=context, + return _call_scheduler('get_zone_capabilities', context=context, params=dict(service=service)) @classmethod diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py index 09c9811f3..c1a50dbc3 100644 --- a/nova/scheduler/zone_manager.py +++ b/nova/scheduler/zone_manager.py @@ -118,8 +118,7 @@ class ZoneManager(object): <cap>_min and <cap>_max values.""" service_dict = self.service_states if service: - service_dict = dict(service_name=service, - hosts=self.service_states.get(service, {})) + service_dict = {service: self.service_states.get(service, {})} # TODO(sandy) - be smarter about fabricating this structure. # But it's likely to change once we understand what the Best-Match |
