From d6f99b721d3e3978fd6a5438bdacefd5840d3b02 Mon Sep 17 00:00:00 2001 From: Hironori Shiina Date: Thu, 11 Aug 2016 00:02:29 +0900 Subject: 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 --- openstackclient/compute/v2/hypervisor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'openstackclient/compute') diff --git a/openstackclient/compute/v2/hypervisor.py b/openstackclient/compute/v2/hypervisor.py index 00625050..f9051919 100644 --- a/openstackclient/compute/v2/hypervisor.py +++ b/openstackclient/compute/v2/hypervisor.py @@ -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) -- cgit v1.2.1