From 98f804ecb44278628070829bd1841ca51476f7b9 Mon Sep 17 00:00:00 2001 From: chifu1234 Date: Tue, 6 Feb 2018 15:10:12 +0100 Subject: [PATCH] nxos_facts: svi support ipv4 (#35222) * nxos_facts: svi support ipv4 * nxos_facts: copy paste error * https://app.shippable.com/github/ansible/ansible/runs/51845/1/tests * E111 indentation is not a multiple of four * Update nxos_facts.py --- .../modules/network/nxos/nxos_facts.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index 88ddbd1923..b4a8ddfe8f 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -273,11 +273,24 @@ class Interfaces(FactsBase): ('eth_hw_desc', 'type') ]) + INTERFACE_SVI_MAP = frozenset([ + ('svi_line_proto', 'state'), + ('svi_bw', 'bandwidth'), + ('svi_mac', 'macaddress'), + ('svi_mtu', 'mtu'), + ('type', 'type') + ]) + INTERFACE_IPV4_MAP = frozenset([ ('eth_ip_addr', 'address'), ('eth_ip_mask', 'masklen') ]) + INTERFACE_SVI_IPV4_MAP = frozenset([ + ('svi_ip_addr', 'address'), + ('svi_ip_mask', 'masklen') + ]) + INTERFACE_IPV6_MAP = frozenset([ ('addr', 'address'), ('prefix', 'subnet') @@ -318,12 +331,19 @@ class Interfaces(FactsBase): name = item['interface'] intf = dict() - intf.update(self.transform_dict(item, self.INTERFACE_MAP)) + if 'type' in item: + intf.update(self.transform_dict(item, self.INTERFACE_SVI_MAP)) + else: + intf.update(self.transform_dict(item, self.INTERFACE_MAP)) if 'eth_ip_addr' in item: intf['ipv4'] = self.transform_dict(item, self.INTERFACE_IPV4_MAP) self.facts['all_ipv4_addresses'].append(item['eth_ip_addr']) + if 'svi_ip_addr' in item: + intf['ipv4'] = self.transform_dict(item, self.INTERFACE_SVI_IPV4_MAP) + self.facts['all_ipv4_addresses'].append(item['svi_ip_addr']) + interfaces[name] = intf return interfaces