ChangeHostState
API Request
URLs
PUT zstack/v1/hosts/{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.
{
"changeHostState": {
"stateEvent": "enable"
},
"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 '{"changeHostState":{"stateEvent":"enable"}}' \
http://localhost:8080/zstack/v1/hosts/70e37940fe263e858a151850a312143f/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| stateEvent | String | body (contained in the changeHostState structure) | The target state of the host. |
|
0.6 |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample Response
{
"inventory": {
"zoneUuid": "faf35db46f044232a96b1c9ac228f7a1",
"name": "example",
"uuid": "cf2e376062fe4a06bd5ab4d76cd88f5d",
"clusterUuid": "7f314660761a4899b5967b6f4aad88f3",
"description": "example",
"managementIp": "192.168.0.1",
"hypervisorType": "KVM",
"state": "Enabled",
"status": "Connected",
"totalCpuCapacity": 4.0,
"availableCpuCapacity": 2.0,
"totalMemoryCapacity": 4.0,
"availableMemoryCapacity": 4.0
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventory | HostInventory | See inventory. | 0.6 |
#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| zoneUuid | String | The zone UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| uuid | String | The resource UUID. | 0.6 |
| clusterUuid | String | The cluster UUID. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| managementIp | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| state | String | 0.6 | |
| status | String | 0.6 | |
| totalCpuCapacity | Long | 0.6 | |
| availableCpuCapacity | Long | 0.6 | |
| cpuSockets | Integer | 0.6 | |
| totalMemoryCapacity | Long | 0.6 | |
| availableMemoryCapacity | Long | 0.6 | |
| cpuNum | Integer | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
ChangeHostStateAction action = new ChangeHostStateAction();
action.uuid = "c5089a867d1c4d52a272b115da9fb51b";
action.stateEvent = "enable";
action.sessionId = "3523eb84bca24927b6c3a3177253ae55";
ChangeHostStateAction.Result res = action.call();Python
SDK
ChangeHostStateAction action = ChangeHostStateAction()
action.uuid = "16ae0707e32a4fc58153084e8649e8ab"
action.stateEvent = "enable"
action.sessionId = "dd5b5dd2df854908a044b74151f135e1"
ChangeHostStateAction.Result res = action.call()