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

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
230
}
if ( $config_node && $config_node ne "" ) {
if ( open OUTPUTFILE, ">$filename" ) {
if (!$text_mode) {
print OUTPUTFILE "<?xml version=\"1.0\"?>\n";
print OUTPUTFILE $config_node->toString(), "\n";
} else {
my $buf = $config_node->getFirstChild()->toString();
$buf =~ s/($char_class)/$escapes{$1}/ge;
print OUTPUTFILE "$buf\n";
}
close OUTPUTFILE;
}
else {
print "ERROR: could not open output file $filename\n";
}
}
else {
print "ERROR: empty configuration data for $hostname\n";
}
}
The first lines of the
outconfig
the subroutine is invoked, assigning each to a local variable:
outconfig( $basepath, $hostname, $config, $opt{t} );
sub outconfig( $$$$ ) {
my $leader = shift;
my $hostname = shift;
my $config = shift;
my $text_mode = shift;
The subroutine constructs the name of the file to which to write the subroutine's output
and assigns the name to the
first two parameters (the directory name and hostname) and the
in a name of the form
directory-name/hostname.xmlconfig
my $trailer = "xmlconfig";
my $filename = $leader . "/" . $hostname . "." . $trailer;
print "# storing configuration for $hostname as $filename\n";
The subroutine checks that the first tag in the XML DOM tree correctly indicates the type
of configuration data in the file. If the user included the
the first tag should be
<configuration-text>
configuration statements; otherwise, the first tag should be
file contains Junos XML tag elements. The subroutine sets the
appropriate value depending on the value of the
value from
, passed as the fourth parameter to the subroutine). The subroutine
opt{t}
invokes the
function (defined in the
getTagName
the name of the first tag in the input file, and compares the name to the value of the
$top_tag
variable. If the comparison succeeds, the XML DOM tree is assigned to the
variable. Otherwise, the subroutine prints an error message because the
$config_node
XML DOM tree is not valid configuration data.
subroutine read in the four parameters passed in when
$filename
variable. The filename is constructed from the
because the file contains formatted ASCII
$text_mode
XML::DOM::Element
Copyright © 2010, Juniper Networks, Inc.
variable, resulting
$trailer
:
option on the command line,
-t
because the
<configuration>
variable to the
$top_tag
variable (which takes its
module) to retrieve

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Junos os

Table of Contents