Obtaining Application-Specific Parameters - 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

Copyright © 2010, Juniper Networks, Inc.
ReadMode 'normal';
print STDERR "\n";
}

Obtaining Application-Specific Parameters

In addition to the parameters required by the
need to define other parameters, such as the name of the file to which to write the data
returned by the Junos XML protocol server in response to a request, or the name of the
Extensible Stylesheet Transformation Language (XSLT) file to use for transforming the
data.
As with the parameters required by the
hardcode the values in the application code, obtain them from a file, or obtain them
interactively. The sample scripts obtain values for these parameters from command-line
options in the same manner as they obtain the parameters required by the
object (discussed in "Obtain and Record Parameters Required by the JUNOS::Device
Object" on page 212). Several examples follow.
The following line enables a debugging trace if the user includes the
option. It invokes the
JUNOS::Trace::init
which is already imported with the
JUNOS::Trace::init(1) if $opt{d};
The following line sets the
command-line option. It names the local file to which the Junos XML protocol server's
response is written. If the
-o
my $outputfile = $opt{o} || " " ;
The following code from the
transform the Junos XML protocol server's response. The first line sets the
to the value specified by the
script uses the
file supplied with the script, which transforms the data to ASCII
text.xsl
text. The
statement verifies that the specified XSLT file exists; the script terminates if
if
it does not.
# Retrieve the XSLT file, default is parsed by perl
my $xslfile = $opt{x} || "xsl/text.xsl";
if ($xslfile && ! -f $xslfile) {
die "ERROR: XSLT file $xslfile does not exist";
}
The following code from the
update, or overwrite the new configuration data into the configuration database (for
more information about these operations, see "Changing Configuration Information" on
page 103). The first two lines set the
command-line option, or to the default value
specified value does not match one of the valid actions defined in the third line, the script
invokes the
subroutine.
output_usage
# The default action for load_configuration is 'merge'
my $load_action = "merge";
$load_action = $opt{a} if $opt{a};
Chapter 9: Writing Junos XML Protocol Perl Client Applications
JUNOS::Device
JUNOS::Device
routine defined in the
object.
JUNOS::Device
variable to the value specified by the
$outputfile
option is not provided, the variable is set to the empty string.
script defines which XSLT file to use to
diagnose_bgp.pl
-x
command-line option. If the option is not provided, the
load_configuration.pl
script defines whether to merge, replace,
variable to the value of the
$load_action
if the option is not provided. If the
merge
object, applications might
object, your application can
JUNOS::Device
-d
command-line
module,
JUNOS::Trace
-o
$xslfile
variable
-a
215

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents