Parsing And Outputting Configuration Data - 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
228
my $nm = $res->translateXSLtoRelease('xmlns:lc', $xslfile, "$xslfile.tmp");
After verifying that the
translateXSLtoRelease
, which builds a command string and assigns it to the
format_by_xslt
The first part of the command string invokes the
names of the XSLT and configuration data files (
if ($nm) {
print "Transforming $xmlfile with $xslfile...\n" if $outputfile;
my $command = "xsltproc $nm $deviceinfo{hostname}.xml";
If the
$outputfile
variable is defined (the file for storing the result of the XSLT
transformation exists), the script appends a string to the
the results of the
command to the file. (If the file does not exist, the script writes
xsltproc
the results to standard out [stdout].) The script then invokes the
execute the command string and prints status messages to stdout.
$command .= "> $outputfile" if $outputfile;
system($command);
print "Done\n" if $outputfile;
print "See $outputfile\n" if $outputfile;
}
If the
translateXSLtoRelease
the script prints an error:
else {
print STDERR "ERROR: Invalid XSL file $xslfile\n";
}

Parsing and Outputting Configuration Data

The
script uses the
get_config.pl
obtained from the Junos XML protocol server to a file either as Junos XML tag elements
or as formatted ASCII text.
The
subroutine takes four parameters. Three must have defined values: the
outconfig
directory in which to store the output file, device hostname, and the XML DOM tree (the
configuration data) returned by the Junos XML protocol server. The fourth parameter
indicates whether to output the configuration as formatted ASCII text, and has a null
value if the requested output is Junos XML tag elements. In the following code sample,
the script obtains values for the four parameters and passes them to the
subroutine. A detailed discussion of each line follows the complete code sample.
my(%opt,$login,$password);
getopts('l:p:dm:hit', \%opt) || output_usage();
output_usage() if $opt{h};
my $basepath = shift || output_usage;
my $hostname = shift || output_usage;
my $config = getconfig( $hostname, $jnx, $opt{t} );
function succeeded, the invokes the
xsltproc
$nm
and
function fails (the
if ($nm)
subroutine to write the configuration data
outconfig
variable.
$command
command and specifies the
$deviceinfo{hostname}.xml
variable to write
$command
function to
system
expression evaluates to " false"),
outconfig
Copyright © 2010, Juniper Networks, Inc.
):

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents