after trunk merge

This commit is contained in:
Ed Leafe
2011-07-01 13:44:12 +00:00
parent baccc08c49
commit 26073ef3a4
3 changed files with 23 additions and 1 deletions

View File

@@ -51,6 +51,11 @@ def _call_scheduler(method, context, params=None):
return rpc.call(context, queue, kwargs) return rpc.call(context, queue, kwargs)
def get_host_list(context):
"""Return a list of hosts associated with this zone."""
return _call_scheduler('get_host_list', context)
def get_zone_list(context): def get_zone_list(context):
"""Return a list of zones assoicated with this zone.""" """Return a list of zones assoicated with this zone."""
items = _call_scheduler('get_zone_list', context) items = _call_scheduler('get_zone_list', context)

View File

@@ -56,6 +56,10 @@ class SchedulerManager(manager.Manager):
"""Poll child zones periodically to get status.""" """Poll child zones periodically to get status."""
self.zone_manager.ping(context) self.zone_manager.ping(context)
def get_host_list(self, context=None):
"""Get a list of hosts from the ZoneManager."""
return self.zone_manager.get_host_list()
def get_zone_list(self, context=None): def get_zone_list(self, context=None):
"""Get a list of zones from the ZoneManager.""" """Get a list of zones from the ZoneManager."""
return self.zone_manager.get_zone_list() return self.zone_manager.get_zone_list()

View File

@@ -115,6 +115,17 @@ class ZoneManager(object):
"""Return the list of zones we know about.""" """Return the list of zones we know about."""
return [zone.to_dict() for zone in self.zone_states.values()] return [zone.to_dict() for zone in self.zone_states.values()]
def get_host_list(self):
"""Returns a list of all the host names that the Zone Manager
knows about.
"""
all_hosts = self.service_states.keys()
ret = []
for host in self.service_states:
for svc in self.service_states[host]:
ret.append({"service": svc, "host_name": host})
return ret
def get_zone_capabilities(self, context): def get_zone_capabilities(self, context):
"""Roll up all the individual host info to generic 'service' """Roll up all the individual host info to generic 'service'
capabilities. Each capability is aggregated into capabilities. Each capability is aggregated into
@@ -127,13 +138,15 @@ class ZoneManager(object):
combined = {} # { <service>_<cap> : (min, max), ... } combined = {} # { <service>_<cap> : (min, max), ... }
for host, host_dict in hosts_dict.iteritems(): for host, host_dict in hosts_dict.iteritems():
for service_name, service_dict in host_dict.iteritems(): for service_name, service_dict in host_dict.iteritems():
if not service_dict.get("enabled", True):
# Service is disabled; do no include it
continue
for cap, value in service_dict.iteritems(): for cap, value in service_dict.iteritems():
key = "%s_%s" % (service_name, cap) key = "%s_%s" % (service_name, cap)
min_value, max_value = combined.get(key, (value, value)) min_value, max_value = combined.get(key, (value, value))
min_value = min(min_value, value) min_value = min(min_value, value)
max_value = max(max_value, value) max_value = max(max_value, value)
combined[key] = (min_value, max_value) combined[key] = (min_value, max_value)
return combined return combined
def _refresh_from_db(self, context): def _refresh_from_db(self, context):