Create/Edit Input Property for Service dialog box

Ops Center Automator Service Builder User Guide

Version
10.9.x
File Size
3.3 MB
Audience
anonymous
Part Number
MK-99AUT002-16

The following table describes the Create/Edit Input Property for Service dialog box fields, subfields, and field groups. A field group is a collection of fields that are related to a specific action or configuration.

When you enter information in a dialog box, if the information is not valid, errors that include a description of the problem appear at the right side of the box.

Table. Definitions Field Group
Field Subfield Description
Key: * - Input property key name.
Display Name: * - Name of the input property.
Description: - Description of the input property.
Property Group: -

Select the property group to which the property belongs.

You can also choose Create New Property Group to create a new property group.

Visibility: - Choose whether properties are visible on both the Edit and Submit windows, or only on the Edit window.
Display Settings: -

Specifies the display setting for the input property. The choices are:

  • Editable
  • Read only
  • Hide
Service Share Property: - Enable Service Share Property to add the service as a Service plug-in after the release process.
Required: - Specifies that the property is required when this check box is checked.
Data Type: -

Select a data type of the property: string, boolean, integer, double, date, password, composite. Various options that specify restrictions on the data entry are visible depending on the option you chose.

When using arrays, verify the Array Type option for the data type to be handled as an array. By doing this, a set of the properties of the same type (number of elements is variable) can be handled as a single property making data mapping easier, especially when passing data between a service and the plug-ins.

Content Type: -

Select the content type:

  • application/json
  • application/javascript
  • application/xml
  • text/html
  • text/plain
  • text/csv
  • application/octet-stream
Domain Type: - Select the domain type from the list or add a new domain type by clicking Add New Domain Type and entering the details in the Create Domain Type Definition dialog box. This option is available when you choose composite for the Data Type and application/json for the Content Type.
Fields with an asterisk (*) are required.
Table. Restrictions Field Group
Field Subfield Description
Minimum Value: - Specifies the minimum value. This input field is visible when you choose integer, double, or date for the Data Type.
Maximum Value: - Specifies the maximum value. This input field is visible when you choose integer, double, or date for the Data Type.
Minimum Length: - Specifies the minimum length of the property. This input field is visible when you choose string or password for the Data Type.
Maximum Length: - Specifies the maximum length of the property. This input field is visible when you choose string or password for the Data Type.
Restricted Character: -

Specifies the allowed characters by using a regular expression. This input field is visible when you choose string or password for the Data Type.

Example: ^[0-9a-zA-Z\.\-]*$

Minimum Array Length: - Specifies the minimum length of array elements.
Maximum Array Length: - Specifies the maximum length of array elements.
Validation Script: - Script that validates the property based on the associated Javascript code.
Table. Value and Presentation Field Group
Field Subfield Description
Presentation: - Specifies the property presentation. The available presentation values appear in the list depending on the Data Type.
Default Value: - Specifies whether the default value for the property is true or false.

When specifying the Array of option, the default value must be written as a comma-separated string value surrounded by brackets.

Example: ["1","2","3"]

Data Source: - Specifies whether the data is Static or Dynamic and obtained from an external resource provider.
Specify List Items: - Specifies the Specify List Items when the data source for the property is static (when you choose the Static option for the Data Source.)
External Resource: - Specifies the external resource provider when the data source for the property is dynamic (when you choose the Dynamic option for the Data Source).

In the list, you can also add, edit, upload, or delete for the external resource provider.

Extra Path: - Specifies the extra path portion of the request URL. Leave it empty if it is not required. The extra path is the path that follows the external resource provider ID in a URL as follows:

/Automation/v1/objects/ExternalResources/<external resource provider ID>/<extra path>?<query parameters>

