Creating Custom Scripts
Scenarios
If the public scripts provided by COC do not meet your requirements, you can create custom scripts in the format of Shell, Python, or Bat. The scripts can be used for global parameters and the associated parameter center.
Precautions
Confirm and complete the risk level of the script content.
Creating a Custom Script
- Log in to COC.
- In the navigation pane on the left, choose Resource O&M > Automated O&M.
- In the Routine O&M area, click Script Management.
- In the Custom Scripts tab page, click Create Script.
- Set parameters on the displayed page.
Table 1 Basic information parameters Parameter
Description
Example Value
Script Name
Customize a script name based on the naming rules.
Test Script
Enterprise Project
Select the enterprise project to which the script belongs from the drop-down list.
default
Version
Enter the script version number.
1.0.0
Risk Level
Select High, Medium, or Low as required.
High
Description
Enter a description about the script.
-
- Set Script Content.
- Select Shell, Python, or Bat.
- Enter the script content.
- The interpreter (for example, #!/usr/bin/python) that is automatically generated in the first row needs to be adapted to the Python soft link on your server. If the soft link is not available, you need to modify the interpreter to the one that can be executed by the server.
- (Optional) If input parameters are defined, use ${parameter_name} for the Shell script type in the script content. For the Python script type, use the environment variable (for example, varValue = os.getenv('parameter_name')) in the Python library of the OS. For the BAT script type, use %parameter_name%.
- Click Verify High-Risk Command.
- Verification scope: the high-risk commands involved in the verification. You can click High-Risk Commands to view the verification rules.
- Verification rule: Within the verification scope, the script content is matched with high-risk commands using regular expression matching.
- Verification result: The regular expression is used to verify whether the script content is high-risk, low-risk, or medium-risk.
The verification result of high-risk commands is only used as a reference for determining the risk level of scripts. The tool does not forcibly intercept the consistency between the risk level of scripts and the verification result of high-risk commands. Evaluate the risk level based on the actual service impact.
- (Optional) Set Script Input Parameters.
- Add execution parameters of the script. A maximum of 20 parameters can be added, and the parameter value can contain spaces. You can select the Sensitive check box to encrypt the parameter.
- Sensitive: Parameters are anonymized and encrypted for storage.
- Add execution parameters of the script. A maximum of 20 parameters can be added, and the parameter value can contain spaces. You can select the Sensitive check box to encrypt the parameter.
- (Optional) Set Advanced Settings.
- Manual Review: If this parameter is enabled, the script needs to be reviewed. For details about how to review, see Approving a Custom Script.
- Reviewer: Shift or Individual.
- Shift: Select a scenario and role from the drop-down lists based on the configured values. For details about how to configure a shift, see Shift Schedule Management.
- Individual: Select a reviewer. For details about how to configure a reviewer, see O&M Engineer Management.
- Notification Mode: Select a notification mode from the drop-down list.
- Default: Same as that selected in the reviewer subscription function. For details about how to set the default notification mode, see Selecting a Notification Method.
- SMS, WeCom, DingTalk, Phone, Lark, and Email: Notifications are sent based on the information reserved by the reviewer. For details about how to set reviewer information, see Modifying Personnel Information.
- No notification: The system does not notify any recipient.
- Click OK.
The custom script is created.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot