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

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
224
unless ( ref $doc ) {
print "ERROR: Cannot parse $xmlfile, check to make sure the XML data is
well-formed\n";
graceful_shutdown($jnx, $xmlfile, STATE_LOCKED, REPORT_FAILURE);
}
The first subsection of the preceding code sample verifies the existence of the file
containing configuration data. The name of the file was previously obtained from the
command line and assigned to the
invokes the
graceful_shutdown
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);
}
If the
command-line option was included when the
-t
invoked, the file referenced by the
configuration statements like those returned by the CLI configuration-mode
command. The script invokes the
Disallowed Characters" on page 216, assigning the result to the
script invokes the
parsestring
format for loading into the configuration hierarchy, and assigns the result to the
variable. The
function is defined in the
parsestring
first line in the following sample code instantiates the module as an object, setting the
$parser
variable to refer to it:
my $parser = new XML::DOM::Parser;
...
my $doc;
if ($opt{t}) {
my $xmlstring = get_escaped_text($xmlfile);
$doc = $parser->parsestring($xmlstring) if $xmlstring;
If the file contains Junos XML configuration tag elements instead, the script invokes the
parsefile
function (also defined in the
} else {
$doc = $parser->parsefile($xmlfile);
}
If the parser cannot transform the file, the script invokes the
described in "Handling Error Conditions" on page 222:
unless ( ref $doc ) {
print "ERROR: Cannot parse $xmlfile, check to make sure the XML data is
well-formed\n";
graceful_shutdown($jnx, $xmlfile, STATE_LOCKED, REPORT_FAILURE);
}
Loading the Configuration Data
The script now invokes the
thedevice. It places the statement inside an
variable. If the file does not exist, the script
$xmlfile
subroutine:
variable should contain formatted ASCII
$xmlfile
subroutine described in "Converting
get_escaped_text
function to transform the data in the file into the proper
XML::DOM::Parser
XML::DOM::Parser
method to load the configuration onto
load_configuration
block to ensure that the
eval
script was
load_configuration.pl
show
variable. The
$xmlstring
$doc
module, and the
module) on the file:
subroutine
graceful_shutdown
Copyright © 2010, Juniper Networks, Inc.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents