Example: Loading Configuration Statements - Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Junos 10.3 Junos XML Management Protocol Guide
222
# Now do the transformation using XSLT
... code that uses XSLT to process results ...
}

Example: Loading Configuration Statements

The
load_configuration.pl
script loads configuration statements onto a device. It uses the
basic structure for sending requests described in "Submitting a Request" on page 220 but
also defines a
graceful_shutdown
elaborate manner than that described in "Submitting a Request" on page 220. The following
sections describe the different functions that the script performs:
Handling Error Conditions on page 222
Locking the Configuration on page 223
Reading In and Parsing the Configuration Data on page 223
Loading the Configuration Data on page 224
Committing the Configuration on page 225
Handling Error Conditions
The
graceful_shutdown
subroutine in the
slightly more elaborate manner than the generic structure described in "Submitting a
Request" on page 220. It employs the following additional constants:
use constant REPORT_SUCCESS => 1;
use constant REPORT_FAILURE => 0;
use constant STATE_CONNECTED => 1;
use constant STATE_LOCKED => 2;
use constant STATE_CONFIG_LOADED => 3;
The first two
statements in the subroutine refer to the
if
STATE_LOCKED
conditions, which apply specifically to loading a configuration in the
script. The
load_configuration.pl
checking described in "Submitting a Request" on page 220. The
each case ensures that any errors that occur during execution of the enclosed function
call are trapped so that failure of the function call does not cause the script to exit.
sub graceful_shutdown
{
my ($jnx, $req, $state, $success) = @_;
if ($state >= STATE_CONFIG_LOADED) {
print "Rolling back configuration ...\n";
eval {
$jnx->load_configuration(rollback => 0);
};
}
if ($state >= STATE_LOCKED) {
print "Unlocking configuration database ...\n";
eval {
$jnx->unlock_configuration();
};
}
subroutine that handles errors in a slightly more
load_configuration.pl
STATE_CONFIG_LOADED
statement for
if
STATE_CONNECTED
Copyright © 2010, Juniper Networks, Inc.
script handles errors in a
and
is similar to the error
statement used in
eval

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents