Automated O&M


CreateGuestVmScript

API Request

URLs
POST zstack/v1/scripts
Headers
Authorization: OAuth the-session-uuid
Body
{   "params": {     "name": "script1",     "description": "this is a script",     "scriptContent": "ZWNobyBoZWxsb3dvcmxkCg\u003d\u003d",     "renderParams": "[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]",     "platform": "Linux",     "scriptType": "Shell",     "scriptTimeout": 30   },   "systemTags": [],   "userTags": [] }
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"script1","description":"this is a script","scriptContent":"ZWNobyBoZWxsb3dvcmxkCg==","renderParams":"[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]","platform":"Linux","scriptType":"Shell","scriptTimeout":30}}' http://localhost:8080/zstack/v1/scripts
Request Parameters
Name Type Location Description Valid Values Starting Version
name String body (contained in the params structure) The resource name. 5.2.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 5.2.0
scriptContent String body (contained in the params structure) The script content. 5.2.0
renderParams String body (contained in the params structure) Optional. The custom parameters. 5.2.0
platform String body (contained in the params structure) The platform.
  • Windows
  • Linux
5.2.0
scriptType String body (contained in the params structure) The script type.
  • Shell
  • Python
  • Perl
  • Bat
  • Powershell
5.2.0
scriptTimeout int body (contained in the params structure) Optional. The timeout period. 5.2.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 5.2.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 5.2.0
systemTags List body Optional. The system tags. 5.2.0
userTags List body Optional. The user tags. 5.2.0

API Response

Sample Response
{   "inventory": {     "uuid": "a90f02b86916371a87bb5f2716dbfc0c",     "name": "script1",     "description": "this is a script",     "scriptContent": "echo helloworld",     "renderParams": "[{\"key\":\"key\",\"value\":\"value\",\"description\":\"description\"}]",     "platform": "Linux",     "scriptType": "Shell",     "scriptTimeout": 30,     "createDate": "Sep 23, 2024 11:53:59 AM",     "lastOpDate": "Sep 23, 2024 11:53:59 AM"   } }
Name Type Description Starting Version
success boolean 5.2.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 5.2.0
inventory GuestVmScriptInventory See inventory 5.2.0
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 5.2.0
description String The brief description of the error. 5.2.0
details String The details about the error. 5.2.0
elaboration String The reserved field. Default value: null. 5.2.0
opaque LinkedHashMap The reserved field. Default value: null. 5.2.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 5.2.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 5.2.0
name String The resource name. 5.2.0
description String The detailed description of the resource. 5.2.0
scriptContent String The script content. 5.2.0
renderParams String The custom parameters. 5.2.0
platform String The platform 5.2.0
scriptType String The script type. 5.2.0
scriptTimeout Integer The timeout period. 5.2.0
createDate Timestamp The creation time. 5.2.0
lastOpDate Timestamp The last operation time. 5.2.0

SDK Sample

Java SDK
CreateGuestVmScriptAction action = new CreateGuestVmScriptAction(); action.name = "script1"; action.description = "this is a script"; action.scriptContent = "ZWNobyBoZWxsb3dvcmxkCg=="; action.renderParams = "[{"key":"key","value":"value","description":"description"}]"; action.platform = "Linux"; action.scriptType = "Shell"; action.scriptTimeout = 30; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; CreateGuestVmScriptAction.Result res = action.call();
Python SDK
CreateGuestVmScriptAction action = CreateGuestVmScriptAction() action.name = "script1" action.description = "this is a script" action.scriptContent = "ZWNobyBoZWxsb3dvcmxkCg==" action.renderParams = "[{"key":"key","value":"value","description":"description"}]" action.platform = "Linux" action.scriptType = "Shell" action.scriptTimeout = 30 action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" CreateGuestVmScriptAction.Result res = action.call()

DeleteGuestVmScript

API Request

URLs
DELETE zstack/v1/scripts/{uuid}
Headers
Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X DELETE http://localhost:8080/zstack/v1/scripts/ed1ef717239e37c29163dcad7576b8d4
Request Parameters
Name Type Location Description Valid Values Starting Version
uuid String url The resource UUID. 5.2.0
deleteMode String body The deletion mode.
  • Permissive
  • Enforcing,Permissive
5.2.0
systemTags List body Optional. The system tags. 5.2.0
userTags List body Optional. The user tags. 5.2.0

API返回

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{ 	"error": { 		"code": "SYS.1001", 		"description": "A message or a operation timeout", 		"details": "Create VM on KVM timeout after 300s" 	} }

SDK Sample

Java SDK
DeleteGuestVmScriptAction action = new DeleteGuestVmScriptAction(); action.uuid = "ed1ef717239e37c29163dcad7576b8d4"; action.deleteMode = "Permissive"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; DeleteGuestVmScriptAction.Result res = action.call();
Python SDK
DeleteGuestVmScriptAction action = DeleteGuestVmScriptAction() action.uuid = "ed1ef717239e37c29163dcad7576b8d4" action.deleteMode = "Permissive" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" DeleteGuestVmScriptAction.Result res = action.call()












Archives

Download Document Archives

Download

Already filled the basic info?Click here.

Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

An email with a verification code will be sent to you. Make sure the address you provided is valid and correct.

同意 不同意

I have read and concur with the Site TermsPrivacy PolicyRules and Conventions on User Management of ZStack Cloud

Download

Not filled the basic info yet? Click here.

Invalid email address or mobile number.
同意 不同意

I have read and concur with the Site TermsPrivacy PolicyRules and Conventions on User Management of ZStack Cloud

Email Us

contact@zstack.io
ZStack Training and Certification
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

同意 不同意

I have read and concur with the Site TermsPrivacy PolicyRules and Conventions on User Management of ZStack Cloud

Email Us

contact@zstack.io
Request Trial
Enter at least 2 characters.
Invalid mobile number.
Enter at least 4 characters.
Invalid email address.
Wrong code. Try again. Send Code Resend Code (60s)

同意 不同意

I have read and concur with the Site TermsPrivacy PolicyRules and Conventions on User Management of ZStack Cloud

Email Us

contact@zstack.io

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder. After receiving the email, click the URL to download the documentation.

The download link is sent to your email address.

If you don't see it, check your spam folder, subscription folder, or AD folder.
Or click on the URL below. (For Internet Explorer, right-click the URL and save it.)

Thank you for using ZStack products and services.

Submit successfully.

We'll connect soon.

Thank you for using ZStack products and services.