>>> import re
>>> ipv4_f = re.compile(str('10.1.1.1'))
>>> address1 = '10.1.1.1'
>>> address2 = '10.1.1.10'
>>> addresses = (address1, address2)
>>> for addr in addresses:
... if ipv4_f.match(addr):
... print 'match found on address: %s' % addr
...
match found on address: 10.1.1.1
match found on address: 10.1.1.10
>>>
Nova should probably just attempt to do an exact match and if none found, then do the regex match but rather than return the first match, return all matches.
The bug is actually in nova here:
https:/ /github. com/openstack/ nova/blob/ 3a2a181796664fe a7f6069d49f9cd3 67b8cff825/ nova/compute/ api.py# L2508
As demonstrated in this example:
>>> import re str('10. 1.1.1') )
>>> ipv4_f = re.compile(
>>> address1 = '10.1.1.1'
>>> address2 = '10.1.1.10'
>>> addresses = (address1, address2)
>>> for addr in addresses:
... if ipv4_f.match(addr):
... print 'match found on address: %s' % addr
...
match found on address: 10.1.1.1
match found on address: 10.1.1.10
>>>
Nova should probably just attempt to do an exact match and if none found, then do the regex match but rather than return the first match, return all matches.