ipaddr filter - return a network address when given an address with /32 subnet (#47539)
* fix #17872 * add changelog fragment and enable unit test
This commit is contained in:
parent
6ec820e264
commit
15e77ebfe8
3 changed files with 11 additions and 11 deletions
2
changelogs/fragments/47539-fix-netaddr-network.yaml
Normal file
2
changelogs/fragments/47539-fix-netaddr-network.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- ipaddr - fix issue where network address was blank for 0-size networks (https://github.com/ansible/ansible/issues/17872)
|
|
@ -249,8 +249,7 @@ def _netmask_query(v):
|
|||
|
||||
def _network_query(v):
|
||||
'''Return the network of a given IP or subnet'''
|
||||
if v.size > 1:
|
||||
return str(v.network)
|
||||
return str(v.network)
|
||||
|
||||
|
||||
def _network_id_query(v):
|
||||
|
|
|
@ -38,15 +38,14 @@ class TestIpFilter(unittest.TestCase):
|
|||
self.assertEqual(ipaddr(address, 'netmask'), '255.255.255.255')
|
||||
|
||||
def test_network(self):
|
||||
# Unfixable in current state
|
||||
# address = '1.12.1.34/32'
|
||||
# self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
# address = '1.12.1.34/255.255.255.255'
|
||||
# self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
# address = '1.12.1.34'
|
||||
# self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
# address = '1.12.1.35/31'
|
||||
# self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
address = '1.12.1.34/32'
|
||||
self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
address = '1.12.1.34/255.255.255.255'
|
||||
self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
address = '1.12.1.34'
|
||||
self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
address = '1.12.1.35/31'
|
||||
self.assertEqual(ipaddr(address, 'network'), '1.12.1.34')
|
||||
address = '1.12.1.34/24'
|
||||
self.assertEqual(ipaddr(address, 'network'), '1.12.1.0')
|
||||
|
||||
|
|
Loading…
Reference in a new issue