1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

routeros_facts: fix crash when ipv6 is disabled (#39)

* routeros_facts: fix crash when ipv6 is disabled

* chore: rename fixture file
This commit is contained in:
Egor Zaitsev 2020-03-27 10:10:42 +03:00 committed by GitHub
parent 5c372e0a7c
commit 4fba692c1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -289,6 +289,8 @@ class Interfaces(FactsBase):
def populate_ipv6_interfaces(self, data): def populate_ipv6_interfaces(self, data):
for key, value in iteritems(data): for key, value in iteritems(data):
if key is None:
break
if 'ipv6' not in self.facts['interfaces'][key]: if 'ipv6' not in self.facts['interfaces'][key]:
self.facts['interfaces'][key]['ipv6'] = list() self.facts['interfaces'][key]['ipv6'] = list()
addr, subnet = value['address'].split("/") addr, subnet = value['address'].split("/")

View file

@ -0,0 +1 @@
bad command name address (line 1 column 7)

View file

@ -107,3 +107,13 @@ class TestRouterosFactsModule(TestRouterosModule):
self.assertEqual( self.assertEqual(
len(result['ansible_facts']['ansible_net_neighbors'].keys()), 4 len(result['ansible_facts']['ansible_net_neighbors'].keys()), 4
) )
def test_routeros_facts_interfaces_no_ipv6(self):
fixture = load_fixture(
'routeros_facts/ipv6_address_print_detail_without-paging_no-ipv6'
)
interfaces = self.module.Interfaces(module=self.module)
addresses = interfaces.parse_addresses(data=fixture)
result = interfaces.populate_ipv6_interfaces(data=addresses)
self.assertEqual(result, None)