SetVmHostname
API Request
URLs
PUT zstack/v1/vm-instances/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"setVmHostname": {
"hostname": "vm1.zstack.org"
},
"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 '{"setVmHostname":{"hostname":"vm1.zstack.org"}}' \
http://localhost:8080/zstack/v1/vm-instances/0d71345add0230f2a893e7789a831b81/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The VM instance UUID. | 0.6 | |
| hostname | String | body (contained in the setVmHostname structure) | The hostname, which must conform to the RFC 1123 specification. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
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
SetVmHostnameAction action = new SetVmHostnameAction();
action.uuid = "ce11eb85ff0f417c9f1255f43e0bb124";
action.hostname = "vm1.zstack.org";
action.sessionId = "fc2d7aab6f0545029fa52fa068dabfbb";
SetVmHostnameAction.Result res = action.call();Python
SDK
SetVmHostnameAction action = SetVmHostnameAction()
action.uuid = "7f11dce627ce4a0db39f20ce2e1afc57"
action.hostname = "vm1.zstack.org"
action.sessionId = "cb33487362ca41599fc2b43a119d8bc6"
SetVmHostnameAction.Result res = action.call()