The documentation set for this product strives to use bias-free language. For the purposes of this documentation set, bias-free is defined as language that does not imply discrimination based on age, disability, gender, racial identity, ethnic identity, sexual orientation, socioeconomic status, and intersectionality. Exceptions may be present in the documentation due to language that is hardcoded in the user interfaces of the product software, language used based on RFP documentation, or language that is used by a referenced third-party product. Learn more about how Cisco is using Inclusive Language.
This chapter contains the following sections:
A script module is essentially a container for custom scripts, jar files, and input controls. The contents of script modules enable you to perform customized actions such as adding library scripts that can be integrated with custom workflow tasks. You can export a script module and import it to a different appliance. Registered scripts in the imported module are available in the new appliance.
The following table describes the actions you can perform using script modules:
Task |
See |
---|---|
Adding script modules |
|
Adding libraries |
|
Adding jars |
|
Adding Lists of Values (LOVs) |
|
Adding Tabular Reports |
|
Adding Context Mappings |
|
Exporting script modules |
Exporting Workflows, Custom Tasks, Script Modules, and Activities |
Importing script modules |
Importing Workflows, Custom Tasks, Script Modules, and Activities |
To create a new script module, do the following:
To add a task library, do the following:
A script module is required before you can add a library. See Adding Script Modules
Step 1 | Choose Orchestration. | ||||||||
Step 2 | On the Orchestration page, click Script Module. | ||||||||
Step 3 | In the Script Module pane, double-click the script module to which you want to add the library. | ||||||||
Step 4 | On the Script Module screen, click Library. | ||||||||
Step 5 | Click Add. | ||||||||
Step 6 | On the Library Information screen, complete the following:
| ||||||||
Step 7 | Click Submit. |
You can access libraries in the followings ways:
Use the following syntax to invoke a library from another library:
loadLibrary("Module Name>/<Library Name>")
ImportPackage(java.lang); function test1(){ logger.addInfo("test1"); loadLibrary("Test_Module/testlib1"); } test1();
When you create a custom workflow task, you can use the syntax shown in this example to invoke a library. Refer to the Cisco UCS Director Custom Task Getting Started Guide for more information on using custom tasks, including how to invoke a library from a custom task.
You can register .jar files with a script module. Using the script module, you can then invoke the contents of the .jar file (its classes, methods, and resources) from a library or a custom task.
To add a .jar file to a script module, do the following:
Step 1 | Choose Orchestration. |
Step 2 | On the Orchestration page, click Script Module. |
Step 3 | On the Script Modules screen, double-click the script module to which you want to add the jar files. |
Step 4 | Click Jars. |
Step 5 | Click Add. |
Step 6 | On the Add Jar screen, click Browse. |
Step 7 | Select the .jar file to upload from your local folder. |
Step 8 | Click Submit. |
A list of values (LOV) is a searchable list that is callable from the Cisco UCS Director GUI or as a task or workflow input. For example, when you choose a data type for a task or workflow input, the choices are presented in an LOV.
You can create an LOV to provide your own set of values for a task or workflow input, and store the LOV in a script module.
To create a list of values (LOV), do the following.
Create a Script Module.
Step 1 | Choose Orchestration. | ||||||||||
Step 2 | On the Orchestration page, click Script Module. | ||||||||||
Step 3 | On the Script Module screen, double-click the script module you want to use. | ||||||||||
Step 4 | Click LOVs. | ||||||||||
Step 5 | Click Add. | ||||||||||
Step 6 | On the LOV Information screen, complete the following:
| ||||||||||
Step 7 | In the Script
text box, add name-value pairs to your list as follows:
| ||||||||||
Step 8 | Click Submit. |
To edit an existing list of values (LOV), do the following:
Step 1 | Choose Orchestration. | ||||||||||||
Step 2 | On the Orchestration page, click Script Module. | ||||||||||||
Step 3 | On the Script Module screen, double-click the script module that contains the LOV you want to edit. | ||||||||||||
Step 4 | Click LOVs. | ||||||||||||
Step 5 | Choose the LOV you want to edit. | ||||||||||||
Step 6 | Click Edit. | ||||||||||||
Step 7 | Edit the LOV fields as described in the following table:
| ||||||||||||
Step 8 | Click Submit. |
Remove references to this list of values (LOV) from all custom tasks and workflows.
A tabular report is a columnar list that is callable from the Cisco UCS Director GUI or as a task or workflow input. For example, when you choose a workflow in the Workflow tab, the choices are presented in tabular report.
You can create a tabular report to provide your own predefined set of values for a task or workflow input. You can store the tabular report in a script module.
Create a Script Module.
Step 1 | On the menu bar, choose . | ||||||||||||||
Step 2 | Click the Script Module tab. | ||||||||||||||
Step 3 | In the Script Module pane, double-click the script module you want to use. | ||||||||||||||
Step 4 | Click the Tabular Reports tab. | ||||||||||||||
Step 5 | Click the Add (+) button. | ||||||||||||||
Step 6 | In the
Tabular
Report Information dialog box, complete the following:
| ||||||||||||||
Step 7 | Click Submit. | ||||||||||||||
Step 8 | Repeat the previous two steps for every column you want to create. | ||||||||||||||
Step 9 | Show Script
check box—Check this check box to see and edit the
Script text area.
The column-creation script in the Script text area is automatically generated when you create columns. A record consists of a row with one value for each column. Edit the Script text area to create records.
| ||||||||||||||
Step 10 | Click Submit. |
Suppose that you created two Column Entries for your tabular report. The first column entry has a column name of Name and column type of Text. The second column entry has a column name of Department and a column type of Long. Once you create the column entries in your tabular report, the system generates function calls in the script to create these columns, as follows:
function implementationForTabularReport(report) { var model = new TabularReportInternalModel(); model.addTextColumn("Name","Name"); model.addNumberColumn("Department","Department"); model.completedHeader(); //START OF YOUR IMPLEMENTATION. //END OF YOUR IMPLEMENTATION. model.updateReport(report); } function getSelectionColumnId(){ return "1"; } function getDisplayColumnId(){ return "0"; }
A section in the middle of the script begins with //START OF YOUR IMPLEMENTATION. and ends with //END OF YOUR IMPLEMENTATION. Create record entries between these two lines. Record entries assign values to the column entries.
The following example assigns a text value of "Smith" to the column with column name Name and a long number value of 40 to the column with column name Department. The function call model.completedRow(); indicates the end of this record entry.
function implementationForTabularReport(report) { var model = new TabularReportInternalModel(); model.addTextColumn("Name","Name"); model.addLongNumberColumn("Department","Department"); model.completedHeader(); //START OF YOUR IMPLEMENTATION. model.addTextValue("Smith"); model.addLongNumberValue(40); model.completedRow(); //END OF YOUR IMPLEMENTATION. model.updateReport(report); } function getSelectionColumnId(){ return "1"; } function getDisplayColumnId(){ return "0"; }
Step 1 | On the menu bar, choose . | ||
Step 2 | Click the Script Module tab. | ||
Step 3 | In the Script Module pane, double-click the script module for which you want to edit a tabular report. | ||
Step 4 | Choose the Tabular Report tab. | ||
Step 5 | Choose the name of the tabular report you want to edit and click Edit. | ||
Step 6 | In the
Edit dialog box, edit the fields you want to change.
| ||
Step 7 | Click Submit. |
Remove references to the tabular report from all custom workflow tasks.
Step 1 | Choose Orchestration. |
Step 2 | On the Orchestration page, click Script Module. |
Step 3 | On the Script Module screen, double-click the script module that contains the tabular report you want to delete. |
Step 4 | Choose Tabular Report. |
Step 5 | Select the name of the tabular report you want to delete. |
Step 6 | Click Delete. |
Step 7 | Click Submit. |
A context workflow mapping consists of an action label mapped to a workflow on a page, such that clicking on the action label triggers the workflow.
Note | Strictly speaking, context mapping is not part of orchestration—It's a modification to the Cisco UCS Director user interface (UI). It is included here because it is a useful application of script modules. |
The Context Mapping module allows you to dynamically add a context workflow mapping. In this way, you can customize the Cisco UCS Director UI by creating an action label for a page and assigning a workflow to that action label.
Creating a context mapping requires knowing the name of the page to which you are adding the action label. The name, and other metadata, of a page are displayed in an Information dialog that is available when you enable the Developer Menu in Cisco UCS Director.
Enable metadata as described in the next section before you begin to create a context mapping.
To access report metadata, first enable the Developer Menu.
Note | The term report in Report Metadata refers to a page in the Cisco UCS Director user interface. |
To enable the Developer Menu, do the following:
Step 1 | In Cisco UCS Director, hover the mouse over the user icon at the top right corner and choose Edit My Profile from the drop-down list. | ||
Step 2 | On the Edit My Profile page, click Show Advanced Settings. | ||
Step 3 | Check Enable Developer Menu (requires re-login).
The REST API Browser is activated in the Orchestration page, and the Report Metadata option becomes available in the report views.
| ||
Step 4 | Click Close. |
View report metadata, including the report name, by clicking Report Metadata in any report.
Create a Script Module. See Using Script Modules.
Identify the page which is to use the action label. Use the report metadata to find the name of this page; see Enabling Metadata. You use this page name when you create a Context Mapping.
Step 1 | Choose Orchestration. | ||||||||||||||||
Step 2 | On the Orchestration page, click Script Module. | ||||||||||||||||
Step 3 | On the Script Module page, double-click the script module you want to use. | ||||||||||||||||
Step 4 | Click Context Mapping. | ||||||||||||||||
Step 5 | Click Add. | ||||||||||||||||
Step 6 | On the Add Context Mapper screen, complete the following:
| ||||||||||||||||
Step 7 | Click Submit. The Status column displays Success or Fail. | ||||||||||||||||
Step 8 | If the result was Fail, edit the Context Mapping to ensure that the correct Report Name and Tabular Field have been entered, then click Submit again. | ||||||||||||||||
Step 9 | If the result was Success then, from the menu bar, choose . | ||||||||||||||||
Step 10 | Click Context Workflow Mapping. The Context Mapping you created is listed in the Mapping Name column. | ||||||||||||||||
Step 11 | Click the context workflow mapping you created. | ||||||||||||||||
Step 12 | Click Edit. | ||||||||||||||||
Step 13 | On the Edit Workflow Mappings screen, click Add Workflow. | ||||||||||||||||
Step 14 | On the Workflow 1 screen, complete the following:
To add an additional Workflow step to this Context Workflow Mapping, click the Add Workflow button and complete the fields. To delete a Workflow step from this Context Workflow Mapping, click Delete Field below the workflow you want to delete. | ||||||||||||||||
Step 15 | If you are satisfied with your workflow mappings, click Submit. In the mapped report, the Action Label that you defined appears. |
To edit a context mapping, do the following:
Step 1 | Choose Orchestration. |
Step 2 | On the Orchestration page, click Script Module. |
Step 3 | On the Script Module page, double-click the script module containing the context mapping you want to edit. |
Step 4 | Choose Context Mapping. |
Step 5 | Choose the name of the context mapping you want to edit. |
Step 6 | Click Edit. |
Step 7 | On the Edit Context Mapper screen, edit the fields you want to change.
You cannot edit the Name field. Select a value for Tabular Fields. This selection is required; the previous value does not persist. |
Step 8 | Click Submit. |
To delete a context mapping, use the following procedure.
Remove references to the Context Mapping from all Workflows and reports.
Step 1 | Choose Orchestration. |
Step 2 | On the Orchestration page, click Script Module. |
Step 3 | On the Script Module page, double-click the script module that contains the context mapping you want to delete. |
Step 4 | Choose Context Mapping. |
Step 5 | Choose the name of the context mapping you want to delete. |
Step 6 | Click Delete. A popup appears to confirm the deletion. |
Step 7 | Click Submit. |
You can import and export script modules using the Import and Export actions you use to import and export workflows, custom tasks, and activities.
To import a script module, see Importing Workflows, Custom Tasks, Script Modules, and Activities.
To export a script module, see Exporting Workflows, Custom Tasks, Script Modules, and Activities.