Query Param: - Specifies the query parameter for the external resource provider. The serviceID and serviceTemplateID parameters are added automatically. You can specify {$ref:keyName} to refer to the value of other properties in the same property group. For a JSON value, you can specify {$ref:keyName#json path}.
Name Field: - Specifies the field name to use as the label visible in the list. If omitted, uses the name field.
Value Field: - Specifies the field value to use as the value of the property visible in the list. If omitted, uses the instance ID field.
Show If: - Specifies to show the property entry if the specified conditions are met.
Enable If: - Enables the property if the specified conditions are met.

Creating a validator script for verifying an input property

If the validation options are not adequate, you can create a script. Following is an example of a validator script written in Javascript code that verifies whether a value entered by the user is a number less than the maximum allowable value of 1024:

function(propertyValue, lang, displayType){
  var jObject = JSON.parse(propertyValue.value);
  if(displayType == "config"){
    if( jObject.luSize > 10){
      return "lu size should be under 10"
    }
    if( jObject.blockSize > 2){
      return "block size should be under 2";
    }
  }
  
 return
}

The following table shows the validator script specifications for the input property.

Name Description
Validator script format

function (arg1, arg2, arg3) {

//code

}

Validator script arguments

arg1:

Property value in string format

arg2:

Locale string. (for example, ja or en)

arg3:

Operating information when script is running (Operation with task creation: exec, Editing operation of properties: config)

Validator scrips return value*

Success:

undefined, null

Failure:

Error message in array or string format

* If the value is not a number or is larger than the specified maximum, a message appears in the user interface.

Using external resource data for input properties

When you specify "Selection" as the input property presentation, you can use the external resource data listed in the menu. You can create the external resource provider by using Service Builder to set up and access the external resource data.

Create an external resource provider by using Service Builder

You can create a new external resource provider by clicking Add New External Resource Provider at the bottom of the list. You can also specify an existing external resource provider from the list.

In the Create External Resource Provider dialog box, enter the following information:

  • Name: Specifies the name of the external resource provider.
  • Version: Specifies the version number.
  • Content Type: Selects either application/json or text/csv.
  • Schema ID: Specifies the schema ID of the domain type corresponding to the external resource provider. This helps users select an external resource provider in the property for service and plug-in setting dialog boxes; in the list of external resource providers, those with the same schema ID as the selected domain type are highlighted in blue.
  • Description: Specifies a description for the external resource provider.
  • Type: Select either Javascript, Script, Command Line, or File. Depending on your selection, enter the required information in the field.

When specifying Javascript for the type

The following table shows the Javascript specifications for the external resource provider.

Name Description
Script format function fn (requestPath, queryParamMap, properties) { // code }
Arguments of script requestPath:

A value of Extra Path which is specified in the Create/Edit Input Property for Service dialog box.

queryParamMap:

A JSON object including key-value maps which is specified as Query Param in the Create/Edit Input Property for Service dialog box.

properties:

A JSON object including service share properties and reserved properties which is related to external resource provider. The reserved properties are the following:

  • reserved.external.hcmds.dir
  • reserved.external.path
  • reserved.external.query
  • reserved.external.resource.dir
  • reserved.external.userName

You can obtain the value of the property using properties["property key"].

Return value of script Return an array of JSON objects which are listed in the menu. The array to be returned must be set to a property named "data".

In the script, you can use one of the following utility functions:

  • Built-in CM-REST methods
  • env function
  • auto util library
Note: Since the JavaScript Plug-in for Configuration Manager REST API that includes the built-in CM-REST methods and env function is scheduled end support in a future release, you should use the auto util library when running the Configuration Manager REST API on the external resource provider.

See "Using the auto util library" below for the sample codes to migrate from the built-in CM-REST methods and env function to the auto util library.

Using the built-in CM-REST methods

You can use the modules that are available in the JavaScript Plug-in for Configuration Manager REST API as follows:

  • ConfigurationManager._0x_xx_xx.api
  • ConfigurationManager._0x_xx_xx.model
  • ConfigurationManager._0x_xx_xx.enum
  • ConfigurationManager._0x_xx_xx.lib
Note: "_0x_xx_xx" is corresponding to the version of the JavaScript Plug-in for Configuration Manager REST API. When the version is 01.51.01, it will be "_01_51_01".

Using env functions

You can use "env" functions to get context information. The following table shows the specification of the functions of the env object.

Function Description
env.getWebServiceConnections(category) Get a listing of Web Service Connections.

Input parameters:

category: Category name of Web Service Connection.

Return value: A listing of JSON objects of Web Service Connections with the same category name as the one specified as an input parameter. When the external resource provider is called by a service, Web Service Connections that are accessible by the service are obtained by considering the defined relation between Service, Service Group, Infrastructure Group, and Web Service Connection.

env.setWebServiceConnection(apiObject, category, name, basePath) Set the Web Service Connection to the apiObject. The Web Service Connection is used in the external connection by the specified apiObject.

Input parameters:

  • apiObject: Instance of ObjectsApi of the built-in CM-REST module.
  • category: Category name of Web Service Connection.
  • name: Name of Web Service Connection
  • basePath: A path following a port number in the URL, which start with "/".

Return value:

No return value.

env.setHTTPProxy(apiObject, host, port, authenticationSchema, userName, password) When you do not use a Web Service Connection, set the HTTP Proxy settings to the apiObject.

Input parameters:

  • apiObject: Instance of ObjectsApi of the built-in CM-REST module.
  • host: Host name or URL of the proxy server.
  • port: Port number of the proxy server
  • authenticationSchema: basic or digest
  • userName: User name to authenticate.
  • password: Password to authenticate.

Return value:

No return value.

env.getServiceTemplate() Get the object of the service template by calling the external resource provider.

Input parameters:

No input parameters. Return value: Service template object

env.getService() Get the object of the service by calling the external resource provider.

Input parameters:

No input parameters. Return value: Service object

Using the auto util library

You can also use the auto util library. See the auto util library in the JavaScript Plug-in topic for more information.

The following shows sample codes when migrating from the code using the built-in CM-REST methods and the env function to the code using the auto util library as a means of running the Configuration Manager REST API.

Following is an sample code using the built-in CM-REST methods and the env function.

function fn(requestPath, queryParamMap, properties) {
  /** This is sample code that calls the Configuration Manager REST API. */
  /** Replace <VERSION> with the available version of the JavaScript Plug-in for Configuration Manager REST API. (e.g., put "_01_62_00" for the version of 01.62.00) */

  //Step 1. Instantiate the API Client.
  var client = new ConfigurationManager._02_80_00.api.ObjectsApi();

  //Step 2. Specify the User Credentials. There are two methods for specifying user credentials. You can use either method, but the first one is recommended.
  //Specify credentials by using the Web Service Connection.
  //Get accessible Web Service Connections by specifying a category name, and specify it. You do not need to specify credentials in a script.
  var wsc = env.getWebServiceConnections("ConfigurationManager");
  env.setWebServiceConnection(client, wsc[0].productName, wsc[0].name, "/ConfigurationManager");

  //Step 3. Get Session
  //You can pass arguments by using the plug-in input properties or you can specify them directly in a script. For example, you can pass the device ID through the query parameters (queryParamMap).
  var argSessionsPost = new ConfigurationManager._02_80_00.argDef.ObjectsApi.v1.objects.storages.storageDeviceID.sessions.post();
  argSessionsPost.setStorageDeviceID(queryParamMap.deviceId);
  var responseBody = client.v1.objects.storages.storageDevice
  ID.sessions.post(argSessionsPost);
  var token = responseBody.getToken();
  var sId = responseBody.getSessionId();

  //Step 4. Call the API that is associated with your use case based on the session obtained in Step 3.
  var argPoolsGet = new ConfigurationManager._02_80_00.argDef.ObjectsApi.v1.objects.storages.storageDeviceID.pools.get();
  argPoolsGet.setStorageDeviceID(queryParamMap.deviceId);
  argPoolsGet.setPoolType("DP");
  client.getApiClient().setApiKeyPrefix("Session");
  client.getApiClient().setApiKey(token);
  var pools = client.v1.objects.storages.storageDeviceID.pools.get(argPoolsGet);

  //Step 5. Make an array containing the required information.
  //An array to be returned has to be set to a property named "data".
  var ret = { "data": [] };
  var p;
  for (var i = 0; i < pools.getData().length; i++) {
    p = pools.getData()[i];
    ret.data.push({
      "Pool ID": p.getPoolId(),
      "Pool Type": p.getPoolType(),
      "Num of LDEVs": p.getNumOfLdevs()
    });
  }

  //Final Step. Discard Session.
  var argSessionIdDelete = new ConfigurationManager._02_80_00.argDef.ObjectsApi.v1.objects.storages.storageDeviceID.sessions.sessionId.delete();
  argSessionIdDelete.setStorageDeviceID(queryParamMap.deviceId);
  argSessionIdDelete.setSessionId(String(sId));
  client.v1.objects.storages.storageDeviceID.sessions.sessionId.delete(argSessionIdDelete);

  return ret;
  
}

Following is a sample code using the auto util library

function fn(requestPath, queryParamMap, properties) {
  /** This is sample code that calls the Configuration Manager REST API. */

  //Step 1. Generate a method to run REST API to Configuration Manager.
  var configurationManagerCall = function(request) {
    var respBody = null;
    auto.util.http.handleCall(auto.util.storage.restCall, request,
      function(resp, req) {
        respBody = auto.util.parseJson(resp.responseBody);
      }, function(resp, req) {
        auto.util.http.defaultErrorHandler(null, req, resp);
      }, function(err, req) {
        auto.util.http.defaultErrorHandler(err, req);
      }, auto.util.storage.retrySettings
    );
    return respBody;
  };
  
  //Step 2. Get accessible Web Service Connections by specifying a category name.
  var wsc = auto.util.env.getWebServiceConnections("ConfigurationManager");
  
  //Step 3. Get Session
  //You can pass arguments by using the plug-in input properties or you can specify them directly in a script. For example, you can pass the device ID through the query parameters (queryParamMap).
  var request = {
    "requestMethod": "POST",
    "requestUrl": "/ConfigurationManager/v1/objects/storages/" + queryParamMap.deviceId + "/sessions",
    "requestHeaders": auto.util.http.toRawHeader({}),
    "authScheme": "basic",
    "connectionName": wsc[0].name,
    "productName": wsc[0].productName
  };
  var respBody = configurationManagerCall(request);
  var token = respBody.token;
  var sId = respBody.sessionId;

  //Step 4. Call the API that is associated with your use case based on the session obtained in Step 3.
//When specifying the Authorization header for the request in the user program, specify "none" for authScheme.
  var headers = {
    "Authorization": "Session " + token,
  };
  var queryMap = {
    "poolType" : "DP"
  };
  var queryStr = auto.util.http.buildQuery(queryMap);
  request = {
    "requestMethod": "GET",
    "requestUrl": "/ConfigurationManager/v1/objects/storages/" + queryParamMap.deviceId + "/pools" + queryStr,
    "requestHeaders": auto.util.http.toRawHeader(headers),
    "authScheme": "none",
    "connectionName": wsc[0].name,
    "productName": wsc[0].productName
  };
  var pools = configurationManagerCall(request);

  //Step 5. Make an array containing the required information.
  //An array to be returned has to be set to a property named "data".
  var ret = { "data": [] };
  var p;
  for (var i = 0; i < pools.data.length; i++) {
    p = pools.data[i];
    ret.data.push({
      "Pool ID": p.poolId,
      "Pool Type": p.poolType,
      "Num of LDEVs": p.numOfLdevs
    });
  }

  //Final Step. Discard Session.
  request = {
    "requestMethod": "DELETE",
    "requestUrl": "/ConfigurationManager/v1/objects/storages/" + queryParamMap.deviceId + "/sessions/" + sId,
    "requestHeaders": auto.util.http.toRawHeader(headers),
    "authScheme": "none", 
    "connectionName": wsc[0].name,
    "productName": wsc[0].productName
  };
  configurationManagerCall(request);

  return ret;

}

When specifying Script for the type

Python is supported as a script type. Specify the path to the Python interpreter that runs the script, and edit a script. The supported versions of Python are version 3.x series. To use this external resource provider in a cluster environment, the Python interpreter must be installed on both the active and standby systems. This external resource provider does not support a virtual Python environment.

Environment variables that can be referenced from the script

The following table shows the environment variables that are allowable in the script. You can get the values for the following environment variables in the os.environ[key-name] or os.environ.get(key-name) format.

Environment variable Description Format
REQUEST_PATH Information specified as Extra Path in the Create/Edit Input Property for Service dialog box String

/external-resource-provider-ID/value-specified-as-extra-path

QUERY_PARAM_MAP Information specified as Query Param in the Create/Edit Input Property for Service dialog box JSON format

{property-name:value, ...}

SERVICE_TEMPLATE_ID ID of the service template to which the Python plug-in belongs Numerical value
SERVICE_ID ID of the service running the Python plug-in Numerical value
SERVICE_TEMPLATE Information about the service template to which the Python plug-in belongs JSON format

{service-template-attribute:value, ...}

SERVICE Information about the service running the Python Plug-in JSON format

{service-attribute:value, ...}

STORAGE_PROFILES Information about the Storage Profile JSON format

[{ StorageProfile-attribute:value, ... }, ...]

WEB_SERVICE_CONNECTIONS Settings information for the Web Service Connection. This corresponds to the query parameters ("__webServiceConnectionCategory__" and "__webServiceConnectionName__") specified in Query Param seen in the following table. JSON format

[{ WebServiceConnection-attribute:value, ... }, ...]

Query Param Parameters Reference information
__webServiceConnectionCategory__ __webServiceConnectionName__
Parameter is specified. (Y) Parameter is specified. (Y) Web Service Connection information that coincides with the specified Category and Name
Parameter is specified. (Y) Parameter is not specified. (N) Web Service Connection information that coincides with the specified Category
Parameter is not specified. (N) Parameter is specified. (Y) None
Parameter is not specified. (N) Parameter is not specified. (N) None

When specifying command line for the type

Enter the command line to run.

  • An error is generated if the return value of the command is not 0.
  • The upper limit for standard output is 30 MB and an error is generated if this limit is exceeded.
  • When specifying a script file, use the absolute path because the current path is not specified.
  • The service share property and the reserved property can be included in a command line. If including a service share property or a reserved property, surround the property key with "${" and "}".
  • The character set for a standard output assumes the character set of the system and the associated user. (For example, in the case of Windows OS with Japanese Locale, MS-932, and in the case of Linux OS, the user who last ran the start command.)
  • In the command line, you can refer to the values for the environment variables. The referable environment variables are the same as when specifying Script for the type. Note that the method of obtaining the value for the environment variable depends on the script language, as shown in the following table.
Item How to get the environment variable value
Command script (Windows) %key-name%
Shell script (Linux) $key-name
PowerShell script $env:key-name

The following example shows how host names are acquired through a program such as Powershell, and are then visible in a list as follows:

Command line:
powershell.exe \"& '${reserved.external.resource.dir}\\getHosts.ps1' ${reserved.external.hcmds.dir} ${reserved.external.userName}\"

Output of a command line:
name,instanceID
host1,123
host2,124
host3,125
host4,126
host5,127

The list item displayed on the Config/Submit window of the service:
host1
host2
host3
host4
host5

When specifying file for the type

Enter the path of the files. The service share property and the reserved property can be included in a file path. If including a service share property or a reserved property, surround the property key with "${" and "}".

In the following example, the host data is acquired from JSON file and output by using another application.

File:
${reserved.external.resource.dir}\\vm.json

vm.json :
{
"data" :[ {
"instanceID" :127,
"name" :"test1"
}, {
"instanceID" :128,
"name" :"test2"
} ]
}

The list item displayed on the Config/Submit window of the service:
test1
test2

Upload a file to an external resource provider

You can upload files to an external resource provider by clicking Upload in the external resource provider list. You can update a .zip archive file. After updating files, you can specify the relative path name in the command line as a file path.

Delete an external resource provider

You can delete an external resource provider by clicking Delete in the external resource provider list. When you click Delete, the Delete Confirmation dialog box appears. The dialog box lists the service templates and plug-ins using the external resource provider you plan to delete. When you confirm that there is no related service templates and plug-ins, click OK and the external resource is deleted. If you delete an external resource provider that is used by a service template, the external resource provider no longer works with the service template.