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
This commit is contained in:
chifu1234 2018-02-06 15:10:12 +01:00 committed by Trishna Guha
parent 48005da645
commit 98f804ecb4

View file

@ -273,11 +273,24 @@ class Interfaces(FactsBase):
('eth_hw_desc', 'type') ('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([ INTERFACE_IPV4_MAP = frozenset([
('eth_ip_addr', 'address'), ('eth_ip_addr', 'address'),
('eth_ip_mask', 'masklen') ('eth_ip_mask', 'masklen')
]) ])
INTERFACE_SVI_IPV4_MAP = frozenset([
('svi_ip_addr', 'address'),
('svi_ip_mask', 'masklen')
])
INTERFACE_IPV6_MAP = frozenset([ INTERFACE_IPV6_MAP = frozenset([
('addr', 'address'), ('addr', 'address'),
('prefix', 'subnet') ('prefix', 'subnet')
@ -318,12 +331,19 @@ class Interfaces(FactsBase):
name = item['interface'] name = item['interface']
intf = dict() intf = dict()
if 'type' in item:
intf.update(self.transform_dict(item, self.INTERFACE_SVI_MAP))
else:
intf.update(self.transform_dict(item, self.INTERFACE_MAP)) intf.update(self.transform_dict(item, self.INTERFACE_MAP))
if 'eth_ip_addr' in item: if 'eth_ip_addr' in item:
intf['ipv4'] = self.transform_dict(item, self.INTERFACE_IPV4_MAP) intf['ipv4'] = self.transform_dict(item, self.INTERFACE_IPV4_MAP)
self.facts['all_ipv4_addresses'].append(item['eth_ip_addr']) 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 interfaces[name] = intf
return interfaces return interfaces