Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Example: Requesting an Inventory of Hardware Components Using a NETCONF Perl Client Application

 

The NETCONF Perl distribution includes several sample Perl scripts to perform various functions on devices running Junos OS. The get_chassis_inventory.pl script retrieves and displays a detailed inventory of the hardware components installed in a routing, switching, or security platform. It is equivalent to issuing the show chassis hardware detail operational mode command in the Junos OS command-line interface (CLI). This topic describes the portion of the script that executes the query.

Note

Prior to Junos OS Release 16.1, every Junos OS release included a new, release-dependent version of the NETCONF Perl client. Beginning in Junos OS Release 16.1, the NETCONF Perl client is release-independent, is hosted on GitHub and CPAN, and can manage devices running any version of the Junos OS release. The sample scripts in the release-dependent versions of the NETCONF Perl distribution differ from those in the release-independent version hosted on GitHub and CPAN.

After establishing a connection to the NETCONF server, the script sends the get_chassis_inventory request and includes the detail argument.

Note

When using the release-dependent NETCONF Perl distribution, to include a fixed-form option when invoking a method, set the option equal to the value 1 (one).

The script sends the query and assigns the return value to the $res variable. The script first prints the RPC request and response to standard output, then it prints the response to the specified file. The script then checks for and prints any error encountered.

Release History Table
Release
Description
Beginning in Junos OS Release 16.1, the NETCONF Perl client is release-independent, is hosted on GitHub and CPAN, and can manage devices running any version of the Junos OS release. The sample scripts in the release-dependent versions of the NETCONF Perl distribution differ from those in the release-independent version hosted on GitHub and CPAN.