Sun Open Telecommunications Platform 2.0 Developer's Guide

Calling N1 SPS Plans From Shell Scripts

You can invoke the N1 SPS plans through the Command-Line Interface (CLI) by using the cr_cli binary. On a host that has Sun OTP 2.0, cr_cli is located in the /var/js/spsotp/N1_Service_Provisioning_System_5.2/cli/bin/cr_cli directory. For detailed description of the N1 SPS CLI, see Sun N1 Service Provisioning System 5.2 Command-Line Interface Reference Manual.

A typical workflow of invoking the N1 SPS plan from a script consists of three steps. The script performs the following tasks:

  1. Creates a variable setting for the components that are installed as part of the plan. Alternatively, you can also use the default values of variables for a component.

  2. Invokes the pe.p.run command through the N1 SPS CLI, which runs the specified plan with either the default values for variables or using specified variable settings.


    Note –

    The choice between the default values and variable settings is done for each component that is installed as part of the plan.


  3. Waits until the running plan is completed and checks for errors.

Examples

An example for creating the variable settings for component foo is as follows:

/var/js/spsotp/N1_Service_Provisioning_System_5.2/cli/bin/cr_cli -cmd cdb.vs.add -u otpadmin -p adminadmin -comp NM:/path/to/component/foo -name foo-varset1 -vars "var1=value1;var2=value2"

The above example creates a variable setting for the component foo with the name foo-varset1. You can use the foo-varset1 variable in the vs parameter of the pe.p.run command for plans that execute an install block on component foo.

An example for running the InstallSecurity plan from Sun OTP 2.0 plug-in is as follows:

/var/js/spsotp/N1_Service_Provisioning_System_5.2/cli/bin/cr_cli -cmd pe.p.run -u otpadmin -p adminadmin -PID NM:/com/sun/OTP/security/plans/InstallSecurity -tar "H:NM:otp-eng-x11;H:NM:otp-eng-x11;H:NM:otp-eng-x11" -comp "+;+;+,+,+,+,+,+,+,+" -vs "+;+;+,+,+,+,+,+,+,+" -pto 9000 -nto 9000

In the above example, the InstallSecurity plan is run on a host named host otp-eng-x11. The user name is otpadmin and password is adminadmin. The default values for component variables are used and the time out is set to 9000 seconds.

Note the syntax of the vs parameter specifying the variable settings to use. The InstallSecurity plan consists of three sub plans. Each sub plan takes a part of the vs parameter value and delimits it by semicolons, that is, the first sub plan takes +, the second takes + and the third takes +,+,+,+,+,+,+,+. The third sub plan calls eight install blocks on various components. For each of these blocks, the default variable values are being used, which is specified by the 8 (+) plus signs and (,) comma as a delimiter. Similar rules apply to the comp parameter. The tar parameter specifying the target host consists of three parts that specify the target for each of the three sub plans.

For detailed information about the pe.p.run command, see Sun N1 Service Provisioning System 5.2 Command-Line Interface Reference Manual.

If you use the correct syntax, the command will complete successfully and return a ID. You can use this ID to check the plan status by running the pe.p.lo command. Error checking needs to parse the pe.p.lo command output.

The following example waits for running task ID 010018158098-1200908797135-01929-1300304153.

/var/js/spsotp/N1_Service_Provisioning_System_5.2/cli/bin/cr_cli -cmd pe.p.lo -u otpadmin -p adminadmin -ID 010018158098-1200908797135-01929-1300304153

The output of this example lists the sub-tasks that run in the background before completing this task.