Automation

 View Only
last person joined: 3 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  The infamous Cisco - show interface status command

    Posted 17 days ago

    Hello all, 

    coming from a Cisco world, I often run that command to check on things. So I wanted to create a script (in .slax) to perform similarly on an EX4300. 

    I managed to write one that list each interface with its name, status, port negotiation, and other info from the "sh inter media". Now, the only thing missing is the vlan info. 

    On the EX4300, the command found to obtain that info, is "show ethernet-switching interface".  The XML returned is a list of l2ng-l2ald-iff-interface-entry, one for each interface. Within that entity, there is another list of l2ng-l2ald-iff-interface-entry, the first one has the logical interface's name with the other member of that list being each of the vlan associated with the interface.

    So given the logical interface name, how can I fetch how many vlan associated with an interface, and vlan name of first vlan. 

    Here's the structure for ge-0/0/0.0

    <rpc-reply xmlns:junos="http://xml.juniper.net/junos/21.4R0/junos">
        <l2ng-l2ald-iff-interface-information xmlns="http://xml.juniper.net/junos/21.4R0/junos-l2al">
            <l2ng-l2ald-iff-interface-entry junos:style="brief">
                <l2iff-interface-lr-name></l2iff-interface-lr-name>
                <l2iff-interface-rtt-name>default-switch</l2iff-interface-rtt-name>
                <l2ng-l2ald-iff-interface-entry junos:style="brief">
                    <l2iff-interface-name>ge-0/0/0.0</l2iff-interface-name>
                    <l2iff-interface-vlan-name/>
                    <l2iff-interface-mac-limit>65535</l2iff-interface-mac-limit>
                    <l2iff-interface-mac-ip-limit>8192</l2iff-interface-mac-ip-limit>
                    <l2iff-interface-vlan-member-stp-state/>
                    <l2iff-interface-flags></l2iff-interface-flags>
                    <l2iff-interface-vlan-member-tagness>untagged</l2iff-interface-vlan-member-tagness>
                </l2ng-l2ald-iff-interface-entry>
                <l2ng-l2ald-iff-interface-entry junos:style="brief">
                    <l2iff-interface-name/>
                    <l2iff-interface-vlan-name>default</l2iff-interface-vlan-name>
                    <l2iff-interface-vlan-id>1</l2iff-interface-vlan-id>
                    <l2iff-interface-vlan-member-tagness>untagged</l2iff-interface-vlan-member-tagness>
                    <l2iff-interface-mac-limit>65535</l2iff-interface-mac-limit>
                    <l2iff-interface-mac-ip-limit>1024</l2iff-interface-mac-ip-limit>
                    <l2iff-interface-vlan-member-stp-state>Forwarding</l2iff-interface-vlan-member-stp-state>
                    <l2iff-interface-flags></l2iff-interface-flags>
                </l2ng-l2ald-iff-interface-entry>
            </l2ng-l2ald-iff-interface-entry>

    Thanks for your help. 



    ------------------------------
    YVON LEDUC
    ------------------------------


  • 2.  RE: The infamous Cisco - show interface status command

     
    Posted 17 days ago

    Hi,

    I'm not sure that I quite know what the possible structures are for this RPC reply as I don't have a device to hand that I can easily test against.

    But would something like the following work?

    for-each ($result/l2ng-l2ald-iff-interface-entry) {
        expr "interface: " _ l2ng-l2ald-iff-interface-entry[1]/l2iff-interface-name;
        expr " count: " _ count(l2ng-l2ald-iff-interface-entry)-1;
        expr " vlan: " _ l2ng-l2ald-iff-interface-entry[2]/l2iff-interface-vlan-name;
    }

    Regards.



    ------------------------------
    Andy Sharp
    ------------------------------



  • 3.  RE: The infamous Cisco - show interface status command

    Posted 16 days ago

    Hello Andy. 

    Thanks for your reply. 

    Searching around your reply, I discovered that if I used the following for-each : 

    for-each ( $results2/l2ng-l2ald-iff-interface-entry [l2ng-l2ald-iff-interface-entry[1]/l2iff-interface-name == $searched-interface] )

    I would still be at the interface level but was able to select a specific interface. 

    Thanks again.



    ------------------------------
    YVON LEDUC
    ------------------------------