Fix for vdc with no interface in N7K

Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
             https://github.com/NilashishC
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>

Add changelog

Co-authored-by: praveenramoorthy <62758226+praveenramoorthy@users.noreply.github.com>
pull/70125/head
Nilashish Chakraborty 5 years ago committed by GitHub
parent 7f31a7a488
commit dec1953cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
---
bugfixes:
- Fix nxos_facts with VDC having no interfaces (https://github.com/ansible-collections/cisco.nxos/pull/68).

@ -252,7 +252,12 @@ class Interfaces(FactsBase):
def populate_structured_interfaces(self, data): def populate_structured_interfaces(self, data):
interfaces = dict() interfaces = dict()
for item in data['TABLE_interface']['ROW_interface']: data = data["TABLE_interface"]["ROW_interface"]
if isinstance(data, dict):
data = [data]
for item in data:
name = item['interface'] name = item['interface']
intf = dict() intf = dict()
@ -604,8 +609,12 @@ class Legacy(FactsBase):
def parse_structured_interfaces(self, data): def parse_structured_interfaces(self, data):
objects = list() objects = list()
for item in data['TABLE_interface']['ROW_interface']: data = data["TABLE_interface"]["ROW_interface"]
objects.append(item['interface']) if isinstance(data, dict):
objects.append(data["interface"])
elif isinstance(data, list):
for item in data:
objects.append(item["interface"])
return objects return objects
def parse_structured_vlans(self, data): def parse_structured_vlans(self, data):

Loading…
Cancel
Save