Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #463. Expose LLDP neighbors on EthernetInterface #464

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions panos/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,41 @@ def set_vlan(
False,
)

def get_lldp_neighbors(self):
"""Pull the LLDP neighbors for an interface

Returns:
list of dicts with keys ['chassis-type', 'chassis-id', 'port-type',
'port-id', 'port-description', 'ttl',
'system-name', 'system-description',
'system-capabilities',
'enabled-capabilities',
]

"""
from pan.config import PanConfig
if not self.lldp_enabled:
logger.debug("not fetching lldp neighbors from %s as lldp is not enabled", self.name)
return []

device = self.nearest_pandevice()
cmd = 'show lldp neighbors "{0}"'.format(self.name)
pconf = device.op(cmd)
pconf = PanConfig(pconf)
response = pconf.python()
logger.debug("response: " + str(response))
neighbors = response["response"]["result"]["entry"][0].get("neighbors")

if neighbors is None:
return []

for e in entries:
e.pop("name", None)
e.pop("management-address", None)

return neighbors["entry"]


def get_counters(self):
"""Pull the counters for an interface

Expand Down