XML Hook
CreateVmUserDefinedXmlHookScript
API Request
POST zstack/v1/vm-instances/xml-hook-scriptAuthorization: OAuth the-session-uuid{
"params": {
"name": "hook",
"description": "xml hook",
"hookScript": "base64"
},
"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":"hook","description":"xml hook","hookScript":"base64"}}' http://localhost:8080/zstack/v1/vm-instances/xml-hook-script
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The XML Hook name. | 5.2.0 | |
| description | String | body (contained in the params structure) | Optional. The detailed information of the XML Hook. | 5.2.0 | |
| hookScript | String | body (contained in the params structure) | The XML Hook content. | 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
{
"inventory": {}
}| 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 | XmlHookInventory | See inventory | 5.2.0 |
| 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 |
| Name | Type | Description | Satrting Version |
|---|---|---|---|
| uuid | String | The XML Hook UUID. | 5.2.0 |
| name | String | The XML Hook name. | 5.2.0 |
| description | String | The detailed information of the XML Hook. | 5.2.0 |
| hookScript | String | The XML Hook content. | 5.2.0 |
| libvirtVersion | String | The Libvirt version. | 5.2.0 |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
| type | XmlHookType | See type | 5.2.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| System | XmlHookType | 5.2.0 | |
| Customization | XmlHookType | 5.2.0 |
SDK Sample
CreateVmUserDefinedXmlHookScriptAction action = new CreateVmUserDefinedXmlHookScriptAction();
action.name = "hook";
action.description = "xml hook";
action.hookScript = "base64";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmUserDefinedXmlHookScriptAction.Result res = action.call();CreateVmUserDefinedXmlHookScriptAction action = CreateVmUserDefinedXmlHookScriptAction()
action.name = "hook"
action.description = "xml hook"
action.hookScript = "base64"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmUserDefinedXmlHookScriptAction.Result res = action.call()ExpungeVmUserDefinedXmlHookScript
API Request
DELETE zstack/v1/vm-instances/xml-hook-script/{uuid}Authorization: OAuth the-session-uuidCurl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vm-instances/xml-hook-script/99df64f50f5b34c6be5a7339d676aeb6
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The XML Hook UUID. | 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
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
ExpungeVmUserDefinedXmlHookScriptAction action = new ExpungeVmUserDefinedXmlHookScriptAction();
action.uuid = "99df64f50f5b34c6be5a7339d676aeb6";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ExpungeVmUserDefinedXmlHookScriptAction.Result res = action.call();ExpungeVmUserDefinedXmlHookScriptAction action = ExpungeVmUserDefinedXmlHookScriptAction()
action.uuid = "99df64f50f5b34c6be5a7339d676aeb6"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ExpungeVmUserDefinedXmlHookScriptAction.Result res = action.call()UpdateVmUserDefinedXmlHookScript
API Request
PUT zstack/v1/vm-instances/xml-hook-scriptAuthorization: OAuth the-session-uuid{
"updateVmUserDefinedXmlHookScript": {
"uuid": "a44a23f78c9c391c9d2f3a6a576e77d6",
"name": "example"
},
"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 PUT -d '{"updateVmUserDefinedXmlHookScript":{"uuid":"a44a23f78c9c391c9d2f3a6a576e77d6","name":"example"}}' http://localhost:8080/zstack/v1/vm-instances/xml-hook-script
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | body (contained in the updateVmUserDefinedXmlHookScript structure) | The XML Hook UUID. | 5.2.0 | |
| name | String | body (contained in the updateVmUserDefinedXmlHookScript structure) | Optional. The XML Hook name. | 5.2.0 | |
| description | String | body (contained in the updateVmUserDefinedXmlHookScript structure) | Optional. The detailed information of the XML Hook. | 5.2.0 | |
| hookScript | String | body (contained in the updateVmUserDefinedXmlHookScript structure) | Optional. The XML Hook content. | 5.2.0 | |
| systemTags | List | body | Optional. The system tags. | 5.2.0 | |
| userTags | List | body | Optional. The user tags. | 5.2.0 | |
| startupStrategy | String | body (contained in the updateVmUserDefinedXmlHookScript structure) | Optional. Whether reboot associated VM instances immediately. |
|
5.2.0 |
API Response
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
UpdateVmUserDefinedXmlHookScriptAction action = new UpdateVmUserDefinedXmlHookScriptAction();
action.uuid = "a44a23f78c9c391c9d2f3a6a576e77d6";
action.name = "example";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVmUserDefinedXmlHookScriptAction.Result res = action.call();UpdateVmUserDefinedXmlHookScriptAction action = UpdateVmUserDefinedXmlHookScriptAction()
action.uuid = "a44a23f78c9c391c9d2f3a6a576e77d6"
action.name = "example"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateVmUserDefinedXmlHookScriptAction.Result res = action.call()AttachUserDefinedXmlHookScriptToVm
API Request
POST zstack/v1/xmlhook/{xmlHookUuid}/vm-instances/{vmInstanceUuid}Authorization: OAuth the-session-uuid{
"params": {
"startupStrategy": "None"
},
"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":{"startupStrategy":"None"}}' http://localhost:8080/zstack/v1/xmlhook/73300c2b203e3e43bc4b0dec7c3b0f21/vm-instances/6baaffd8cb123dcc954b6242835267b9
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 5.2.0 | |
| xmlHookUuid | String | url | The XML Hook UUID. | 5.2.0 | |
| startupStrategy | String | body (contained in the params structure) | Optional. Whether reboot the VM instance immediately. |
|
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
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
AttachUserDefinedXmlHookScriptToVmAction action = new AttachUserDefinedXmlHookScriptToVmAction();
action.vmInstanceUuid = "6baaffd8cb123dcc954b6242835267b9";
action.xmlHookUuid = "73300c2b203e3e43bc4b0dec7c3b0f21";
action.startupStrategy = "None";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachUserDefinedXmlHookScriptToVmAction.Result res = action.call();AttachUserDefinedXmlHookScriptToVmAction action = AttachUserDefinedXmlHookScriptToVmAction()
action.vmInstanceUuid = "6baaffd8cb123dcc954b6242835267b9"
action.xmlHookUuid = "73300c2b203e3e43bc4b0dec7c3b0f21"
action.startupStrategy = "None"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachUserDefinedXmlHookScriptToVmAction.Result res = action.call()DetachUserDefinedXmlHookScriptFromVm
API Request
DELETE zstack/v1/xmlhook/vm-instances/{vmInstanceUuid}/detachAuthorization: OAuth the-session-uuidCurl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/xmlhook/vm-instances/588ac603fdd73c7c8519235a73271188/detach
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 5.2.0 | |
| startupStrategy | String | body | Optional. Whether reboot the VM instance immediately. |
|
5.2.0 |
| deleteMode | String | body | Optional. The deletion mode. |
|
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
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
DetachUserDefinedXmlHookScriptFromVmAction action = new DetachUserDefinedXmlHookScriptFromVmAction();
action.vmInstanceUuid = "588ac603fdd73c7c8519235a73271188";
action.startupStrategy = "None";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachUserDefinedXmlHookScriptFromVmAction.Result res = action.call();DetachUserDefinedXmlHookScriptFromVmAction action = DetachUserDefinedXmlHookScriptFromVmAction()
action.vmInstanceUuid = "588ac603fdd73c7c8519235a73271188"
action.startupStrategy = "None"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachUserDefinedXmlHookScriptFromVmAction.Result res = action.call()QueryVmUserDefinedXmlHookScript
API Request
GET zstack/v1/vm-instances/xml-hook-script
GET zstack/v1/vm-instances/xml-hook-script/{uuid}Authorization: OAuth the-session-uuidCurl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/xml-hook-script?q=uuid=xxx&q=name=xxx
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/xml-hook-script/c2643474f4ca3bb1a5c9e821f53c3ed2
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryVmUserDefinedXmlHookScript, and pressing the Tab key.
API Response
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
QueryVmUserDefinedXmlHookScriptAction action = new QueryVmUserDefinedXmlHookScriptAction();
action.conditions = asList("uuid=xxx","name=xxx");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVmUserDefinedXmlHookScriptAction.Result res = action.call();QueryVmUserDefinedXmlHookScriptAction action = QueryVmUserDefinedXmlHookScriptAction()
action.conditions = ["uuid=xxx","name=xxx"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryVmUserDefinedXmlHookScriptAction.Result res = action.call()