Juniper / py-junos-eznc

Python library for Junos automation
https://www.juniper.net/documentation/en_US/junos-pyez/information-products/pathway-pages/junos-pyez-developer-guide.html
Apache License 2.0
668 stars 342 forks source link

Add LLDPNeighborDetailTable to /op/lldp.yml using <get-lldp-neighbors-detail-information> #1239

Open cronicded opened 1 year ago

cronicded commented 1 year ago
Request:

Include in /op/lldp.yml an LLDPNeighborDetailView table making the <get-lldp-neighbors-detail-information> call to ensure <lldp-remote-port-id> available on varied JunOS hardware platforms.

PROBLEM Description:

EX Platform does not return <lldp-remote-port-id>. Inconsistent RPC returns between hardware for the RPC call <get-lldp-neighbors-information>. MX does not return and does not have a <get-lldp-neighbors-detail-information> call.

This issue is being specifically opened for the EX as required/expected data is available in <get-lldp-neighbor-detail-information>.

EXPECTED Behavior

/op/lldp.yml to return <lldp-remote-port-id> and <lldp-remote-system-id> from a <get-lldp-neighbors-information> call.

ACTUAL Behavior

For EX platforms the RPC:

user@host1> show lldp neighbors | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.2R0/junos">
    <rpc>
        <get-lldp-neighbors-information>
        </get-lldp-neighbors-information>
    </rpc>
    <cli>
        <banner>{master:0}</banner>
    </cli>
</rpc-reply>

Does not return <lldp-remote-port-id>:

user@host1> show lldp neighbors | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.2R0/junos">
    <lldp-neighbors-information junos:style="brief">
        <lldp-neighbor-information>
            <lldp-local-port-id>ge-0/0/27</lldp-local-port-id>
            <lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
            <lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
            <lldp-remote-chassis-id>bb:cc:dd:ee:ff:aa</lldp-remote-chassis-id>
            <lldp-remote-port-description>eth0</lldp-remote-port-description>
            <lldp-remote-system-name>host3</lldp-remote-system-name>
        </lldp-neighbor-information>
        ...

MX platform the RPC:

user@host2> show lldp neighbors | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/18.2R3/junos">
    <rpc>
        <get-lldp-neighbors-information>
        </get-lldp-neighbors-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

Does not return <lldp-remote-system-name>:

user@host2> show lldp neighbors | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/18.2R3/junos">
    <lldp-neighbors-information junos:style="brief">
        <lldp-neighbor-information>
            <lldp-local-port-id>xe-0/1/5</lldp-local-port-id>
            <lldp-local-parent-interface-name>ae0</lldp-local-parent-interface-name>
            <lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
            <lldp-remote-chassis-id>aa:bb:cc:dd:ee:ff</lldp-remote-chassis-id>
            <lldp-remote-port-id-subtype>Interface name</lldp-remote-port-id-subtype>
            <lldp-remote-port-id>TenGigabitEthernet 0/28</lldp-remote-port-id>
        </lldp-neighbor-information>
        ...
ADDITIONAL INFO:

Discovered this using the [junipernetworks.junos] collection for ansible to populate cable terminations in netbox. remote_port_id returns null/None when using the following play on EX platforms and returns null/None for remote_sysname on MX platforms using the [juniper_junos_table] module:

    - name: Get LLDP neighbors using table/views
      juniper_junos_table:
        table: "LLDPNeighborTable"
        file: "lldp.yml"
      register: lldp_results

There is an inconsistency between EX and MX platforms. MX does not include [show lldp neighbors detail]. Interestingly, <lldp-remote-system-name> is missing from the MX rpc return. Tested on multiple JunOS versions [15.x to JTAC 20.x-Ry on both platforms].

Similar / related to https://github.com/Juniper/py-junos-eznc/pull/645 but this lack of information was mentioned in https://github.com/Juniper/py-junos-eznc/issues/474#issuecomment-385984771

cronicded commented 1 year ago

