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

T6045: Recreate show lldp detail views & improve remote port selection #3590

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

talmakion
Copy link
Contributor

Change Summary

If the remote device has explicitly sent the interface name as the portID, we should use that first as the interface name, before working through the previous priority order.

I've brought back LLDP detail views by directly calling lldpcli. This can be extended to render a template from op_mode/lldp.py, but lldpcli isn't bad at rendering readable info. Raw mode (including detailed raw) is still accessible for programmatic access.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

  • op_mode

Proposed changes

Different NOSes and full blown OSes return interface information differently, making a proper universal selection on the "Remote Port" field difficult. It's a similar situation in net-snmp between ifName, ifAlias and ifDescr. However, we do get a type attribute for the PortID returned in LLDP (ref: https://github.com/lldpd/lldpd/blob/master/src/lib/atoms/port.c#L41), so if the remote explicitly says it's the interface name (eg, Cisco & HPE do), that's the interface name.

It will likely need some tweaking and testing, as I'm sure there are still vendors misusing the attribute, but it's a bit closer in the most common use cases from large vendors.

I started re-implementing a detail view in op_mode/lldp.py using some Cisco output samples as a template and calling in with --detail set for those tag branches from the XML. However - it's a decent bit of effort, source JSON is very flexible in structure depending on the devices found, we already have an competent renderer in lldpcli.

I can revisit this one to complete the re-rendering in lldp.py if that's the preferred way of doing things, but this should be a working implementation as-is.

How to test

