diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-03-08 14:27:49 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-03-08 14:27:49 +0000 |
| commit | 5d98bb38003941654161d5db789d80be937b4926 (patch) | |
| tree | 51a194104ceb718fbcfa6990e53fd9638c4fc208 /openstackclient | |
| parent | 0443c20e29273420d3fc6a80c64ba649191313fb (diff) | |
| parent | 5fddec359dbf6106fd72fcc469d37fd432c85cf3 (diff) | |
| download | python-openstackclient-5d98bb38003941654161d5db789d80be937b4926.tar.gz | |
Merge "Add 'uptime' in 'hypervisor show'"
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/compute/v2/hypervisor.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/openstackclient/compute/v2/hypervisor.py b/openstackclient/compute/v2/hypervisor.py index 355ffbb3..65035d04 100644 --- a/openstackclient/compute/v2/hypervisor.py +++ b/openstackclient/compute/v2/hypervisor.py @@ -16,6 +16,7 @@ """Hypervisor action implementations""" import logging +import re import six from cliff import lister @@ -76,6 +77,18 @@ class ShowHypervisor(show.ShowOne): hypervisor = utils.find_resource(compute_client.hypervisors, parsed_args.hypervisor)._info.copy() + 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("(.+)\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) + hypervisor["service_id"] = hypervisor["service"]["id"] hypervisor["service_host"] = hypervisor["service"]["host"] del hypervisor["service"] |
