tag_start(w, "interface", "Interface");
tag_attr(w, "name", "",
lldpctl_atom_get_str(iface, lldpctl_k_interface_name));
- tag_attr(w, "via" , "via",
- lldpctl_atom_get_str(port, lldpctl_k_port_protocol));
- if (details > DISPLAY_BRIEF) {
- if (!local)
+ if (!local) {
+ tag_attr(w, "via" , "via",
+ lldpctl_atom_get_str(port, lldpctl_k_port_protocol));
+ if (details > DISPLAY_BRIEF) {
tag_attr(w, "rid" , "RID",
lldpctl_atom_get_str(chassis, lldpctl_k_chassis_index));
- tag_attr(w, "age" , "Time",
- display_age(lldpctl_atom_get_int(port, lldpctl_k_port_age)));
- }
- if (local) {
+ tag_attr(w, "age" , "Time",
+ display_age(lldpctl_atom_get_int(port, lldpctl_k_port_age)));
+ }
+ } else {
tag_datatag(w, "status", "Administrative status",
lldpctl_atom_get_str(port, lldpctl_k_port_status));
}
out = lldpcli("-f", "keyvalue", "show", "interfaces")
assert out['lldp.eth0.chassis.descr'].startswith(
"Spectacular GNU/Linux 2016 Linux")
- assert 'lldp.eth0.age' in out
assert 'lldp.eth0.chassis.Router.enabled' in out
assert 'lldp.eth0.chassis.Station.enabled' in out
- del out['lldp.eth0.age']
del out['lldp.eth0.chassis.descr']
del out['lldp.eth0.chassis.Router.enabled']
del out['lldp.eth0.chassis.Station.enabled']
"""-------------------------------------------------------------------------------
LLDP interfaces:
-------------------------------------------------------------------------------
-Interface: eth0, via: unknown, Time: {time}
+Interface: eth0
+ Administrative status: RX and TX
Chassis:
ChassisID: mac 00:00:00:00:00:01
SysName: ns-1.example.com
dot3 = ""
out = result.stdout.decode('ascii')
- time = re.search(r'^Interface: .*Time: (.*)$',
- out,
- re.MULTILINE).group(1)
- seconds = re.search(r'^Interface: .*(\d\d)$',
- out,
- re.MULTILINE).group(1)
+ if command == "neighbors":
+ time = re.search(r'^Interface: .*Time: (.*)$',
+ out,
+ re.MULTILINE).group(1)
+ seconds = re.search(r'^Interface: .*(\d\d)$',
+ out,
+ re.MULTILINE).group(1)
+ else:
+ time = None
+ seconds = None
router = re.search(r'^ Capability: Router, (.*)$',
out,
re.MULTILINE).group(1)
{"lldp": {
"interface": {
"eth0": {
- "via": "unknown",
+ "status": "RX and TX",
"chassis": {
"ns-1.example.com": {
"id": {
eth0 = j['lldp']['interface']['eth0']
name = next(k for k,v in eth0['chassis'].items() if k.startswith('ns'))
- del eth0['age']
+ if command == "neighbors":
+ del eth0['age']
del eth0['chassis'][name]['capability'][3]
del eth0['chassis'][name]['capability'][1]
{"lldp": [{
"interface": [{
"name": "eth0",
- "via": "unknown",
+ "status": [{
+ "value": "RX and TX",
+ }],
"chassis": [{
"id": [{
"type": "mac",
j = json.loads(out)
eth0 = j['lldp'][0]['interface'][0]
- del eth0['age']
+ if command == "neighbors":
+ del eth0['age']
del eth0['chassis'][0]['capability'][3]
del eth0['chassis'][0]['capability'][1]
("interfaces",
"""<?xml version="1.0" encoding="UTF-8"?>
<lldp label="LLDP interfaces">
- <interface label="Interface" name="eth0" via="unknown" age="{age}">
+ <interface label="Interface" name="eth0">
+ <status label="Administrative status">RX and TX</status>
<chassis label="Chassis">
<id label="ChassisID" type="mac">00:00:00:00:00:01</id>
<name label="SysName">ns-1.example.com</name>
out = result.stdout.decode('ascii')
xml = ET.fromstring(out)
- age = xml.findall('./interface[1]')[0].attrib['age']
+ if command == "neighbors":
+ age = xml.findall('./interface[1]')[0].attrib['age']
+ else:
+ age = None
router = xml.findall("./interface[1]/chassis/"
"capability[@type='Router']")[0].attrib['enabled']
station = xml.findall("./interface[1]/chassis/"