Get CPU and Memory Capacity (GetCpuMemoryCapacity)

API Request

URLs
GET zstack/v1/hosts/capacities/cpu-memory
Headers
Authorization: OAuth the-session-uuid
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/hosts/capacities/cpu-memory?zoneUuids=6510dcd4e77939d695b035ecbcfb217c&zoneUuids=33a39cd9391538a4a4d45666e8505dda&clusterUuids=b7c233dd9c573f63b5bb97f50028fa7f&clusterUuids=08d332af6fdb351da456aea3b6b5d029&hostUuids=ba1bfc20682136c4b2f76920af8f010e&hostUuids=b09cd47a6fa93302ae55918ef8da2af4&hypervisorType=KVM&all=true
Parameter List
Name Type Location Description Allowed Values Starting Version
zoneUuids (Optional) List query Data Center UUID 0.6
clusterUuids (Optional) List query Cluster UUID. Used for attaching networks, storage, etc. 0.6
hostUuids (Optional) List query Host UUID. Used for adding, deleting hosts, etc. 0.6
all (Optional) boolean query
  • Defaults to false. When false, at least one of Data Center UUID, Cluster UUID, or Host UUID must be specified, or all can be specified
  • When set to true, Data Center UUID, Cluster UUID, and Host UUID can all be omitted
0.6
hypervisorType (Optional) String query
  • KVM
  • ESC
0.6
systemTags (Optional) List query System tags 0.6
userTags (Optional) List query User tags 0.6

API Response

Response Example
{   "totalCpu": 4.0,   "availableCpu": 2.0,   "totalMemory": 8.0,   "availableMemory": 4.0,   "managedCpuNum": 4.0,   "capacityData": [     {       "resourceUuid": "db558260b0b53e36aa8ebf7e40c7c9c6",       "totalCpu": 4.0,       "availableCpu": 2.0,       "totalMemory": 8.0,       "availableMemory": 4.0,       "managedCpuNum": 4.0     }   ],   "resourceType": "HostVO" }
Name Type Description Starting Version
totalCpu long Total CPU count 0.6
availableCpu long Available CPU count 0.6
totalMemory long Total memory 0.6
availableMemory long Available memory 0.6
managedCpuNum long Number of managed physical CPUs 2.5.0
resourceType String The type of queried resource (Host, Cluster, Data Center) 3.9.0
success boolean Success 0.6
error ErrorCode The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details 0.6
capacityData List See capacityData for details 3.9.0
error ErrorCode See error for details 0.6
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, for example, SYS.1000, HOST.1001 0.6
description String A brief description of the error 0.6
details String The detailed error information 0.6
elaboration String Reserved field. Default is null 0.6
opaque LinkedHashMap Reserved field. Default is null 0.6
cause ErrorCode The root error that caused the current error. If no root error exists, this field is null 0.6
#capacityData
Name Type Description Starting Version
resourceUuid String Resource UUID 3.9.0
totalCpu long Total CPU count 3.9.0
availableCpu long Available CPU count 3.9.0
totalMemory long Total memory 3.9.0
availableMemory long Available memory 3.9.0
managedCpuNum long Number of managed physical CPUs 3.9.0
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, for example, SYS.1000, HOST.1001 0.6
description String A brief description of the error 0.6
details String The detailed error information 0.6
elaboration String Reserved field. Default is null 0.6
opaque LinkedHashMap Reserved field. Default is null 0.6
cause ErrorCode The root error that caused the current error. If no root error exists, this field is null 0.6

SDK Examples

