Fix regular expression for uptime in hypervisor show
Hypervisor show command has a few bugs as follows. - It doesn't trim an extra whitespace in the head of uptime information. - It doesn't display uptime information when the number of user is 1. This patch fixes the regular expression to match uptime information. Change-Id: Ic2f7fd9a9274466717084a0886f95f78e98a9007 Closes-Bug: 1611809
This commit is contained in:
parent
d2273ecea5
commit
d6f99b721d
openstackclient
@ -98,8 +98,9 @@ class ShowHypervisor(command.ShowOne):
|
|||||||
# Extract data from uptime value
|
# Extract data from uptime value
|
||||||
# format: 0 up 0, 0 users, load average: 0, 0, 0
|
# 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
|
# 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(.+)",
|
m = re.match(
|
||||||
uptime['uptime'])
|
"\s*(.+)\sup\s+(.+),\s+(.+)\susers?,\s+load average:\s(.+)",
|
||||||
|
uptime['uptime'])
|
||||||
if m:
|
if m:
|
||||||
hypervisor["host_time"] = m.group(1)
|
hypervisor["host_time"] = m.group(1)
|
||||||
hypervisor["uptime"] = m.group(2)
|
hypervisor["uptime"] = m.group(2)
|
||||||
|
@ -159,10 +159,12 @@ class TestHypervisorShow(TestHypervisor):
|
|||||||
'free_disk_gb',
|
'free_disk_gb',
|
||||||
'free_ram_mb',
|
'free_ram_mb',
|
||||||
'host_ip',
|
'host_ip',
|
||||||
|
'host_time',
|
||||||
'hypervisor_hostname',
|
'hypervisor_hostname',
|
||||||
'hypervisor_type',
|
'hypervisor_type',
|
||||||
'hypervisor_version',
|
'hypervisor_version',
|
||||||
'id',
|
'id',
|
||||||
|
'load_average',
|
||||||
'local_gb',
|
'local_gb',
|
||||||
'local_gb_used',
|
'local_gb_used',
|
||||||
'memory_mb',
|
'memory_mb',
|
||||||
@ -172,6 +174,8 @@ class TestHypervisorShow(TestHypervisor):
|
|||||||
'service_id',
|
'service_id',
|
||||||
'state',
|
'state',
|
||||||
'status',
|
'status',
|
||||||
|
'uptime',
|
||||||
|
'users',
|
||||||
'vcpus',
|
'vcpus',
|
||||||
'vcpus_used',
|
'vcpus_used',
|
||||||
)
|
)
|
||||||
@ -183,10 +187,12 @@ class TestHypervisorShow(TestHypervisor):
|
|||||||
50,
|
50,
|
||||||
1024,
|
1024,
|
||||||
'192.168.0.10',
|
'192.168.0.10',
|
||||||
|
'01:28:24',
|
||||||
self.hypervisor.hypervisor_hostname,
|
self.hypervisor.hypervisor_hostname,
|
||||||
'QEMU',
|
'QEMU',
|
||||||
2004001,
|
2004001,
|
||||||
self.hypervisor.id,
|
self.hypervisor.id,
|
||||||
|
'0.94, 0.62, 0.50',
|
||||||
50,
|
50,
|
||||||
0,
|
0,
|
||||||
1024,
|
1024,
|
||||||
@ -196,6 +202,8 @@ class TestHypervisorShow(TestHypervisor):
|
|||||||
1,
|
1,
|
||||||
'up',
|
'up',
|
||||||
'enabled',
|
'enabled',
|
||||||
|
'3 days, 11:15',
|
||||||
|
'1',
|
||||||
4,
|
4,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user