Document navigation

Script Library

Overview

The script library stores and manages script files centrally. By executing scripts on VM instances, you can complete complex O&M operations and automated jobs.

Figure 1. Script Library


Advantages

The script library feature provided by ZStack Cloud has the following advantages:
  • Simple and User-Friendly
    • Allows you to conveniently create a script in a visualized way and realize flexible script configurations by adding custom parameters.
    • You can include complex commands in a script. By executing this script, VM instances can complete complex operations, thus reducing the difficulty of manual O&M.
  • Convenient O&M
    • Provides a dedicated page, Script Library, for the central management of multiple scripts. On the Script Library page, you can flexibly create scripts and delete or modify existing scripts.
    • A script can be stored in the script library for long-term reuse. In addition, a script can be executed on multiple VM instances simultaneously without interference, thus effectively improving your O&M efficiency on large-scale scenarios.
    • Provides detailed script execution records, recording the VM instances that executed this script, execution start time, execution completion time, and execution result, facilitating your operation tracking and troubleshooting.
  • Diversity: Supports diversified command types, including Shell, Python, Perl, Bat, and Powershell. You can select a command type as you need.

Inventory

Properties

Name Description Optional Valid Values Starting Version
uuid The resource UUID. 5.2.0
name The resource name. 5.2.0
description The detailed description of the resource. 5.2.0
scriptContent The script content. 5.2.0
renderParams The custom parameters. 5.2.0
platform The platform. 5.2.0
scriptType The script type. 5.2.0
scriptTimeout The timeout period. 5.2.0
createDate The last operation data. See Resource Property 5.2.0
lastOpDate The last operation data. See Resource Property 5.2.0
userTags The user tags. For more information, see CreateUserTag. 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. 5.2.0
groupBy 5.2.0

Guest VM Script Execution Record Inventory

Name Description Optional Valid Values Starting Version
uuid The resource UUID. 5.2.0
scriptUuid The script UUID. 5.2.0
recordName The execution record name. 5.2.0
scriptTimeout The timeout period. 5.2.0
status The execution status. 5.2.0
executor The executor. 5.2.0
executionCount The execution times. 5.2.0
version The version. 5.2.0
scriptContent The script content. 5.2.0
startTime The start time. 5.2.0
endTime The end time. 5.2.0
tagUuid The tag UUID list. 5.2.0
userTags The user tags. For more information, see CreateUserTag. 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. 5.2.0
groupBy 5.2.0

Sample

{
    "inventories": [
        {
            "endTime": "Sep 4, 2024 5:42:39 PM",
            "executionCount": 1,
            "executor": "admin",
            "recordName": "20240904053437_system_info.ps1",
            "scriptTimeout": 480,
            "scriptUuid": "94e251dbd63f43d79077d62edfc694f0",
            "startTime": "Sep 4, 2024 5:34:37 PM",
            "status": "Failed",
            "uuid": "de2ea20623b545699d4f8d7561f8dd8f",
            "version": 3
        }
    ],
    "success": true
}

Guest VM Script Execution Record Details Inventory

Name Description Optional Valid Values Starting Version
recordUuid The execution record UUID. 5.2.0
vmInstanceUuid The VM instance UUID. 5.2.0
vmName The VM instance UUID. 5.2.0
status The execution status. 5.2.0
exitCode The exist code. 5.2.0
stdout The standard output. 5.2.0
errCause The error cause. 5.2.0
stderr The error output. 5.2.0
startTime The start time. 5.2.0
endTime The end time. 5.2.0
tagUuid The tag UUID list. 5.2.0
userTags The user tags. For more information, see CreateUserTag. 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. 5.2.0
groupBy 5.2.0

Sample

{
  "inventories": [
    {
      "recordUuid": "ab90a0142aef36fd97c3c759bc7e459d",
      "vmInstanceUuid": "4708f0f6f76e39e882886241761d0c27",
      "status": "Completed",
      "stdout": "helloworld",
      "errCause": "",
      "stderr": "1/0 is not a goodScript",
      "startTime": "Sep 23, 2024 11:53:03 AM",
      "endTime": "Sep 23, 2024 11:53:03 AM"
    }
  ]
}

Operations

CreateGuestVmScript

Create a script. For example,
CreateGuestVmScript name=script1 scriptContent=ZWNobyBoZWxsb3dvcmxkCg== platform=Linux scriptType=Shell scriptTimeout=30

Parameters

Name Description Optional Valid Values Starting Version
name The resource name. 5.2.0
description The detailed description of the resource. Yes 5.2.0
scriptContent The script content. 5.2.0
renderParams The custom parameters. Yes 5.2.0
platform The platform. 5.2.0
scriptType The script type. 5.2.0
scriptTimeout The timeout period. Yes 5.2.0
resourceUuid The resource UUID. Yes 5.2.0
tagUuids The tag UUID list. Yes 5.2.0
userTags The user tags. For more information, see CreateUserTag. Yes 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 5.2.0
timeout Yes

DeleteGuestVmScript

Deletes a script. For example,
DeleteGuestVmScript uuid=ed1ef717239e37c29163dcad7576b8d4

Parameters

Name Description Optional Valid Values Starting Version
name The resource name. 5.2.0
deleteMode The deletion mode. Yes
  • Permissive
  • Enforcing,Permissive
5.2.0
userTags The user tags. For more information, see CreateUserTag. Yes 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 5.2.0
timeout Yes

UpdateGuestVmScript

Updates a script. For example,
UpdateGuestVmScript uuid=110b774720573fd6aec8ec70b669ffb8 scriptContent=ls

Parameters

Name Description Optional Valid Values Starting Version
uuid The resource UUID. 5.2.0
name The resource name. Yes 5.2.0
description The detailed description of the resource. Yes 5.2.0
scriptContent The script content. Yes 5.2.0
renderParams The custom parameters. Yes 5.2.0
platform The platform. Yes 5.2.0
scriptType The script type. Yes 5.2.0
scriptTimeout The timeout period. Yes 5.2.0
userTags The user tags. For more information, see CreateUserTag. Yes 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 5.2.0
timeout Yes

ExecuteGuestVmScript

Executes a scripts on VM instances. For example,
ExecuteGuestVmScript uuid=f9f25df251013694bbbf68bb42b1bde1 vmInstanceUuids=c9cc2aa748383595b144d9d12ff3abb2

Parameters

Name Description Optional Valid Values Starting Version
uuid The resource UUID. 5.2.0
vmInstanceUuids The VM instance UUID. 5.2.0
scriptTimeout The timeout period. Yes 5.2.0
logPath The log path. Yes 5.2.0
userTags The user tags. For more information, see CreateUserTag. Yes 5.2.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 5.2.0
timeout Yes

QueryGuestVmScript

Queries a script. For example,
QueryGuestVmScript name=script1

Primitive Fields of Query

See Guest Vm Script Inventory.

QueryGuestVmScriptExecutedRecord

Queries script execution records. For example,
QueryGuestVmScriptExecutedRecord scriptUuid=94e251dbd63f43d79077d62edfc694f0

Primitive Fields of Query

See Guest VM Script Execution Record Inventory.

QueryGuestVmScriptExecutedRecordDetail

Queries script execution record details. For example,
QueryGuestVmScriptExecutedRecordDetail
CLI Command Manual | 5.4.12 | ZStack Cloud · ZCF | ZStack Resource Center