From 6419533f436c6c369e05662c6ced26ad0bc68240 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 14 Jun 2019 11:51:52 +0100 Subject: Bump hacking version Pick up newer versions of this library. Thankfully no serious changes are needed. Change-Id: I69e523844529fc1c8aa0c1ce764182dbe29cfeb6 Signed-off-by: Stephen Finucane --- openstackclient/compute/v2/hypervisor.py | 2 +- openstackclient/compute/v2/server.py | 58 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'openstackclient/compute/v2') diff --git a/openstackclient/compute/v2/hypervisor.py b/openstackclient/compute/v2/hypervisor.py index 406aa917..0d367fee 100644 --- a/openstackclient/compute/v2/hypervisor.py +++ b/openstackclient/compute/v2/hypervisor.py @@ -112,7 +112,7 @@ class ShowHypervisor(command.ShowOne): # 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(.+)", + r"\s*(.+)\sup\s+(.+),\s+(.+)\susers?,\s+load average:\s(.+)", uptime['uptime']) if m: hypervisor["host_time"] = m.group(1) diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 95c2f28a..5922dc50 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -79,37 +79,37 @@ def _format_servers_list_power_state(state): def _get_ip_address(addresses, address_type, ip_address_family): - # Old style addresses - if address_type in addresses: - for addy in addresses[address_type]: + # Old style addresses + if address_type in addresses: + for addy in addresses[address_type]: + if int(addy['version']) in ip_address_family: + return addy['addr'] + + # New style addresses + new_address_type = address_type + if address_type == 'public': + new_address_type = 'floating' + if address_type == 'private': + new_address_type = 'fixed' + for network in addresses: + for addy in addresses[network]: + # Case where it is list of strings + if isinstance(addy, six.string_types): + if new_address_type == 'fixed': + return addresses[network][0] + else: + return addresses[network][-1] + # Case where it is a dict + if 'OS-EXT-IPS:type' not in addy: + continue + if addy['OS-EXT-IPS:type'] == new_address_type: if int(addy['version']) in ip_address_family: return addy['addr'] - - # New style addresses - new_address_type = address_type - if address_type == 'public': - new_address_type = 'floating' - if address_type == 'private': - new_address_type = 'fixed' - for network in addresses: - for addy in addresses[network]: - # Case where it is list of strings - if isinstance(addy, six.string_types): - if new_address_type == 'fixed': - return addresses[network][0] - else: - return addresses[network][-1] - # Case where it is a dict - if 'OS-EXT-IPS:type' not in addy: - continue - if addy['OS-EXT-IPS:type'] == new_address_type: - if int(addy['version']) in ip_address_family: - return addy['addr'] - msg = _("ERROR: No %(type)s IP version %(family)s address found") - raise exceptions.CommandError( - msg % {"type": address_type, - "family": ip_address_family} - ) + msg = _("ERROR: No %(type)s IP version %(family)s address found") + raise exceptions.CommandError( + msg % {"type": address_type, + "family": ip_address_family} + ) def _prefix_checked_value(prefix): -- cgit v1.2.1