The script now invokes the load_configuration method to load the configuration onto the routing platform. It places the statement inside an eval block to ensure that the graceful_shutdown subroutine is invoked if the response from the JUNOScript 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:
my $config_format = "xml";
$config_format = "text" if $opt{t};
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 script performs two additional checks for errors and invokes the graceful_shutdown 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);
}