version 1.0; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; import "../import/junos.xsl"; var $arguments = { { "community"; "Community of a VPN"; } } param $community; match / { { var $config = jcs:invoke("get-configuration"); if (jcs:empty($config/protocols/isis) and jcs:empty($config/protocols/ospf)){ { "NO IGP was found"; } call exit-script(); } if (jcs:empty($config/protocols/rsvp) and jcs:empty($config/protocols/ldp)){ { "NO labeling protocol was found"; } call exit-script(); } if (not($config/protocols/bgp//group[type="internal"]/family/inet-vpn)){ { "NO iBGP inet-vpn enabled group was found"; } call exit-script(); } if (not(jcs:empty($config/protocols/ospf))){ "IGP: OSPF\nneighbors status"; var $res = jcs:invoke("get-ospf-neighbor-information"); for-each($res/ospf-neighbor){ neighbor-address _ " : " _ interface-name _ " : " _ ospf-neighbor-state; } } if (not(jcs:empty($config/protocols/isis))){ "ISIS LOGIC"; } if (not(jcs:empty($config/protocols/ldp))){ "\n\nLABELS: LDP\nneighbors status"; var $res = jcs:invoke("get-ldp-session-information"); for-each($res/ldp-session){ ldp-neighbor-address _ " : " _ ldp-session-state; } } if (not(jcs:empty($config/protocols/rsvp))){ "LDP LOGIC"; } if ($config/protocols/bgp//group[type="internal"]/family/inet-vpn){ "\n\nROUTING: BGP"; for-each($config/protocols/bgp/group[type="internal"]/family/inet-vpn/../..){ "Group " _ name; var $bgpr = { ./name; } var $res = jcs:invoke($bgpr); "Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped..."; { for-each ($res/bgp-peer){ { copy-of ./*; } } } "\n"; } } if(not(jcs:empty($community))){ jcs:printf("\n\nVPN routes tagged with community %s", $community); var $router = { $community; "bgp.l3vpn.0"; } var $res = jcs:invoke($router); for-each ($res/route-table/rt){ "\tVPN ROUTE: " _ rt-destination _ "/" _ rt-prefix-length _ " from " _ rt-entry/learned-from; } } } } template exit-script(){ "Script aborted"; }