Parsing And Formatting The Response From The Junos Xml Protocol; Server; Parsing And Formatting An Operational Response - 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
Parsing and Formatting the Response from the Junos XML Protocol Server
226
if ($err) {
print "ERROR: Failed to commit configuration. Reason: $err->{message}.\n";
graceful_shutdown($jnx, $xmlfile, STATE_CONFIG_LOADED, REPORT_FAILURE);
}
As the last step in sending a request, the application verifies that there are no errors with
the response from the Junos XML protocol server (see "Submitting a Request" on page 220).
It can then write the response to a file, to the screen, or both. If the response is for an
operational query, the application usually uses XSLT to transform the output into a more
readable format, such as HTML or formatted ASCII text. If the response consists of
configuration data, the application can store it as XML (the Junos XML tag elements
generated by default from the Junos XML protocol server) or transform it into formatted
ASCII text.
The following sections discuss parsing and formatting options:
Parsing and Formatting an Operational Response on page 226
Parsing and Outputting Configuration Data on page 228

Parsing and Formatting an Operational Response

The following code sample from the
uses XSLT to transform an operational response from the Junos XML protocol server
into a more readable format. A detailed discussion of the functional subsections follows
the complete code sample.
# Get the name of the output file
my $outputfile = $opt{o} || "";
# Retrieve the XSLT file
my $xslfile = $opt{x} || "xsl/text.xsl";
if ($xslfile && ! -f $xslfile) {
die "ERROR: XSLT file $xslfile does not exist";
#Get the xmlfile
my $xmlfile = "$deviceinfo{hostname}.xml";
$res->printToFile($xmlfile);
my $nm = $res->translateXSLtoRelease('xmlns:lc', $xslfile, "$xslfile.tmp");
if ($nm) {
print "Transforming $xmlfile with $xslfile...\n" if $outputfile;
my $command = "xsltproc $nm $deviceinfo{hostname}.xml";
$command .= "> $outputfile" if $outputfile;
system($command);
print "Done\n" if $outputfile;
print "See $outputfile\n" if $outputfile;
}
else {
and
diagnose_bgp.pl
get_chassis_inventory.pl
Copyright © 2010, Juniper Networks, Inc.
scripts

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents