summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorivan-zhu <bozhu@linux.vnet.ibm.com>2012-10-24 16:13:01 +0800
committerivan-zhu <bozhu@linux.vnet.ibm.com>2012-10-25 12:04:58 +0800
commitd9c95e4c8bb0a2d9d7f73600d82bfd32318c37a6 (patch)
tree176f6c3e6f1ef0785c7610b95bb407c869a6831a /nova/api
parentdf1fb2978c854beb58646406796c2bef2bfb047f (diff)
downloadnova-d9c95e4c8bb0a2d9d7f73600d82bfd32318c37a6.tar.gz
nova-d9c95e4c8bb0a2d9d7f73600d82bfd32318c37a6.tar.xz
nova-d9c95e4c8bb0a2d9d7f73600d82bfd32318c37a6.zip
Support for nova client list hosts with specific zone
Implements one workitem of blueprint apis-for-nova-manage This add an optional QUEY_STRING(zone=xxx) in /v1.1/{tenant_id}/os-hosts. So we can also send /v1.1/{tenant_id}/os-hosts?zone=xxx now. It will only return the hosts that availability_zone=xxx. Change-Id: I89f2c0bf50f8ea1ef9f06da664f5c4b24098e5df
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/hosts.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py
index 95a80f3f6..67fc897fb 100644
--- a/nova/api/openstack/compute/contrib/hosts.py
+++ b/nova/api/openstack/compute/contrib/hosts.py
@@ -98,13 +98,18 @@ def _list_hosts(req, service=None):
"""
context = req.environ['nova.context']
services = db.service_get_all(context, False)
-
+ zone = ''
+ if 'zone' in req.GET:
+ zone = req.GET['zone']
+ if zone:
+ services = [s for s in services if s['availability_zone'] == zone]
hosts = []
for host in services:
- hosts.append({"host_name": host['host'], 'service': host['topic']})
+ hosts.append({"host_name": host['host'], 'service': host['topic'],
+ 'zone': host['availability_zone']})
if service:
hosts = [host for host in hosts
- if host["service"] == service]
+ if host["service"] == service]
return hosts