I did not look into or investigate if there is a switch/knob for changing the RPC output of junos:style="detail" to ="brief" etc., or if it is possible/relevant when making the current <get-lldp-neighbor-information> for either platform.

Sample output of the requested call in case an EX is not available for testing/review for building the table:

{master:0}
user@host1> show lldp neighbors detail | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.2R0/junos">
    <lldp-neighbors-information xmlns="http://xml.juniper.net/junos/20.2R0/lldp-mtx" junos:style="detail">
        <lldp-neighbor-information>
            <lldp-index>151</lldp-index>
            <lldp-ttl>120</lldp-ttl>
            <lldp-timemark>Tue Feb 28 23:13:26 2023</lldp-timemark>
            <lldp-age>10</lldp-age>
            <lldp-local-interface>ge-0/0/27</lldp-local-interface>
            <lldp-local-parent-interface-name>-</lldp-local-parent-interface-name>
            <lldp-local-port-id>541</lldp-local-port-id>
            <lldp-local-port-ageout-count>0</lldp-local-port-ageout-count>
            <lldp-remote-chassis-id-subtype>Mac address</lldp-remote-chassis-id-subtype>
            <lldp-remote-chassis-id>aa:bb:cc:dd:ee:ff</lldp-remote-chassis-id>
            <lldp-remote-port-id-subtype>Mac address</lldp-remote-port-id-subtype>
            <lldp-remote-port-id>aa:bb:c0:dd:ee:ff</lldp-remote-port-id>
            <lldp-remote-port-description>eth0</lldp-remote-port-description>
            <lldp-remote-system-name>host2</lldp-remote-system-name>
            <lldp-system-description>
                <lldp-remote-system-description>Some Information about the remote system OS/Versions</lldp-remote-system-description>
            </lldp-system-description>
            <lldp-remote-system-capabilities-supported>Bridge WLAN Access Point Router </lldp-remote-system-capabilities-supported>
            <lldp-remote-system-capabilities-enabled>Bridge WLAN Access Point Router </lldp-remote-system-capabilities-enabled>
            <lldp-remote-management-address-type>IPv4(1)</lldp-remote-management-address-type>
            <lldp-remote-management-address>10.10.10.10</lldp-remote-management-address>
            <lldp-remote-management-address-port-id>0</lldp-remote-management-address-port-id>
            <lldp-remote-management-address-interface-subtype>Unknown(1)</lldp-remote-management-address-interface-subtype>
            <lldp-remote-management-addr-oid></lldp-remote-management-addr-oid>
            <lldp-org-specific-tlv>
                <lldp-remote-oui-802-3>00120f</lldp-remote-oui-802-3>
                <lldp-remote-subtype-lag>3</lldp-remote-subtype-lag>
                <lldp-remote-subtype-lag-status>supported, disabled (0x1)</lldp-remote-subtype-lag-status>
                <lldp-remote-subtype-lag-portid>0</lldp-remote-subtype-lag-portid>
                <lldp-remote-index>1</lldp-remote-index>
            </lldp-org-specific-tlv>
            <lldp-org-specific-tlv>
                <lldp-remote-oui-802-3>00120f</lldp-remote-oui-802-3>
                <lldp-remote-subtype-mac>1</lldp-remote-subtype-mac>
                <lldp-remote-subtype-mac-autonegotiation>supported, enabled (0x3)</lldp-remote-subtype-mac-autonegotiation>
                <lldp-remote-subtype-mac-pmd>6cc1</lldp-remote-subtype-mac-pmd>
                <lldp-remote-subtype-mac-mau>1e</lldp-remote-subtype-mac-mau>
                <lldp-remote-index>2</lldp-remote-index>
            </lldp-org-specific-tlv>
        </lldp-neighbor-information>
    ...
        </lldp-neighbor-information>
    </lldp-neighbors-information>
    <cli>
        <banner>{master:0}</banner>
    </cli>
</rpc-reply>