command to rpc mapping

496 views
Skip to first unread message

00_tlb_00

unread,
Nov 19, 2015, 5:25:21 PM11/19/15
to Junos Python EZ
Is there a way to map the command "clear bgp neighbor <neighbor> soft" to RPC?  Working a script to auto-update prefix lists and today using CLI which flags warning on debug use only.
In testing I've tried a few variations of sw = node.rpc.clear_bgp_neighbor(neighbor='10.10.200.53', terse=True).
One thing I didn't quite understand is how to include soft from the | display xml rpc reply I received.

>>> jnpr.junos.version.VERSION
'1.2.3'

ro...@juniper.mx5> show version 
Hostname: juniper.mx5
Model: mx5-t
JUNOS Base OS boot [12.3R4.6]
JUNOS Base OS Software Suite [12.3R4.6]
JUNOS Kernel Software Suite [12.3R4.6]
JUNOS Crypto Software Suite [12.3R4.6]
JUNOS Packet Forwarding Engine Support (MX80) [12.3R4.6]
JUNOS Online Documentation [12.3R4.6]
JUNOS Routing Software Suite [12.3R4.6]

Stacy W. Smith

unread,
Nov 20, 2015, 12:09:42 AM11/20/15
to 00_tlb_00, Junos Python EZ
Based on this output:

user@r0> clear bgp neighbor 10.10.200.53 soft | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1I0/junos">
    <rpc>
        <clear-bgp-neighbor>
                <soft/>
                <neighbor>10.10.200.53</neighbor>
        </clear-bgp-neighbor>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>


I believe you want:

sw = node.rpc.clear_bgp_neighbor(neighbor='10.10.200.53', soft=True)


--Stacy

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at http://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/99380da1-6b81-478a-8fb0-e930d3411cc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nitin Kumar

unread,
Nov 20, 2015, 12:16:28 AM11/20/15
to Stacy W. Smith, 00_tlb_00, Junos Python EZ
Thanks Stacy,

Also to add, For more details do have a look to

Junos OS commands can have options that do not require a value. For example, the Junos XML equivalent for the show interfaces terse command indicates that terse is an empty element.

user@router> show interfaces terse | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/14.1R1/junos">
    <rpc>
        <get-interface-information>
                <terse/>
        </get-interface-information>
    </rpc>
</rpc-reply>

In Junos PyEZ, if you want to execute an RPC and include a command option that does not take a value, add the option to the RPC method parameter list and set it equal to True. The following code executes the Junos PyEZ RPC equivalent of the show interfaces terse command:

  rsp = dev.rpc.get_interface_information(terse=True)

Thanks
Nitin Kr

00_tlb_00

unread,
Nov 20, 2015, 3:05:56 PM11/20/15
to Junos Python EZ, st...@acm.org, tlbvi...@gmail.com, nit...@juniper.net
Thank you Stacy and Nitin, much appreciated.
Reply all
Reply to author
Forward
0 new messages