vyos@TEST-VYOS-LEFT:~$ show lldp neighbors interface eth1 detail
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface:    eth1, via: LLDP, RID: 1, Time: 0 day, 03:02:43
  Chassis:     
    ChassisID:    mac bc:24:11:73:39:f8
    SysName:      TEST-VYOS-RIGHT
    SysDescr:     VyOS 1.5-rolling-202406020021
    MgmtIP:       9.9.9.10
    MgmtIface:    3
    MgmtIP:       fe80::200:ff:fe00:0
    MgmtIface:    1
    Capability:   Bridge, off
    Capability:   Router, on
    Capability:   Wlan, off
    Capability:   Station, off
  Port:        
    PortID:       mac bc:24:11:f3:ab:a8
    PortDescr:    eth1
    TTL:          120
  LLDP-MED:    
    Device Type:  Network Connectivity Device
    Capability:   Capabilities, yes
    Capability:   Policy, yes
    Capability:   Location, yes
    Capability:   MDI/PSE, yes
    Capability:   MDI/PD, yes
    Capability:   Inventory, yes
    Inventory:   
      Hardware Revision: pc-i440fx-8.1
      Software Revision: 6.6.32-amd64-vyos
      Firmware Revision: rel-1.16.2-0-gea1b7a073390-prebu
      Manufacturer: QEMU
      Model:        Standard PC (i440FX + PIIX, 1996
-------------------------------------------------------------------------------

and

vyos@TEST-VYOS-LEFT:~$ show lldp neighbors details 
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface:    eth1, via: LLDP, RID: 1, Time: 0 day, 03:02:49
  Chassis:     
    ChassisID:    mac bc:24:11:73:39:f8
    SysName:      TEST-VYOS-RIGHT
    SysDescr:     VyOS 1.5-rolling-202406020021
    MgmtIP:       9.9.9.10
    MgmtIface:    3
    MgmtIP:       fe80::200:ff:fe00:0
    MgmtIface:    1
    Capability:   Bridge, off
    Capability:   Router, on
    Capability:   Wlan, off
    Capability:   Station, off
  Port:        
    PortID:       mac bc:24:11:f3:ab:a8
    PortDescr:    eth1
    TTL:          120
  LLDP-MED:    
    Device Type:  Network Connectivity Device
    Capability:   Capabilities, yes
    Capability:   Policy, yes
    Capability:   Location, yes
    Capability:   MDI/PSE, yes
    Capability:   MDI/PD, yes
    Capability:   Inventory, yes
    Inventory:   
      Hardware Revision: pc-i440fx-8.1
      Software Revision: 6.6.32-amd64-vyos
      Firmware Revision: rel-1.16.2-0-gea1b7a073390-prebu
      Manufacturer: QEMU
      Model:        Standard PC (i440FX + PIIX, 1996
-------------------------------------------------------------------------------

Smoketest result

There doesn't appear to be a smoketest for op-mode schema changes.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

<properties>
<help>Show extended detail for LLDP neighbors</help>
</properties>
<command>/usr/sbin/lldpcli show neighbors detail</command>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use lldp.py which should show data in the formatted or raw format.

<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>/usr/sbin/lldpcli show neighbors ports $5 detail</command>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use lldp.py which should show data in the formatted or raw format.

@@ -13,6 +13,12 @@
</properties>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors</command>
<children>
<node name="details">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use detail

@talmakion
Copy link
Contributor Author

Apologies - didn't realise wrapping opmode commands in Python was a hard requirement, I added a commit to fix that and the "details" => "detail" change.

The existing op_mode/lldp.py code already dealt with detail raw-mode, it just didn't expose this in the XML or handle it properly to output a plain text view.

Let me know if this solution still isn't suitable.

@talmakion
Copy link
Contributor Author

Squashed the fixup commits and rebased on current.

If the remote device has explicitly sent the interface name as the portID,
we should use that first as the interface name, before working through
the previous priority order.

I've brought back LLDP detail views directly calling lldpcli. This can be
extended to render a template from op_mode/lldp.py, but lldpcli isn't bad
at rendering readable info. Raw mode (including detailed raw) is still
accessible for programmatic access.
Copy link

👍
No issues in PR Title / Commit Title

@sever-sever
Copy link
Member

Looks good:

vyos@r4:~$ show lldp neighbors detail 
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface:    eth0, via: LLDP, RID: 2, Time: 0 day, 00:00:17
  Chassis:     
    ChassisID:    mac 52:54:00:0c:6c:1d
    SysName:      r16
    SysDescr:     VyOS 1.5-rolling-202406130020
    MgmtIP:       192.168.122.16
    MgmtIface:    2
    MgmtIP:       fe80::200:ff:fe00:0
    MgmtIface:    1
    Capability:   Bridge, off
    Capability:   Router, on
    Capability:   Wlan, off
    Capability:   Station, off
  Port:        
    PortID:       ifname eth0
    PortDescr:    WAN
    TTL:          120
  LLDP-MED:    
    Device Type:  Network Connectivity Device
    Capability:   Capabilities, yes
    Capability:   Policy, yes
    Capability:   Location, yes
    Capability:   MDI/PSE, yes
    Capability:   MDI/PD, yes
    Capability:   Inventory, yes
    Inventory:   
      Hardware Revision: pc-q35-6.2
      Software Revision: 6.6.33-amd64-vyos
      Firmware Revision: 1.15.0-1
      Manufacturer: QEMU
      Model:        Standard PC (Q35 + ICH9, 2009)
-------------------------------------------------------------------------------
vyos@r4:~$  
vyos@r4:~$ /usr/libexec/vyos/op_mode/lldp.py show_neighbors --detail --raw
{
    "lldp": {
        "interface": {
            "eth0": {
                "via": "LLDP",
                "rid": "2",
                "age": "0 day, 00:00:25",
                "chassis": {
                    "r16": {
                        "id": {
                            "type": "mac",
                            "value": "52:54:00:0c:6c:1d"
                        },
                        "descr": "VyOS 1.5-rolling-202406130020",
                        "mgmt_ip": [
                            "192.168.122.16",
                            "fe80::200:ff:fe00:0"
                        ],
                        "mgmt_iface": [
                            "2",
                            "1"
                        ],
                        "capability": [
                            {
                                "type": "Bridge",
                                "enabled": false
                            },
                            {
                                "type": "Router",
                                "enabled": true
                            },
                            {
                                "type": "Wlan",
                                "enabled": false
                            },
                            {
                                "type": "Station",
                                "enabled": false
                            }
                        ]
                    }
                },
                "port": {
                    "id": {
                        "type": "ifname",
                        "value": "eth0"
                    },
                    "descr": "WAN",
                    "ttl": "120"
                },
                "lldp_med": {
                    "device_type": "Network Connectivity Device",
                    "capability": [
                        {
                            "type": "Capabilities",
                            "available": true
                        },
                        {
                            "type": "Policy",
                            "available": true
                        },
                        {
                            "type": "Location",
                            "available": true
                        },
                        {
                            "type": "MDI/PSE",
                            "available": true
                        },
                        {
                            "type": "MDI/PD",
                            "available": true
                        },
                        {
                            "type": "Inventory",
                            "available": true
                        }
                    ],
                    "inventory": {
                        "hardware": "pc-q35-6.2",
                        "software": "6.6.33-amd64-vyos",
                        "firmware": "1.15.0-1",
                        "manufacturer": "QEMU",
                        "model": "Standard PC (Q35 + ICH9, 2009)"
                    }
                }
            }
        }
    }
}
vyos@r4:~$ 

@dmbaturin dmbaturin merged commit c4269a9 into vyos:current Jun 13, 2024
8 checks passed
@talmakion talmakion deleted the feature/T6045 branch June 13, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants