- 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
Collect Parameters Interactively in NETCONF Perl Client Applications
In a NETCONF Perl client application, a script can interactively
obtain the parameters required by the NET::Netconf::Manager
object from the command-line.
The NETCONF Perl distribution includes several sample Perl scripts
to perform various functions on devices running Junos OS. Each sample
script obtains the parameters required by the NET::Netconf::Manager
object from command-line options provided by the user who invokes
the script. The scripts use the getopts
function defined in the Getopt::Std
Perl
module to read the options from the command line and then record the
options in a Perl hash called %opt
. (Scripts
used in production environments probably do not obtain parameters
interactively, so this section is important mostly for understanding
the sample scripts.)
The following example references the get_chassis_inventory.pl sample script from the NETCONF Perl GitHub repository at https://github.com/Juniper/netconf-perl/tree/master/examples/get_chassis_inventory.
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.
The first parameter to the getopts
function defines the acceptable options, which vary depending on
the application. A colon after the option letter indicates that it
takes an argument.
The second parameter, \%opt
, specifies that the values are recorded in the %opt
hash. If the user does not provide at least one option, provides
an invalid option, or provides the -h
option, the script
invokes the output_usage
subroutine, which
prints a usage message to the screen.
my %opt; getopts('l:p:d:f:m:o:h', \%opt) || output_usage(); output_usage() if $opt{'h'};
The following code defines the output_usage
subroutine for the get_chassis_inventory.pl sample script. The contents of the my $usage
definition and the Where
and Options
sections are specific to the script, and
differ for each application.
sub output_usage { my $usage = "Usage: $0 [options] <target> Where: <target> The hostname of the target device. Options: -l <login> A login name accepted by the target device. -p <password> The password for the login name. -m <access> Access method. The only supported method is 'ssh'. -f <xmlfile> The name of the XML file to print server response to. Default: chassis_inventory.xml -o <filename> output is written to this file instead of standard output. -d <level> Debug level [1-6]\n\n"; croak $usage; }
The get_chassis_inventory.pl script includes the following code to obtain values from the command
line for the parameters required by the NET::Netconf::Manager
object. A detailed discussion of the various functional units follows
the complete code sample.
# Get the hostname my $hostname = shift || output_usage(); # Get the access method, can be ssh only my $access = $opt{'m'} || 'ssh'; use constant VALID_ACCESS_METHOD => 'ssh'; output_usage() unless (VALID_ACCESS_METHOD =~ /$access/); # Check for login name. If not provided, prompt for it my $login = ""; if ($opt{'l'}) { $login = $opt{'l'}; } else { print STDERR "login: "; $login = ReadLine 0; chomp $login; } # Check for password. If not provided, prompt for it my $password = ""; if ($opt{'p'}) { $password = $opt{'p'}; } else { print STDERR "password: "; ReadMode 'noecho'; $password = ReadLine 0; chomp $password; ReadMode 'normal'; print STDERR "\n"; }
In the first line of the preceding code sample, the script
uses the Perl shift
function to read the
hostname from the end of the command line. If the hostname is missing,
the script invokes the output_usage
subroutine
to print the usage message, which specifies that a hostname is required.
my $hostname = shift || output_usage();
The script next determines which access protocol to use,
setting the $access
variable to the value
of the -m
command-line option. If the specified value does
not match the only valid value defined by the VALID_ACCESSES
constant, the script invokes the output_usage
subroutine to print the usage message.
my $access = $opt{'m'} || 'ssh'; use constant VALID_ACCESS_METHOD => 'ssh'; output_usage() unless (VALID_ACCESS_METHOD =~ /$access/);
The script then determines the username, setting the $login
variable to the value of the -l
command-line
option. If the option is not provided, the script prompts for it and
uses the ReadLine
function (defined in
the standard Perl Term::ReadKey
module)
to read it from the command line.
my $login = ""; if ($opt{'l'}) { $login = $opt{'l'}; } else { print STDERR "login: "; $login = ReadLine 0; chomp $login; }
The script finally determines the password for the username,
setting the $password
variable to the value
of the -p
command-line option. If the option is not provided,
the script prompts for it. It uses the ReadMode
function (defined in the standard Perl Term::ReadKey
module) twice: first to prevent the password from echoing visibly
on the screen, and then to return the shell to normal (echo) mode
after it reads the password.
my $password = ""; if ($opt{'p'}) { $password = $opt{'p'}; } else { print STDERR "password: "; ReadMode 'noecho'; $password = ReadLine 0; chomp $password; ReadMode 'normal'; print STDERR "\n"; }
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.