Skip to content

Commit 3bfaf79

Browse files
author
David Moreau Simard
committed
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
1 parent d80deab commit 3bfaf79

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

openstackclient/compute/v2/hypervisor.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ def take_action(self, parsed_args):
7777
hypervisor = utils.find_resource(compute_client.hypervisors,
7878
parsed_args.hypervisor)._info.copy()
7979

80+
aggregates = compute_client.aggregates.list()
81+
hypervisor["aggregates"] = list()
82+
if aggregates:
83+
# Hypervisors in nova cells are prefixed by "<cell>@"
84+
if "@" in hypervisor['service']['host']:
85+
cell, service_host = hypervisor['service']['host'].split('@',
86+
1)
87+
else:
88+
cell = None
89+
service_host = hypervisor['service']['host']
90+
91+
if cell:
92+
# The host aggregates are also prefixed by "<cell>@"
93+
member_of = [aggregate.name
94+
for aggregate in aggregates
95+
if cell in aggregate.name and
96+
service_host in aggregate.hosts]
97+
else:
98+
member_of = [aggregate.name
99+
for aggregate in aggregates
100+
if service_host in aggregate.hosts]
101+
hypervisor["aggregates"] = member_of
102+
80103
uptime = compute_client.hypervisors.uptime(hypervisor['id'])._info
81104
# Extract data from uptime value
82105
# format: 0 up 0, 0 users, load average: 0, 0, 0

0 commit comments

Comments
 (0)