NETCONF Perl client README


Contents

Abstract

Each Juniper Networks routing platform running JUNOS Internet software release 7.5B1 or later supports the NETCONF API. The NETCONF API provides mechanisms to install, manipulate, and delete the configuration of network devices. The NETCONF API uses an Extensible markup Language (XML) based data encoding for the configuration data as well as operations and messages defined in the API.

Because NETCONF uses XML based data encoding, you can leverage the myriad Perl modules in the public domain to ease the development of client applications that monitor and configure Juniper Networks routers. There are many modules in the Comprehensive Perl Archival Network (CPAN, http://www.cpan.org) and other Perl source repositories that provide ways to manipulate XML data (for example, the XML::Parser, and XML::DOM modules).

The Net::Netconf::Manager module provides an object-oriented interface for communicating with the NETCONF server so you can start using the NETCONF API quickly and easily. There are several modules in this library but client applications directly invoke the Manager object only. When the client application creates a Net::Netconf::Manager object, it specifies a router name and the login name to use when accessing the router (which determines the client application's access level).

The following code segment shows how to use the Net::Netconf::Manager object to request information from a Juniper Networks routing platform. This example invokes the query called get_chassis_inventory.

# Step 1: set up the query

my $query = "get_chassis_inventory";
my %queryargs = ( detail => 1 );


# Step 2: Create a Netconf Manager object and connect to the Juniper
Networks routing platform

my %deviceinfo = (
 access => "ssh",
 login => "johndoe",
 password => "secret",
 hostname => "router11"
 );
 my $jnx = new Net::Netconf::Manager(%deviceinfo);

 unless ( ref $jnx ) {
        croak "ERROR: $deviceinfo{hostname}: failed to connect.\n";
 } 


 # Step 3: send the query and receive a reply 

 my $res = $jnx->$query( %queryargs );


# Step 4: check for error

 if ($jnx->has_error) {
     croak "ERROR: in processing request \n $jnx->{request} \n";
 } else {


# Step 5: do something with the result
 }

# Step 6: always disconnect from the server when you're done
$jnx->disconnect();

 Back to Top  

Documents

The following documents are available at http://www.juniper.net/beta for the beta release and http://www.juniper.net/support for final release of each version of the JUNOS Internet software.

The following classes provide perldoc to describe their interfaces. Run man <class> after the installation is complete.


 Back to Top  

Supported Platforms

The current version of this module has been tested on the following platforms. Later releases may support additional platforms.