From 43310bb7b7c85f941ec43d5604f1e5c04c9f64a4 Mon Sep 17 00:00:00 2001 From: Dhivyap Date: Fri, 24 Mar 2017 08:36:26 +0530 Subject: [PATCH] Fixes#21557-Handled dellos9_facts crash with IPV6 configs (#21652) (cherry picked from commit cd662efd2bf686ae559174fb247e33f13e05c90a) --- .../modules/network/dellos9/dellos9_facts.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/network/dellos9/dellos9_facts.py b/lib/ansible/modules/network/dellos9/dellos9_facts.py index 8fed100947c..f84fafa6fdc 100644 --- a/lib/ansible/modules/network/dellos9/dellos9_facts.py +++ b/lib/ansible/modules/network/dellos9/dellos9_facts.py @@ -309,13 +309,14 @@ class Interfaces(FactsBase): def populate_ipv6_interfaces(self, data): for key, value in data.items(): - self.facts['interfaces'][key]['ipv6'] = list() - addresses = re.findall(r'\s+(.+), subnet', value, re.M) - subnets = re.findall(r', subnet is (\S+)', value, re.M) - for addr, subnet in itertools.izip(addresses, subnets): - ipv6 = dict(address=addr.strip(), subnet=subnet.strip()) - self.add_ip_address(addr.strip(), 'ipv6') - self.facts['interfaces'][key]['ipv6'].append(ipv6) + if key in self.facts['interfaces']: + self.facts['interfaces'][key]['ipv6'] = list() + addresses = re.findall(r'\s+(.+), subnet', value, re.M) + subnets = re.findall(r', subnet is (\S+)', value, re.M) + for addr, subnet in itertools.izip(addresses, subnets): + ipv6 = dict(address=addr.strip(), subnet=subnet.strip()) + self.add_ip_address(addr.strip(), 'ipv6') + self.facts['interfaces'][key]['ipv6'].append(ipv6) def add_ip_address(self, address, family): if family == 'ipv4':