Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

physical topology validation (demo with LLDP)

Khelil Sator edited this page Mar 6, 2019 · 11 revisions

topology

3 devices connected in a triangle topology

ex4300-9 ge-0/0/0 <-> ex4300-17 ge-0/0/0
ex4300-9 ge-0/0/1 <-> ex4300-18 ge-0/0/0
ex4300-17 ge-0/0/1 <-> ex4300-18 ge-0/0/1

Junos show commands

show lldp neighbors interface command output

pytraining@ex4300-9> show lldp neighbors interface
Local Interface    Parent Interface    Chassis Id          Port info          System Name
ge-0/0/0           -                   4c:96:14:ee:60:20   ge-0/0/0           ex4300-17
ge-0/0/1           -                   4c:96:14:ee:85:40   ge-0/0/0           ex4300-18

equivalent rpc of show lldp neighbors interface command

pytraining@ex4300-9> show lldp neighbors interface | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1R5/junos">
    <rpc>
        <get-lldp-interface-neighbors>
        </get-lldp-interface-neighbors>
    </rpc>
    <cli>
        <banner>{master:0}</banner>
    </cli>
</rpc-reply>

xml representation of show lldp neighbors interface

pytraining@ex4300-9> show lldp neighbors interface | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1R5/junos">
    <lldp-neighbors-information junos:style="brief">
        <lldp-neighbor-information>
            <lldp-local-port-id>ge-0/0/0</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>4c:96:14:ee:60:20</lldp-remote-chassis-id>
            <lldp-remote-port-description>ge-0/0/0</lldp-remote-port-description>
            <lldp-remote-system-name>ex4300-17</lldp-remote-system-name>
        </lldp-neighbor-information>
        <lldp-neighbor-information>
            <lldp-local-port-id>ge-0/0/1</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>4c:96:14:ee:85:40</lldp-remote-chassis-id>
            <lldp-remote-port-description>ge-0/0/0</lldp-remote-port-description>
            <lldp-remote-system-name>ex4300-18</lldp-remote-system-name>
        </lldp-neighbor-information>
    </lldp-neighbors-information>
    <cli>
        <banner>{master:0}</banner>
    </cli>
</rpc-reply>

table and view

we will use this table and view to collect LLDP details

--- 
LldpNeighborTable: 
    rpc: get-lldp-neighbors-information 
    item: lldp-neighbor-information 
    key: lldp-local-port-id 
    view: LldpNeighborView 

LldpNeighborView: 
    fields: 
        local_port: lldp-local-port-id 
        remote_port: lldp-remote-port-description 
        remote_name: lldp-remote-system-name

HealthBot configuration

  • lldp.yml table and view
  • collect-lldp rule to collect LLDP details (using the lldp.yml table and view) and to update the database
  • collect-lldp playbook uses the collect-lldp rule
  • check-lldp rule to validate the physical topology. This rule doesnt collect data from devices. This rule compares the desired/expected LLDP details against LLDP details collected by the rule above (i.e already available in the database). When we configure a rule field, we can use the argument reference to refer to another field from another rule.
  • check-lldp playbook uses the check-lldp rule

Demo

The python script check_lldp.py executes all the required tasks:

$ python check_lldp.py
loaded table and view lldp.yml
loaded healthbot rule collect-lldp.rule
loaded healthbot playbook collect-lldp.playbook
loaded healthbot configuration for the device: ex4300-9
loaded healthbot configuration for the device: ex4300-17
loaded healthbot configuration for the device: ex4300-18
loaded healthbot configuration for the device group: EX
healthbot configuration commited!
wait 60 sec
loaded healthbot rule check-topology.rule
loaded healthbot playbook check-lldp.playbook
loaded healthbot configuration for the network group: LLDP
healthbot configuration commited!
$

LLDP.png

Healthbot collect LLDP details from junos devices and compare the expected LLDP details against the actual LLDP details.

Clone this wiki locally