The example code in this section is in the LSPPing.asl file.

A GA_Driver is used to start an ASL script. It can be programmed to start an ASL script on the local server or on a remote server.

A GA_Driver instance is created by:

<instance name>=create(“GA_Driver”, <Driver_Name>);

For example:

driver=create(“GA_Driver”, “lsp-ping-”.LSP.”-Driver”.thread());

To run an ASL script on a remote server, such as running pinglsp-ondemand.asl on the MPLS Topology Server, a GA_Driver requires an instance of GA_RemoteServer in which the remote server name is specified.

For an LSP Ping server tool request, the assumption is that the name of the MPLS Topology Server is not available. Thus, “runViaSAM,” an instance of the class RunViaSAM, is used to automatically obtain the MPLS Topology Server name.

runViaSAM = object(“RunViaSAM”, “runViaSAM”);
    if (runViaSAM->isNull()) {
        print(“RunViaSAM object does not exist, exit.”);
        stop();
    }
    domains = runViaSAM->getDomains(ServerName, "dummy-server");
    mplsServerName= ““;
    mpls_ver = 0;
    extractedDomain = list();
    extractedDomain = runViaSAM->extractType(domains, “mpls-vpn”);
    extractedDomain2 = list();
    extractedDomain2 = runViaSAM->extractType(domains, “mpls-t”);
    if (sizeof(extractedDomain2) > 0) {
        mplsServerName = extractedDomain2[0];
        mpls_ver = 2;   // stand for MPLS 2.0 and later version
        if (detailDebug) { print(“Using MPLS server: 
           “.mplsServerName); }
    } else if (sizeof(extractedDomain) > 0) {
        mplsServerName = extractedDomain[0];
        mpls_ver = 1;
        if (detailDebug) { print(“Using MPLS server: 
           “.mplsServerName); }
    } else {
        print(“There is no MPLS server connected to 
           “.ServerName.”\n”);
        print(“Tool cannot be executed \n”);
        stop();
    }

If you want to reuse the previous code to obtain the name of a different type of server, you can do so by replacing the argument of extractType function with the argument of the different type of server; for example, replace “mpls-vpn” with “icf” (for IP Availability Manager), or replace “mpls-vpn” with “ics” (for the Global Manager). If you know the remote server name in advance, you can hard code the name in the script. For instance, if the MPLS Topology Server name is INCHARGE-MPLS-TOPOLOGY, you can set the value of the server name variable as:

mplsServerName = “INCHARGE-MPLS-TOPOLOGY”;

After obtaining the remote server name, the following lines of code create and attach an instance of GA_RemoteServer to the GA_Driver:

domainServer=create(“GA_RemoteServer”, 
   “lsp-ping-”.LSP.”-driver”.thread());
domainServer->remoteServerName = mplsServerName;
driver->SendsActionsTo = domainServer;
driver->waitForCompletion=TRUE;

The remoteServerName attribute of the GA_RemoteServer instance is the remote server name. Without providing a GA_RemoteServer (which can be accomplished by commenting out the previous three lines of code), the GA_Driver will run the ASL script on the same server where it is invoked.

A GA_Driver needs to know the place and the name of the ASL script that it will invoke. To this end, the ASL script name is first fed into an object of GA_RuleSet, which in turn is attached to the GA_Driver. Note that the directory of the ASL script is referenced to the BASEDIR/smarts/rules directory (or the BASEDIR/smarts/local/rules directory) in the Global Manager installation area.

ruleObj=create(“GA_RuleSet”, “lsp-ping-”.LSP.”-Rule”.thread());
ruleObj->fileName=”ics/pinglsp-ondemand.asl”;
driver->ReadsRulesFrom=ruleObj;

The GA_Parameters object of a GA_Driver can be used to pass parameters to the ASL script, for carrying string inputs and string outputs. By default, an LSP ping server tool request include the following fields of information:

  • An LSP name

  • A ping command

  • Four ping arguments if the source network device is a Cisco device

  • One ping argument if the source network device is a Juniper device

    The default values of the ping arguments are specified in GUID-424FEAF2-21D9-491B-A175-C5B2771DB344.html#GUID-424FEAF2-21D9-491B-A175-C5B2771DB344___MPLS_CONFIG_SAM_46021.

    Variables “CLIOutput” and “LSPPingCommand” are used for carrying the CLI output and the ping command, respectively. In this particular example, there are two output strings. One, two, or more output strings are possible.

    params =driver->getMyParameters();
    params->clear();
    params->insert(“LSP”, LSP);
    params->insert(“RepeatCount”, vendorLSPPingRepeatCount);
    params->insert(“VendorID”, string(deviceTypeID));
    if (deviceTypeID == 0) {
       params->insert(“Interval”, vendorLSPPingInterval);
    }
    if ((deviceTypeID == 0) || (deviceTypeID == 4)) {
       params->insert(“PacketSize”, vendorLSPPingPacketSize);
    }
    if ((deviceTypeID == 0) || (deviceTypeID == 4)) {
       params->insert(“TimeOut”, ciscoLSPPingPacketTimeout);
    }
    .
    .
    .
    params->insert(“CLIOutput”, “”);
    params->insert(“LSPPingCommand”,Command);
    params->insert(“MPLSVersion”, string(mpls_ver));
    

    The GA_Driver is ready to be started after the parameters are set. If outputs of the ASL script are needed, set the getDriverResults attribute of the GA_Parameters object to TRUE.

    params->getDriverResults = TRUE;
    if (debug) { print(“Starting LSP ping driver”); }
    driver->startWithParameters(params);
    

    The output strings can be obtained by using the find operation of the GA_Parameters object with the argument of the output variable name. In the following example, the CLI output is passed backed with variable CLIOutput:

    CLIOutput = params->find("CLIOutput");