summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-30 15:50:10 +0000
committerGerrit Code Review <review@openstack.org>2012-10-30 15:50:10 +0000
commit2f24d950c00580d650b945830ab79da266acf5ea (patch)
tree3a3b5d328f5cc8fec9e57f3548315869c6b1383d /nova/api
parent18882e4f18df6a6b5217c39eedd009c4747f4803 (diff)
parentd9c95e4c8bb0a2d9d7f73600d82bfd32318c37a6 (diff)
downloadnova-2f24d950c00580d650b945830ab79da266acf5ea.tar.gz
nova-2f24d950c00580d650b945830ab79da266acf5ea.tar.xz
nova-2f24d950c00580d650b945830ab79da266acf5ea.zip
Merge "Support for nova client list hosts with specific zone"
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