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

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.
subroutine is invoked if the response from the Junos XML protocol
graceful_shutdown
server has errors.
eval {
$res = $jnx->load_configuration(
format => $config_format,
action => $load_action,
configuration => $doc);
};
if ($@) {
print "ERROR: Failed to load the configuration from $xmlfile. Reason: $@\n";
graceful_shutdown($jnx, $xmlfile, STATE_CONFIG_LOADED, REPORT_FAILURE);
exit(1);
}
The variables used to define the method's three arguments were set at previous points
in the application file:
The
variable was previously set to
$config_format
option was included:
my $config_format = "xml";
$config_format = "text" if $opt{t};
The
variable was previously set to
$load_action
option was included. The final two lines verify that the specified value is one of the
acceptable choices:
my $load_action = "merge";
$load_action = $opt{a} if $opt{a};
use constant VALID_ACTIONS => "merge|replace|override";
output_usage() unless ( $load_action =~ /VALID_ACTIONS/);
The
variable was set to the output from the
$doc
(defined in the
XML::DOM::Parser
Configuration Data" on page 223.
The script performs two additional checks for errors and invokes the
subroutine in either case:
unless ( ref $res ) {
print "ERROR: Failed to load the configuration from $xmlfile\n";
graceful_shutdown($jnx, $xmlfile, STATE_LOCKED, REPORT_FAILURE);
}
$err = $res->getFirstError();
if ($err) {
print "ERROR: Failed to load the configuration. Reason: $err->{message}\n";
graceful_shutdown($jnx, $xmlfile, STATE_CONFIG_LOADED, REPORT_FAILURE);
}
Committing the Configuration
If there are no errors, the script invokes the
file
lib/JUNOS/Methods.pm
print "Committing configuration from $xmlfile ...\n";
$res = $jnx->commit_configuration();
$err = $res->getFirstError();
Chapter 9: Writing Junos XML Protocol Perl Client Applications
xml
merge
parsestring
module), as described in "Reading In and Parsing the
commit_configuration
in the Junos XML protocol Perl distribution):
unless the
command-line
-t
unless the
command-line
-a
or
function
parsefile
graceful_shutdown
method (defined in the
225

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