diff options
| author | Hironori Shiina <shiina.hironori@jp.fujitsu.com> | 2016-08-11 14:57:57 +0900 |
|---|---|---|
| committer | Hironori Shiina <shiina.hironori@jp.fujitsu.com> | 2016-09-11 21:58:55 +0900 |
| commit | 98bafda7e919b57d473f283f96ebb39219cfd2b6 (patch) | |
| tree | af4a87d5d9d36fad59e854cc2583dfa16c4d0420 /openstackclient/compute/v2/hypervisor.py | |
| parent | d6f99b721d3e3978fd6a5438bdacefd5840d3b02 (diff) | |
| download | python-openstackclient-98bafda7e919b57d473f283f96ebb39219cfd2b6.tar.gz | |
Display hypervisor information without uptime
Some virt drivers such as ironic virt driver doesn't implement a
method to get host uptime. For such drivers, hypervisor show command
displays no information although these drivers provides other host
information.
This patch fixes the command to display hypervisor information in case
where a virt driver doesn't provide host uptime by ignoring a
HTTPNotImplemented exception.
Change-Id: I7bcca5862cd9c05aadaf6192cb80aa651cd77cad
Closes-Bug: 1612065
Diffstat (limited to 'openstackclient/compute/v2/hypervisor.py')
| -rw-r--r-- | openstackclient/compute/v2/hypervisor.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/openstackclient/compute/v2/hypervisor.py b/openstackclient/compute/v2/hypervisor.py index f9051919..0222e899 100644 --- a/openstackclient/compute/v2/hypervisor.py +++ b/openstackclient/compute/v2/hypervisor.py @@ -17,6 +17,7 @@ import re +from novaclient import exceptions as nova_exceptions from osc_lib.command import command from osc_lib import utils import six @@ -94,18 +95,22 @@ class ShowHypervisor(command.ShowOne): 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 - # example: 17:37:14 up 2:33, 3 users, load average: 0.33, 0.36, 0.34 - m = re.match( - "\s*(.+)\sup\s+(.+),\s+(.+)\susers?,\s+load average:\s(.+)", - uptime['uptime']) - if m: - hypervisor["host_time"] = m.group(1) - hypervisor["uptime"] = m.group(2) - hypervisor["users"] = m.group(3) - hypervisor["load_average"] = m.group(4) + try: + uptime = compute_client.hypervisors.uptime(hypervisor['id'])._info + # Extract data from uptime value + # format: 0 up 0, 0 users, load average: 0, 0, 0 + # example: 17:37:14 up 2:33, 3 users, + # load average: 0.33, 0.36, 0.34 + m = re.match( + "\s*(.+)\sup\s+(.+),\s+(.+)\susers?,\s+load average:\s(.+)", + uptime['uptime']) + if m: + hypervisor["host_time"] = m.group(1) + hypervisor["uptime"] = m.group(2) + hypervisor["users"] = m.group(3) + hypervisor["load_average"] = m.group(4) + except nova_exceptions.HTTPNotImplemented: + pass hypervisor["service_id"] = hypervisor["service"]["id"] hypervisor["service_host"] = hypervisor["service"]["host"] |
