nxos_facts: cdp support (#31202)

* nxos_facts get CPD neighbor

* nxos_fact: cdp support

* remove blank spaces

* add ansible_net_neighbors cdp informations
pull/25612/merge
chifu1234 7 years ago committed by Chris Alfonso
parent af0d42885d
commit e2fef7beed

@ -128,7 +128,7 @@ ansible_net_interfaces:
returned: when interfaces is configured
type: dict
ansible_net_neighbors:
description: The list of LLDP neighbors from the remote device
description: The list of LLDP/CDP neighbors from the remote device
returned: when interfaces is configured
type: dict
@ -297,6 +297,10 @@ class Interfaces(FactsBase):
if data:
self.facts['neighbors'] = self.populate_neighbors(data)
data = self.run('show cdp neighbors detail', 'json')
if data:
self.facts['neighbors'] = self.populate_neighbors_cdp(data)
def populate_interfaces(self, data):
interfaces = dict()
for item in data['TABLE_interface']['ROW_interface']:
@ -347,6 +351,23 @@ class Interfaces(FactsBase):
return objects
def populate_neighbors_cdp(self, data):
objects = dict()
data = data['TABLE_cdp_neighbor_detail_info']['ROW_cdp_neighbor_detail_info']
if isinstance(data, dict):
data = [data]
for item in data:
local_intf = item['intf_id']
objects[local_intf] = list()
nbor = dict()
nbor['port'] = item['port_id']
nbor['sysname'] = item['device_id']
objects[local_intf].append(nbor)
return objects
def parse_ipv6_interfaces(self, data):
try:
data = data['TABLE_intf']

Loading…
Cancel
Save