diff options
| author | David Moreau Simard <dmsimard@iweb.com> | 2015-06-30 14:36:51 -0400 |
|---|---|---|
| committer | David Moreau Simard <dmsimard@iweb.com> | 2015-07-02 10:23:22 -0400 |
| commit | 3bfaf79732a5c4493ae700722c48a20dab8690a2 (patch) | |
| tree | 79d050c57b62d73083fc5dde5c7e8aa47093c06d /openstackclient | |
| parent | d80deaba41d09534a3f5a670957b4b0d035509b6 (diff) | |
| download | python-openstackclient-3bfaf79732a5c4493ae700722c48a20dab8690a2.tar.gz | |
Show which aggregate a hypervisor is member of
This adds support for showing which host aggregates
a hypervisor is member of, if any.
It supports hypervisors with or without nova cells.
Closes-bug: #1470875
Change-Id: I0cfe4f15fa8f8ba0be3295b79cd438998893114c
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/compute/v2/hypervisor.py | 23 |
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 |
