- play_arrow Overview
- play_arrow NETCONF XML Management Protocol Overview
- play_arrow NETCONF and Junos XML Tags Overview
- XML and Junos OS Overview
- XML Overview
- XML and NETCONF XML Management Protocol Conventions Overview
- Map Junos OS Commands and Command Output to Junos XML Tag Elements
- Map Configuration Statements to Junos XML Tag Elements
- Using NETCONF Configuration Response Tag Elements in NETCONF Requests and Configuration Changes
-
- play_arrow Manage NETCONF Sessions
- play_arrow NETCONF Session Overview
- play_arrow Manage NETCONF Sessions
- Establish an SSH Connection for a NETCONF Session
- NETCONF Sessions over Transport Layer Security (TLS)
- NETCONF and Shell Sessions over Enhanced Outbound HTTPS
- NETCONF Sessions over Outbound HTTPS
- NETCONF Call Home Sessions
- NETCONF Sessions
- Sample NETCONF Session
- How Character Encoding Works on Juniper Networks Devices
- Configure RFC-Compliant NETCONF Sessions
- NETCONF Monitoring
- NETCONF Event Notifications
- play_arrow NETCONF Tracing Operations
- play_arrow NETCONF Protocol Operations and Attributes
- play_arrow NETCONF Request and Response Tags
- play_arrow Junos XML Protocol Elements Supported in NETCONF Sessions
- <abort/>
- <abort-acknowledgement/>
- <checksum-information>
- <close-configuration/>
- <commit-configuration>
- <commit-results>
- <commit-revision-information>
- <database-status>
- <database-status-information>
- <end-session/>
- <get-checksum-information>
- <get-configuration>
- <load-configuration>
- <load-configuration-results>
- <lock-configuration/>
- <open-configuration>
- <reason>
- <request-end-session/>
- <routing-engine>
- <unlock-configuration/>
- <xnm:error>
- <xnm:warning>
- play_arrow Junos XML Protocol Element Attributes Supported in NETCONF Sessions
-
- play_arrow Manage Configurations Using NETCONF
- play_arrow Change the Configuration Using NETCONF
- Edit the Configuration Using NETCONF
- Upload and Format Configuration Data in a NETCONF Session
- Set the Edit Configuration Mode in a NETCONF Session
- Handle Errors While Editing the Candidate Configuration in a NETCONF Session
- Replace the Candidate Configuration Using NETCONF
- Roll Back Uncommitted Changes in the Candidate Configuration Using NETCONF
- Delete the Configuration Using NETCONF
- Change Individual Configuration Elements Using NETCONF
- Merge Configuration Elements Using NETCONF
- Create Configuration Elements Using NETCONF
- Delete Configuration Elements Using NETCONF
- Replace Configuration Elements Using NETCONF
- Replace Patterns in Configuration Data Using the NETCONF or Junos XML Protocol
- play_arrow Commit the Configuration Using NETCONF
- play_arrow Ephemeral Configuration Database
- Understanding the Ephemeral Configuration Database
- Unsupported Configuration Statements in the Ephemeral Configuration Database
- Enable and Configure Instances of the Ephemeral Configuration Database
- Commit and Synchronize Ephemeral Configuration Data Using the NETCONF or Junos XML Protocol
- Managing Ephemeral Configuration Database Space
- Example: Configure the Ephemeral Configuration Database Using NETCONF
-
- play_arrow Request Operational and Configuration Information Using NETCONF
- play_arrow Request Operational Information Using NETCONF
- play_arrow Request Configuration Information Using NETCONF
- Request the Committed Configuration and Device State Using NETCONF
- Request Configuration Data Using NETCONF
- Specify the Source for Configuration Information Requests Using NETCONF
- Specify the Scope of Configuration Information to Return in a NETCONF Response
- Request the Complete Configuration Using NETCONF
- Request a Configuration Hierarchy Level or Container Object Without an Identifier Using NETCONF
- Request All Configuration Objects of a Specified Type Using NETCONF
- Request Identifiers for Configuration Objects of a Specified Type Using NETCONF
- Request A Specific Configuration Object Using NETCONF
- Request Specific Child Tags for a Configuration Object Using NETCONF
- Request Multiple Configuration Elements Simultaneously Using NETCONF
- Retrieve a Previous (Rollback) Configuration Using NETCONF
- Compare Two Previous (Rollback) Configurations Using NETCONF
- Retrieve the Rescue Configuration Using NETCONF
- Request an XML Schema for the Configuration Hierarchy Using NETCONF
-
- play_arrow YANG
- play_arrow YANG Overview
- Understanding YANG on Devices Running Junos OS
- Understanding Junos YANG Modules
- YANG Modules Overview
- Understanding the YANG Modules That Define the Junos OS Configuration
- Understanding the YANG Modules for Junos Operational Commands
- Junos Genstate YANG Data Models
- Understanding the Junos DDL Extensions YANG Module
- YANG Metadata Annotations for Junos Devices
- Use Juniper Networks YANG Modules
- play_arrow Create and Use Non-Native YANG Modules
- Understanding the Management of Nonnative YANG Modules on Devices Running Junos OS
- Manage YANG Packages, Modules, and Scripts on Junos Devices
- Managing YANG Packages and Configurations During a Software Upgrade or Downgrade
- Create Translation Scripts for YANG Configuration Models
- Disable and Enable YANG Translation Scripts on Devices Running Junos OS
- Commit and Display Configuration Data for Nonnative YANG Modules
- Create Custom RPCs in YANG for Devices Running Junos OS
- Create Action Scripts for YANG RPCs on Junos Devices
- Use Custom YANG RPCs on Devices Running Junos OS
- Example: Use a Custom YANG RPC to Retrieve Operational Information on Junos Devices
- Understanding Junos OS YANG Extensions for Formatting RPC Output
- Customize YANG RPC Output on Devices Running Junos OS
- Define Different Levels of Output in Custom YANG RPCs for Junos Devices
- Display Valid Command Option and Configuration Statement Values in the CLI for Custom YANG Modules
- Configure a NETCONF Proxy Telemetry Sensor in Junos
-
- play_arrow OpenDaylight Integration
- play_arrow Configure OpenDaylight Integration
-
- play_arrow Configuration Statements and Operational Commands
Submit a Request to the NETCONF Server in Perl Client Applications
In a NETCONF Perl client application, after establishing a connection to the NETCONF server, the client application can execute operational or configuration commands on a device running Junos OS to request operational information or change the configuration. The NETCONF Perl API supports a set of methods that correspond to CLI operational mode commands and NETCONF configuration operations. To execute a command, the client application invokes the Perl method corresponding to that command.
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 release-independent version of the NETCONF Perl client can invoke any method that has a corresponding Junos XML request tag.
Prior to Junos OS Release 16.1, every Junos OS release included a new, release-dependent version of the NETCONF Perl client. Each version of the software supported a set of methods that corresponded to specific CLI operational mode commands and operations on configuration objects. You can view the list of operational methods supported in that version of the client by examining the files stored in the lib/Net/Netconf/Plugins/Plugin/release directory of the NETCONF Perl distribution. The set of methods that correspond to operations on configuration objects is defined in the lib/Net/Netconf/Plugins.pm file of the distribution.
See the following sections for more information:
Mapping Junos OS Commands and NETCONF Operations to Perl Methods
All operational commands that have Junos XML counterparts are listed in the Junos XML API Operational Developer Reference. You can also display the Junos XML request tag elements for any operational mode command that has a Junos XML counterpart on the CLI. Once you obtain the request tag, you can map it to the corresponding Perl method name.
To display the Junos XML request tags for a command
in the CLI, include the | display xml rpc
option after
the command. The following example displays the request tag for the show route
command:
user@host> show route | display xml rpc <rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1R1/junos"> <rpc> <get-route-information> </get-route-information> </rpc> </rpc-reply>
You can map the request tag for an operational command to a
Perl method name. To derive the method name, replace any hyphens in
the request tag with underscores, and remove the enclosing angle brackets.
For example, the <get-route-information>
request tag maps to the get_route_information
method name.
Similarly, NETCONF protocol operations map to Perl method names
in the same manner. For example, the <edit-config>
operation maps to the edit_config
method
name.
Providing Method Options
Perl methods can have one or more options. The following section describes the notation that an application uses to define a method’s options in a NETCONF Perl client application.
A method without options is defined as
$NO_ARGS
, as in the following entry for theget_autoinstallation_status_information
method:content_copy zoom_out_map## Method : get_autoinstallation_status_information ## Returns: <autoinstallation-status-information> ## Command: "show system autoinstallation status" get_autoinstallation_status_information => $NO_ARGS,
To invoke a method without options, the client application follows the method name with an empty set of parentheses, as in the following example:
content_copy zoom_out_map$jnx->get_autoinstallation_status_information();
A fixed-form option is defined as type
$TOGGLE
. In the following example, theget_ancp_neighbor_information
method has two fixed-form options,brief
anddetail
:content_copy zoom_out_map## Method : get_ancp_neighbor_information ## Returns: <ancp-neighbor-information> ## Command: "show ancp neighbor" get_ancp_neighbor_information => { brief => $TOGGLE, detail => $TOGGLE, }
To include a fixed-form option when invoking a method, set the option equal to the string
'True'
, as in the following example:content_copy zoom_out_map$jnx->get_ancp_neighbor_information(brief => 'True');
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).
An option with a variable value is defined as type
$STRING
. In the following example, theget_cos_drop_profile_information
method takes theprofile_name
argument:content_copy zoom_out_map## Method : get_cos_drop_profile_information ## Returns: <cos-drop-profile-information> ## Command: "show class-of-service drop-profile" get_cos_drop_profile_information => { profile_name => $STRING, },
To include a variable value when invoking a method, enclose the value in single quotes, as in the following example:
content_copy zoom_out_map$jnx->get_cos_drop_profile_information(profile_name => 'user-drop-profile');
A set of configuration statements or corresponding tag elements is defined as type
$DOM
. In the following example, theget_config
method takes a set of configuration statements (along with two attributes):content_copy zoom_out_map'get_config' => { 'source' => $DOM_STRING, 'source_url' => $URL_STRING, 'filter' => $DOM },
A DOM object is XML code:
content_copy zoom_out_mapmy $xml_string = " <filter type=\"subtree\"> <configuration> <protocols> <bgp></bgp> </protocols> </configuration> </filter> "; my %queryargs = ( 'source' => "running", 'filter' => $xml_string, );
This generates the following RPC request:
content_copy zoom_out_map<rpc message-id='1'> <get-config> <source> <running/> </source> <filter type="subtree"> <configuration> <protocols> <bgp></bgp> </protocols> </configuration> </filter> </get-config> </rpc>
A method can have a combination of fixed-form options, options
with variable values, and a set of configuration statements. For example,
the get_forwarding_table_information
method
has four fixed-form options and five options with variable values:
## Method :get_forwarding_table_information
## Returns:<forwarding-table-information>
## Command: "show route forwarding-table" get_forwarding_table_information => { detail => $TOGGLE, extensive => $TOGGLE, multicast => $TOGGLE, family => $STRING, vpn => $STRING, summary => $TOGGLE, matching => $STRING, destination => $STRING, label => $STRING, },
Submitting a Request
The following code illustrates the recommended way to send a
configuration request to the NETCONF server and shows how to handle
error conditions. The $jnx
variable is
defined to be a NET::Netconf::Manager
object.
The sample code, which is taken from the edit_configuration.pl sample script, locks the candidate configuration, loads the configuration
changes, commits the changes, and then unlocks the configuration database
and disconnects from the NETCONF server. You can view the complete edit_configuration.pl script in the examples/edit_configuration directory in the NETCONF
Perl GitHub repository at https://github.com/Juniper/netconf-perl.
my $res; # Netconf server response # connect to the Netconf server my $jnx = new Net::Netconf::Manager(%deviceinfo); unless (ref $jnx) { croak "ERROR: $deviceinfo{hostname}: failed to connect.\n"; } # Lock the configuration database before making any changes print "Locking configuration database ...\n"; my %queryargs = ( 'target' => 'candidate' ); $res = $jnx->lock_config(%queryargs); # See if you got an error if ($jnx->has_error) { print "ERROR: in processing request \n $jnx->{'request'} \n"; graceful_shutdown($jnx, STATE_CONNECTED, REPORT_FAILURE); } # Load the configuration from the given XML file print "Loading configuration from $xmlfile \n"; if (! -f $xmlfile) { print "ERROR: Cannot load configuration in $xmlfile\n"; graceful_shutdown($jnx, STATE_LOCKED, REPORT_FAILURE); } # Read in the XML file my $config = read_xml_file($xmlfile); print "\n\n$config \n\n"; %queryargs = ( 'target' => 'candidate' ); # If we are in text mode, use config-text arg with wrapped # configuration-text, otherwise use config arg with raw # XML if ($opt{t}) { $queryargs{'config-text'} = '<configuration-text>' . $config . '</configuration-text>'; } else { $queryargs{'config'} = $config; } $res = $jnx->edit_config(%queryargs); # See if you got an error if ($jnx->has_error) { print "ERROR: in processing request \n $jnx->{'request'} \n"; # Get the error my $error = $jnx->get_first_error(); get_error_info(%$error); # Disconnect graceful_shutdown($jnx, STATE_LOCKED, REPORT_FAILURE); } # Commit the changes print "Committing the <edit-config> changes ...\n"; $jnx->commit(); if ($jnx->has_error) { print "ERROR: Failed to commit the configuration.\n"; graceful_shutdown($jnx, STATE_CONFIG_LOADED, REPORT_FAILURE); } # Unlock the configuration database and # disconnect from the Netconf server print "Disconnecting from the Netconf server ...\n"; graceful_shutdown($jnx, STATE_LOCKED, REPORT_SUCCESS);
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.