The JavaScript Plug-in for Configuration Manager REST API runs any script written in JavaScript and includes methods for accessing Configuration Manager REST API.
See JavaScript Plug-in for more details.
The relationship between the specification of Configuration Manager REST API and the specification of methods and data models that are available in the script of this plug-in, is as follows:
- The path name of each API, the method with the name where the "/"(slash) separator is replaced with a "."(dot) separator, is provided through the plug-in.
- The HTTP Method can be specified such as "~.get(…", "~.post(…" at the end of the method name.
- The variables and the query parameters in the API path can be specified as the arguments of the method.
- The Request Body can be given to the arguments as the relevant data model.
When the HTTP status code of the Configuration Manager REST API is 503, the retry is performed with the following retry count and interval:
- Retry count: 130
- Retry interval: 30 seconds
The maximum number of concurrent plug-in runs is 30. Even if you specify a value more than 30 for plugin.threadPoolSize in config_user.properties, the number of concurrent plug-in runs is limited to 30.
If the specified value for plugin.threadPoolSize is less than or equal to 30, the maximum number of concurrent plug-in runs will be the specified value for plugin.threadPoolSize.
Return codes
The JavaScript Plug-in for Configuration Manager REST API generates the following return codes.
Return Code | Description |
---|---|
0 | Ended normally. |
1 | Script has ended due to an error. |
60 | A JavaScript library read error has occurred. |
61 | A JavaScript compile error has occurred. |
62 | The JavaScript code is not properly formatted. |
63 | An error occurred during the processing of the plug-in. |
80 | Task execution has stopped. |
Property list
The following properties are available for the JavaScript Plug-in for Configuration Manager REST API:
Property key | Property name | Description | I/O type |
---|---|---|---|
webServiceConnectionCategory | Web Service Connection Category | Specify the Web Service Connection category. By the combination of this property and Web Service Connection Name, Web Service Connection can be identified uniquely. | Input |
webServiceConnectionName | Web Service Connection Name | Specify the Web Service Connection name. If this property and Web Service Connection Category are specified, Web Service Connections registered into Ops Center Automator are searched and if there is matching one, its URL and Proxy are used at the time of API call. | Input |
baseUrl | Base URL | Specify the base URL at the time of API call. - The input format is "<protocol>://<host>:<port>/". - The subsequent resource path and the query parameters cannot be specified. See details on WebServiceConnection. | Input |
requestHeaders | Request Headers | Specify the HTTP request headers appended at each API call. Main usage is the various authentications. Specify as the following format (The leading and trailing white spaces of the header name and the value are ignored.): < Header-name-of-Header1 > : < Value-of-Header1 > \n < Header-name-of-Header2 > : < Value-of-Header2 > \n You can specify any additional headers. However, since the header required to connect with Configuration Manager REST API (such as credential) is automatically appended, basically it is not necessary to specify the header here. | Input |
webUsername | Server Authentication Basic User Name | Specify the user name used for server authentication. | Input |
webPassword | Server Authentication Basic Password | Specify the password used for server authentication. | Input |
useProxy | Use Proxy Server | Set this to true when a proxy connection is required. | Input |
ApiKey | Server Authentication API Key | Specify the API key for authentication (used together with API Key Prefix) | Input |
ApiKeyPrefix | Server Authentication API Key Prefix | Specify the API Key Prefix for authentication (used together with API Key). The following part of HTTP header. Authorization: [API Key Prefix] [API Key]. | Input |
proxyHostname | Proxy Hostname | Specify the proxy host name or IP address. | Input |
proxyPort | Proxy Port Number | Specify the proxy port number. | Input |
proxyAuth | Proxy Server Authentication Scheme | Specifies the proxy authentication type. The following
authentication functions are supported:
|
Input |
proxyUsername | Proxy Username | Specify the user name used for proxy authentication. | Input |
proxyPassword | Proxy Password | Specify the password used for proxy authentication. | Input |
scriptBody | Script body | Specifies the JavaScript code strings. This property is required. |
Input |
importedScript | Imported script |
Specifies methods and constants (code string of JavaScript) to be used in common with other JavaScript Plug-in for Configuration Manager REST API plug-ins placed on the same service template. The following items can be used in the script of importedScript:
|
Input |
arg0 | Argument(0) | Specifies an argument to be passed to the script. | Input |
arg1 | Argument(1) | Specifies an argument to be passed to the script. | Input |
arg2 | Argument(2) | Specifies an argument to be passed to the script. | Input |
arg3 | Argument(3) | Specifies an argument to be passed to the script. | Input |
arg4 | Argument(4) | Specifies an argument to be passed to the script. | Input |
arg5 | Argument(5) | Specifies an argument to be passed to the script. | Input |
arg6 | Argument(6) | Specifies an argument to be passed to the script. | Input |
arg7 | Argument(7) | Specifies an argument to be passed to the script. | Input |
arg8 | Argument(8) | Specifies an argument to be passed to the script. | Input |
arg9 | Argument(9) | Specifies an argument to be passed to the script. | Input |
notify | Notification flag | Specifies a non-empty string if the script detects something to notify; the plug-in ends with a return value of 1 if a non-empty string was specified here. | Output |
returnValue | Return value | The content of the object returned from the function of the specified script is output as a character string. | Output |
out0 | Output(0) | A value set to the out0 key in the map of the second argument in the user-specified script is output. | Output |
out1 | Output(1) | A value set to the out1 key in the map of the second argument in the user-specified script is output. | Output |
out2 | Output(2) | A value set to the out2 key in the map of the second argument in the user-specified script is output. | Output |
out3 | Output(3) | A value set to the out3key in the map of the second argument in the user-specified script is output. | Output |
out4 | Output(4) | A value set to the out4 key in the map of the second argument in the user-specified script is output. | Output |
out5 | Output(5) | A value set to the out5 key in the map of the second argument in the user-specified script is output. | Output |
out6 | Output(6) | A value set to the out6 key in the map of the second argument in the user-specified script is output. | Output |
out7 | Output(7) | A value set to the out7 key in the map of the second argument in the user-specified script is output. | Output |
out8 | Output(8) | A value set to the out8 key in the map of the second argument in the user-specified script is output. | Output |
out9 | Output(9) | A value set to the out9 key in the map of the second argument in the user-specified script is output. | Output |
The setting value of Web Service Connection can be referred to as a value of the input property of the Plug-in. In this case, the corresponding input property is overwritten by the setting value of the Web Service Connection. Whether to refer to the setting value of Web Service Connection is determined by the input value of webServiceConnectionCategory and webServiceConnectionName. When referring to the setting value of WebServiceConnection, the URL (property name: baseUrl) is ignored.
You specify the plug-in input/output properties in the property list. Combinations of service property values, reserved property values, and literal characters can be used for the input properties.
Input Value of webServiceConnectionCategory | Input Value of webServiceConnectionName | Behavior of the plug-in |
---|---|---|
Exist | Exist | See the value of Web Service Connection. If no matching Web Service Connection is found, it becomes a run-time error. |
Exist | Not exist | Error (tried to refer to Web Service Connection, but did not find the matching one). |
Not exist | Exist | Error (tried to refer to Web Service Connection, but did not find the matching one). |
Not exist | Not exist | Do not refer to the value of Web Service Connection. |
JavaScript code specifiable for the JavaScript body
The following table shows the JavaScript codes that are allowable in the body of the script:
Character encoding | UTF-8 | ||||
Available JS Library |
underscore.js 1.8.3 auto_util-1.0.1.js (Bundled library of Ops Center Automator) |
||||
Format | Must be an unnamed function (See the sample code.) | ||||
Function call interface | Argument | serviceProperties | Object type | Service properties are mapped. The values of the service properties can be viewed from the script. Note that even if the script updates, deletes, or adds any of the values, the modified values will not be reflected in the service properties after the script is called. | |
pluginProperties | Object type | Plug-in properties are mapped. The values of the plug-in properties can be viewed from the script. | |||
arg0 to arg9 | Strings specified in the plug-in properties are directly mapped. Even the strings conform to JSON, if the script refers to here, and arguments can be obtained as strings, not objects. When you do not expect the validation from JSON strings to objects described afterwards, verify here. | ||||
notify | If you specify a value other than a non-empty string to a member specified for notify in the script, the plug-in finishes with a return value of 1 after calling. | ||||
out0 to out9 | If you specify values to members specified for out0 to out9 in the script, the values are reflected in the plug-in output properties of Argument(0) to Argument(9) after calling. The values are reflected in the processing results of the script, and the results will be used for the next step. (See the sample code.) | ||||
arg0 to arg9 | Plug-in properties Argument(0) to Argument(9) are mapped. (Optional)
If you specify JSON strings to the plug-in properties, the strings can be obtained as objects in the functions of the script.
|
||||
Return code | Any objects can be returned from the script. After calling the script, the return codes are extracted as JSON strings that are then reflected in the plug-in output property Return value. The values are reflected in the processing results of the script and then used for the next step. (See the sample code.) | ||||
print () function | By using the print() function in the script, you can output any strings to the task log. In this case, choose a log level by adding a specific prefix to the beginning of the string. Note that alphabetical prefixes are case-sensitive. (See the sample code.) | ||||
Prefix | [Severe] | Outputs as log level 0 | |||
[Information] | Outputs as log level 10 | ||||
[Fine] | Outputs as log level 20 | ||||
[Finer] | Outputs as log level 30 | ||||
[Debug] | Outputs as log level 40 | ||||
(No prefix) | Same as the prefix [Information] | ||||
Other functionalities | If an exception is thrown in the script or an unexpected exception occurs in the script, the plug-in ends abnormally and shows the exception in the task log. | ||||
When the script finishes properly, and when the values returned from the script or the values specified in the plug-in output properties (out0 to out9) of the script contain null or undefined, those values are stored as null or undefined. |
Sample code (scriptBody)
The following examples show the sample code of Configuration Manager REST API (HTTP) and the JavaScript that can be specified in the plug-in property JavaScript body:
Obtain Pool Information
[In the case of Configuration Manager REST API (HTTP)] HTTP Method: GET Request URL: ../ConfigurationManager/v1/objects/storages/<storageDeviceID>/pools?poolType=<poolType> Request Body: None [In the case of JavaScript Plug-in for Configuration Manager REST API] var client = new api.ObjectsApi(); var arg = new argDef.ObjectsApi.v1.objects.storages.storageDeviceID.pools.get(); arg.setStorageDeviceID(<storageDeviceID>); arg.setDetailInfoType(<detailInfoType>); arg.setPoolType(<poolType>); arg.setResponseMaxWait(<responseMaxWait>); arg.setResponseJobStatus(<responseJobStatus>); client.v1.objects.storages.storageDeviceID.pools.get(arg);
Register the Pool information
[In the case of Configuration Manager REST API (HTTP)] HTTP Method: POST Request URL: ../ConfigurationManager/v1/objects/storages/<storageDeviceID>/pools Request Body: { "poolId": 76, "poolName": "pool1", "ldevIds": [405], "poolType": "HDP" } [In the case of JavaScript Plug-in for Configuration Manager REST API] var reqBody = { poolId:76, poolName:"pool1", ldevIds:[405], poolType:"HDP" }; var client = new api.ObjectsApi(); var arg = new argDef.ObjectsApi.v1.objects.storages.storageDeviceID.pools.post(); arg.setStorageDeviceID(<storageDeviceID>); arg.setRequestBody(reqBody); arg.setResponseMaxWait(<responseMaxWait>); arg.setResponseJobStatus(<responseJobStatus>); client.v1.objects.storages.storageDeviceID.pools.post(arg);
Sample code (scriptBody/importedScript)
The following examples show the sample code of Configuration Manager REST API that can be specified in the plug-in property scriptBody/importedScript:
------------------------------------------- (scriptBody) ------------------------------------------- function fn(serviceProperties, pluginProperties, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { hoge(CNST); } ------------------------------------------- (importedScript) ------------------------------------------- var CNST = "hoge"; function hoge(a){ print(a + " from common js!"); } -------------------------------------------