Fix ipaddress issues in the infinidat driver

In python3.8.11 and python3.9.6, the behavior of the
ipaddress.ip_network.hosts() method changed. Now /32
addresses are returned by that method as a single
element list. This was apparently done as a bugfix [1]

Change-Id: Iab6d96351fa21131d834ccf07ffddd70555f25a7
Closes-Bug: #1934345
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
[1] https://bugs.python.org/issue27683
(cherry picked from commit 1161a56a74)
This commit is contained in:
Goutham Pacha Ravi 2021-07-01 09:01:55 -07:00
parent de8b5c3dc9
commit d015399af5
2 changed files with 7 additions and 1 deletions

View File

@ -330,7 +330,7 @@ class InfiniboxShareDriver(driver.ShareDriver):
# try treating the ip_address parameter as a range of IP addresses: # try treating the ip_address parameter as a range of IP addresses:
ip_network = ipaddress.ip_network(ip_address, strict=False) ip_network = ipaddress.ip_network(ip_address, strict=False)
ip_network_hosts = list(ip_network.hosts()) ip_network_hosts = list(ip_network.hosts())
if len(ip_network_hosts) == 0: # /32, single IP address if len(ip_network_hosts) < 2: # /32, single IP address
return ip_address.split('/')[0] return ip_address.split('/')[0]
return "{}-{}".format(ip_network_hosts[0], ip_network_hosts[-1]) return "{}-{}".format(ip_network_hosts[0], ip_network_hosts[-1])

View File

@ -0,0 +1,6 @@
---
fixes:
- |
The Infinidat driver's been fixed to process single IP Addresses (/32)
correctly. See `bug 1934345 <https://launchpad.net/bugs/1934345>`_ for
more details.