Java SDK
GetCpuMemoryCapacityAction action = new GetCpuMemoryCapacityAction(); action.zoneUuids = asList("79383afd88f54a0b994515d84dbfa447","907c8ca71ee440e3bb0327f19d60754a"); action.clusterUuids = asList("9f5431123b834d95ae642c3cb923ba32","09cdcc7e28f340ccace7c427a32e2c05"); action.hostUuids = asList("2926839176934652ac3c6a77e4ce1484","c1b46284d0dd4d2a8a7637f0d4792d31"); action.hypervisorType = "KVM"; action.all = true; action.sessionId = "f3aedb623b3c47a7bb215ea3f4be90d7"; GetCpuMemoryCapacityAction.Result res = action.call();
Python SDK
GetCpuMemoryCapacityAction action = GetCpuMemoryCapacityAction() action.zoneUuids = [28cd4ea55a72429d815205b0738b87b3, 2571613b0ba642b7a1c99ddc17aee8e3] action.clusterUuids = [3e9e56c96fa545fea0b759cb601aad1c, 98ec43d31af446a9bf290b117af95e52] action.hostUuids = [b5cf96f88a1943f89417d6bea0715b6c, b358d13ac15049a581e47c76183c1358] action.hypervisorType = "KVM" action.all = true action.sessionId = "b0b7e398d33d4d7893255547d0859731" GetCpuMemoryCapacityAction.Result res = action.call()

Get External Services (GetExternalServices)

API Request

URLs
GET zstack/v1/external/services
Headers
Authorization: OAuth the-session-uuid
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/external/services
Parameter List
Name Type Location Description Allowed Values Starting Version
systemTags (Optional) List query System tags 4.7.0
userTags (Optional) List query User tags 4.7.0

API Response

Response Example
{   "inventories": [     {       "name": "prometheus",       "status": "RUNNING",       "capabilities": {         "reloadConfig": true       }     }   ] }
Name Type Description Starting Version
success boolean 4.7.0
inventories List See inventories for details 4.7.0
error ErrorCode The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details 4.7.0
#inventories
Name Type Description Starting Version
name String Resource name 4.7.0
status String Service status 4.7.0
capabilities ExternalServiceCapabilities See capabilities for details 4.7.0
#capabilities
Name Type Description Starting Version
reloadConfig boolean Supports reloading configuration 4.7.0
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, for example, SYS.1000, HOST.1001 0.6
description String A brief description of the error 0.6
details String The detailed error information 0.6
elaboration String Reserved field. Default is null 0.6
opaque LinkedHashMap Reserved field. Default is null 0.6
cause ErrorCode The root error that caused the current error. If no root error exists, this field is null 0.6

SDK Examples

Java SDK
GetExternalServicesAction action = new GetExternalServicesAction(); action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; GetExternalServicesAction.Result res = action.call();
Python SDK
GetExternalServicesAction action = GetExternalServicesAction() action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" GetExternalServicesAction.Result res = action.call()

Reload External Service (ReloadExternalService)

API Request

URLs
PUT zstack/v1/external/services
Headers
Authorization: OAuth the-session-uuid
Body
{   "reloadExternalService": {     "name": "prometheus"   },   "systemTags": [],   "userTags": [] }
Note: In the above example, the systemTags and userTags fields are optional. They are listed to indicate that the body can contain these two fields.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"reloadExternalService":{"name":"prometheus"}}' \ http://localhost:8080/zstack/v1/external/services
Parameter List
Name Type Location Description Allowed Values Starting Version
name String body (included in the reloadExternalService structure) Resource name 4.7.0
systemTags (Optional) List body System tags 4.7.0
userTags (Optional) List body User tags 4.7.0

API Response

When the API succeeds, it returns an empty JSON structure {}. When an error occurs, the returned JSON structure contains 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 Examples

Java SDK
ReloadExternalServiceAction action = new ReloadExternalServiceAction(); action.name = "prometheus"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; ReloadExternalServiceAction.Result res = action.call();
Python SDK
ReloadExternalServiceAction action = ReloadExternalServiceAction() action.name = "prometheus" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" ReloadExternalServiceAction.Result res = action.call()

Archives

Download Document Archives

Download

Already filled the basic info?Click here.

Enter at least 2 characters.
Cannot be empty.
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.