summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-08-28 02:42:06 +0000
committerGerrit Code Review <review@openstack.org>2019-08-28 02:42:06 +0000
commitfd63a909a8247775d474521007546785566af13a (patch)
tree901e582e56aa9e86d3e2a338d9138e682308e83e /openstackclient/compute/v2
parentc9cc8b0ae2ebb14ba2893057c2388764b60aeb11 (diff)
parent6419533f436c6c369e05662c6ced26ad0bc68240 (diff)
downloadpython-openstackclient-fd63a909a8247775d474521007546785566af13a.tar.gz
Merge "Bump hacking version"
Diffstat (limited to 'openstackclient/compute/v2')
-rw-r--r--openstackclient/compute/v2/hypervisor.py2
-rw-r--r--openstackclient/compute/v2/server.py58
2 files changed, 30 insertions, 30 deletions
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 493fd5ad..9ba91812 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):