[Contents] [Prev] [Next] [Index] [Report an Error]

Loading the Configuration Data

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:

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);
     }

[Contents] [Prev] [Next] [Index] [Report an Error]