summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-07-13 17:07:08 +0000
committerGerrit Code Review <review@openstack.org>2015-07-13 17:07:08 +0000
commitdc3ff5e00001f4def8908972ca6221e703fd4e0c (patch)
treef0deb153d08ca8afb2ca96ac4b7e5421d8aaeb8b /openstackclient
parent1462fb7f49d1ebd4868fee0c997ceb85c45582dc (diff)
parent3bfaf79732a5c4493ae700722c48a20dab8690a2 (diff)
downloadpython-openstackclient-dc3ff5e00001f4def8908972ca6221e703fd4e0c.tar.gz
Merge "Show which aggregate a hypervisor is member of"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/v2/hypervisor.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/openstackclient/compute/v2/hypervisor.py b/openstackclient/compute/v2/hypervisor.py
index 65035d04..f33beb08 100644
--- a/openstackclient/compute/v2/hypervisor.py
+++ b/openstackclient/compute/v2/hypervisor.py
@@ -77,6 +77,29 @@ class ShowHypervisor(show.ShowOne):
hypervisor = utils.find_resource(compute_client.hypervisors,
parsed_args.hypervisor)._info.copy()
+ aggregates = compute_client.aggregates.list()
+ hypervisor["aggregates"] = list()
+ if aggregates:
+ # Hypervisors in nova cells are prefixed by "<cell>@"
+ if "@" in hypervisor['service']['host']:
+ cell, service_host = hypervisor['service']['host'].split('@',
+ 1)
+ else:
+ cell = None
+ service_host = hypervisor['service']['host']
+
+ if cell:
+ # The host aggregates are also prefixed by "<cell>@"
+ member_of = [aggregate.name
+ for aggregate in aggregates
+ if cell in aggregate.name and
+ service_host in aggregate.hosts]
+ else:
+ member_of = [aggregate.name
+ for aggregate in aggregates
+ if service_host in aggregate.hosts]
+ hypervisor["aggregates"] = member_of
+
uptime = compute_client.hypervisors.uptime(hypervisor['id'])._info
# Extract data from uptime value
# format: 0 up 0, 0 users, load average: 0, 0, 0