Document navigation

USB Redirection Operations

GetVmUsbRedirect

API Request

URLs
GET zstack/v1/vm-instances/{uuid}/usbredirect
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth bb5fd18e914f4bfd88032edd0ee7b975" \
-X GET http://localhost:8080/zstack/v1/vm-instances/4b9d28c1d35f4f14b8ba1bb982500c50/usbredirect
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 2.1
systemTags List query Optional. The system tags. 2.1
userTags List query Optional. The user tags. 2.1

API Response

Sample Response
{
  "enable": true
}
Name Type Description Starting Version
enable boolean If true, the USB redirection switch is enabled,or vice versa. 2.1
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.1
#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. 2.1
description String The brief description of the error. 2.1
details String The details about the error. 2.1
elaboration String The reserved field. Default value: null. 2.1
opaque LinkedHashMap The reserved field. Default value: null. 2.1
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 2.1

SDK Sample

Java SDK
GetVmUsbRedirectAction action = new GetVmUsbRedirectAction();
action.uuid = "c58671c58dd147e29d4bc263feafa04d";
action.sessionId = "e173648fdca94fd3ae720473a305ce4c";
GetVmUsbRedirectAction.Result res = action.call();
Python SDK
GetVmUsbRedirectAction action = GetVmUsbRedirectAction()
action.uuid = "08efac4de45a4f6789d1009afa9e295e"
action.sessionId = "3f5a7473758d4c8ab3cc4664461500a4"
GetVmUsbRedirectAction.Result res = action.call()

SetVmUsbRedirect

API Request

URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "setVmUsbRedirect": {
    "enable": true
  },
  "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 '{"setVmUsbRedirect":{"enable":true}}' \
http://localhost:8080/zstack/v1/vm-instances/ceeca8ab8c6b33fab9bdc143dec13211/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 2.1
enable boolean body (contained in the setVmUsbRedirect structure) If true, the USB redirection switch is enabled,or vice versa.
  • true
  • false
2.1
systemTags List body Optional. The system tags. 2.1
userTags List body Optional. The user tags. 2.1

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

Java SDK
SetVmUsbRedirectAction action = new SetVmUsbRedirectAction();
action.uuid = "8c14cf1dd17642c19622c924d065bb00";
action.enable = true;
action.sessionId = "6a5e2cc211794d28b9e1641c1a53d018";
SetVmUsbRedirectAction.Result res = action.call();
Python SDK
SetVmUsbRedirectAction action = SetVmUsbRedirectAction()
action.uuid = "977cd1ae8b5f4dcab4c5f2062089ebf9"
action.enable = true
action.sessionId = "e6b4af2b358b44ea9fc3ff185d9af869"
SetVmUsbRedirectAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center