Check if lldpctl present, and log debug if no lldpctl output.

This commit is contained in:
Cyril Levis 2020-10-01 13:27:34 +02:00
commit 3ac3a69cf1
No known key found for this signature in database
GPG key ID: 8538D68543979A20

View file

@ -1,8 +1,12 @@
import subprocess import subprocess
import logging
from netbox_agent.misc import is_tool
class LLDP(): class LLDP():
def __init__(self, output=None): def __init__(self, output=None):
if not is_tool('lldpctl'):
logging.debug('lldpd package seems to be missing or daemon not running.')
if output: if output:
self.output = output self.output = output
else: else:
@ -40,6 +44,8 @@ class LLDP():
current_dict[final] = value current_dict[final] = value
for interface, vlan in vlans.items(): for interface, vlan in vlans.items():
output_dict['lldp'][interface]['vlan'] = vlan output_dict['lldp'][interface]['vlan'] = vlan
if not output_dict:
logging.debug('No LLDP output, please check your network config.')
return output_dict return output_dict
def get_switch_ip(self, interface): def get_switch_ip(self, interface):