Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual page 245

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

Copyright © 2010, Juniper Networks, Inc.
if ($state >= STATE_CONNECTED) {
print "Disconnecting from the device ...\n";
eval {
$jnx->request_end_session()
$jnx->disconnect();
};
}
if ($success) {
die "REQUEST $req SUCCEEDED\n";
} else {
die "REQUEST $req FAILED\n";
};
}
Locking the Configuration
The main section of the
load_configuration.pl
to a Junos XML protocol server, as described in "Establishing the Connection" on page 217.
It then invokes the
lock_configuration
of error, the script invokes the
Conditions" on page 222.
print "Locking configuration database ...\n";
my $res = $jnx->lock_configuration();
my $err = $res->getFirstError();
if ($err) {
print "ERROR: $deviceinfo{hostname}: failed to lock configuration. Reason:
$err->{message}.\n";
graceful_shutdown($jnx, $xmlfile, STATE_CONNECTED, REPORT_FAILURE);
}
Reading In and Parsing the Configuration Data
In the following code sample, the
that contains Junos XML configuration tag elements or ASCII-formatted statements. A
detailed discussion of the functional subsections follows the complete code sample.
# 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, $xmlfile, STATE_LOCKED, REPORT_FAILURE);
}
my $parser = new XML::DOM::Parser;
...
my $doc;
if ($opt{t}) {
my $xmlstring = get_escaped_text($xmlfile);
$doc = $parser->parsestring($xmlstring) if $xmlstring;
} else {
$doc = $parser->parsefile($xmlfile);
}
Chapter 9: Writing Junos XML Protocol Perl Client Applications
script begins by establishing a connection
method to lock the configuration database. In case
subroutine described in "Handling Error
graceful_shutdown
script reads in and parses a file
load_configuration.pl
223

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents