]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: don't show age/via for local interfaces feature/show-port-config
authorVincent Bernat <vincent@bernat.ch>
Mon, 1 Mar 2021 08:21:10 +0000 (09:21 +0100)
committerVincent Bernat <vincent@bernat.ch>
Mon, 1 Mar 2021 09:01:01 +0000 (10:01 +0100)
NEWS
src/client/display.c
tests/integration/test_basic.py
tests/integration/test_lldpcli.py

diff --git a/NEWS b/NEWS
index 14d7893403e0727da21158a8f5e93df1156e6154..dc995ab075431a5fdb9245a4be3bcb477e0869f3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ lldpd (1.0.9)
     + Do not use interface alias if we set it ourselves.
   * Changes:
     + Display port status with "show interfaces".
+    + Do not display "age" and "via" when using "show interfaces".
 
 lldpd (1.0.8)
   * Fix:
index ab2061404c364b613ed9ece12244d10fe5ea4aea..7bbe549c826c3193b79f007e45bda3b6fe1a73f3 100644 (file)
@@ -717,16 +717,16 @@ display_interface(lldpctl_conn_t *conn, struct writer *w, int hidden,
        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));
        }
index a470c7f632fadacad567ddb42b64da1d629040fe..4a9459ff65c976c0ae6502300948eb91dcdc61c7 100644 (file)
@@ -55,10 +55,8 @@ def test_one_interface(lldpd1, lldpd, lldpcli, namespaces):
         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']
index 1d1da2e82f921154e9b0fb200a9f6a24a86d39ad..e6cde3d2e8b6668e7050d3097d252726c39c38a4 100644 (file)
@@ -47,7 +47,8 @@ Interface:    eth0, via: LLDP, RID: 1, Time: 0 day, 00:00:{seconds}
      """-------------------------------------------------------------------------------
 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
@@ -82,12 +83,16 @@ def test_text_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
             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)
@@ -132,7 +137,7 @@ def test_text_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
      {"lldp": {
         "interface": {
           "eth0": {
-            "via": "unknown",
+            "status": "RX and TX",
             "chassis": {
               "ns-1.example.com": {
                 "id": {
@@ -164,7 +169,8 @@ def test_json_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
 
         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]
 
@@ -217,7 +223,9 @@ def test_json_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
      {"lldp": [{
             "interface": [{
                 "name": "eth0",
-                "via": "unknown",
+                "status": [{
+                    "value": "RX and TX",
+                }],
                 "chassis": [{
                     "id": [{
                         "type": "mac",
@@ -254,7 +262,8 @@ def test_json0_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
         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]
 
@@ -300,7 +309,8 @@ def test_json0_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
 ("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>
@@ -331,7 +341,10 @@ def test_xml_output(request, lldpd1, lldpd, lldpcli, namespaces, uname,
         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/"