summaryrefslogtreecommitdiffstats
path: root/nova/scheduler
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-03-22 20:36:49 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-03-22 20:36:49 -0700
commit209da18033a49062bbcfaf7739db5959be87b142 (patch)
treea05b2626a9c5c1c346a5833fc4aca76089b82369 /nova/scheduler
parent2a38aa7583be37ece6c42ba9307c2db0232dbed3 (diff)
pep8 and fixed up zone-list
Diffstat (limited to 'nova/scheduler')
-rw-r--r--nova/scheduler/api.py24
-rw-r--r--nova/scheduler/zone_manager.py5
2 files changed, 23 insertions, 6 deletions
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py
index bd64f9b9b..c1417dfe4 100644
--- a/nova/scheduler/api.py
+++ b/nova/scheduler/api.py
@@ -55,9 +55,27 @@ def get_zone_list(context):
items = _call_scheduler('get_zone_list', context)
for item in items:
item['api_url'] = item['api_url'].replace('\\/', '/')
+ if not items:
+ items = db.zone_get_all(context)
return items
+def zone_get(context, zone_id):
+ return db.zone_get(context, zone_id)
+
+
+def zone_delete(context, zone_id):
+ return db.zone_delete(context, zone_id)
+
+
+def zone_create(context, data):
+ return db.zone_create(context, data)
+
+
+def zone_update(context, zone_id, data):
+ return db.zone_update(context, zone_id, data)
+
+
def get_zone_capabilities(context, service=None):
"""Returns a dict of key, value capabilities for this zone,
or for a particular class of services running in this zone."""
@@ -149,10 +167,8 @@ class reroute_compute(object):
def __call__(self, f):
def wrapped_f(*args, **kwargs):
- LOG.debug(_("IN DECORATOR ..."))
collection, context, item_id = \
self.get_collection_context_and_id(args, kwargs)
- LOG.debug(_("IN DECORATOR 2..."))
try:
# Call the original function ...
return f(*args, **kwargs)
@@ -181,7 +197,7 @@ class reroute_compute(object):
"""Ask the child zones to perform this operation.
Broken out for testing."""
return child_zone_helper(zones, function)
-
+
def get_collection_context_and_id(self, args, kwargs):
"""Returns a tuple of (novaclient collection name, security
context and resource id. Derived class should override this."""
@@ -212,7 +228,7 @@ class reroute_compute(object):
del server[k]
reduced_response.append(dict(server=server))
- if reduced_response:
+ if reduced_response:
return reduced_response[0] # first for now.
return {}
diff --git a/nova/scheduler/zone_manager.py b/nova/scheduler/zone_manager.py
index d32cc2e8f..198f9d4cc 100644
--- a/nova/scheduler/zone_manager.py
+++ b/nova/scheduler/zone_manager.py
@@ -58,8 +58,9 @@ class ZoneState(object):
child zone."""
self.last_seen = datetime.now()
self.attempt = 0
- self.name = zone_metadata["name"]
- self.capabilities = zone_metadata["capabilities"]
+ self.name = zone_metadata.get("name", "n/a")
+ self.capabilities = ", ".join(["%s=%s" % (k, v)
+ for k, v in zone_metadata.iteritems() if k != 'name'])
self.is_active = True
def to_dict(self):