Merge "Fix regular expression for uptime in hypervisor show"

This commit is contained in:
Jenkins 2016-09-12 20:25:45 +00:00 committed by Gerrit Code Review
commit d5a011216e
2 changed files with 11 additions and 2 deletions

View File

@ -98,8 +98,9 @@ class ShowHypervisor(command.ShowOne):
# 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'])
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)

View File

@ -159,10 +159,12 @@ class TestHypervisorShow(TestHypervisor):
'free_disk_gb',
'free_ram_mb',
'host_ip',
'host_time',
'hypervisor_hostname',
'hypervisor_type',
'hypervisor_version',
'id',
'load_average',
'local_gb',
'local_gb_used',
'memory_mb',
@ -172,6 +174,8 @@ class TestHypervisorShow(TestHypervisor):
'service_id',
'state',
'status',
'uptime',
'users',
'vcpus',
'vcpus_used',
)
@ -183,10 +187,12 @@ class TestHypervisorShow(TestHypervisor):
50,
1024,
'192.168.0.10',
'01:28:24',
self.hypervisor.hypervisor_hostname,
'QEMU',
2004001,
self.hypervisor.id,
'0.94, 0.62, 0.50',
50,
0,
1024,
@ -196,6 +202,8 @@ class TestHypervisorShow(TestHypervisor):
1,
'up',
'enabled',
'3 days, 11:15',
'1',
4,
0,
)