Understanding the NETCONF Perl Distribution and Sample Scripts
Juniper Networks provides a Perl module, called NET::Netconf::Manager, to help you more quickly and easily develop custom NETCONF scripts for configuring and monitoring switches, routers, and security devices running Junos OS . The module implements a NET::Netconf::Manager object that client applications can use to communicate with the NETCONF server on a device. The Perl distribution includes several sample Perl scripts, which illustrate how to use the module in scripts that perform various functions.
The NETCONF Perl distribution uses the same directory structure
for Perl modules as the Comprehensive Perl Archive Network (http://www.cpan.org). This includes a lib
directory
for the NET::Netconf module and its supporting
files, and an examples
directory
for the sample scripts.
Client applications use the NET::Netconf::Manager object to communicate with a NETCONF server. All of the sample scripts use this object.
The sample scripts illustrate how to perform the following functions:
diagnose_bgp.pl
—Illustrates how to write scripts to monitor device status and diagnose problems. The sample script extracts and displays information about a device's unestablished Border Gateway Protocol (BGP) peers from the full set of BGP configuration data. The script is provided in theexamples/diagnose_bgp
directory in the NETCONF Perl distribution.get_chassis_inventory.pl
—Illustrates how to use a predefined query to request information from a device. The sample script invokes the get_chassis_inventory query with the detail option to request the same information as the Junos XML get-chassis-inventorydetail/get-chassis-inventory tag sequence and the command-line interface (CLI) show chassis hardware detail command. The script is provided in theexamples/get_chassis_inventory
directory in the NETCONF Perl distribution.edit_configuration.pl
—Illustrates how to change the device configuration by loading a file that contains configuration data formatted with Junos XML tag elements. The distribution includes a sample configuration file,config.xml
; however, you can specify another configuration file on the command line. The script is provided in theexamples/edit_configuration
directory in the NETCONF Perl distribution.
For instructions on running the scripts, see the README
or README.html
file included in the NETCONF Perl distribution.