Document navigation

Instance Offering Operations

CreateInstanceOffering

API Request

URLs
POST zstack/v1/instance-offerings
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"name": "instanceOffering",
"cpuNum": 2.0,
"memorySize": 2097152.0,
"sortKey": 0.0,
"type": "UserVm"
  },
"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":"instanceOffering","cpuNum":2.0,"memorySize":2097152.0,"sortKey":0.0,"type":"UserVm"}}' \
http://localhost:8080/zstack/v1/instance-offerings
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The resource name. 0.6
description String body (contained in the params structure) Optional. The detailed description of the resource. 0.6
cpuNum int body (contained in the params structure) The CPU count. 0.6
memorySize long body (contained in the params structure) The memory size. Unit: byte. 0.6
allocatorStrategy String body (contained in the params structure) Optional. The allocator strategy.
  • DefaultHostAllocatorStrategy
  • LastHostPreferredAllocatorStrategy
  • LeastVmPreferredHostAllocatorStrategy
  • MinimumCPUUsageHostAllocatorStrategy
  • MinimumMemoryUsageHostAllocatorStrategy
  • MaxInstancePerHostHostAllocatorStrategy
0.6
sortKey int body (contained in the params structure) Optional. The sort key. 0.6
type String body (contained in the params structure) Optional. The type. 0.6
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6
Note:
  • When you create an instance offering in ZStack Cloud, you can add a GPU specification by adding the pciRom option to SystemTags.
    • Format of the pciRom option: pciRomUuid::UUID. Here, the UUID is the UUID of the PCI device firmware.
    • Example: pciRomUuid::5fd71606d5af451d981413f35367a8d6
  • When you create an instance offering in ZStack Cloud, you can customize the instance offering parameters by adding the instanceOfferingUserConfig option to SystemTags.
    • Format of the instanceOfferingUserConfig option: instanceOfferingUserConfig::xxx. Here, xxx must be a JSON string.

API Response

Sample Response
{
"inventory": {
"uuid": "d04e02a97d6c4ad0b0acee2a2f6c7084",
"name": "instanceOffering1",
"cpuNum": 2.0,
"cpuSpeed": 1.0,
"type": "UserVm",
"allocatorStrategy": "Mevoco",
"createDate": "Jun 7, 2017 9:20:40 PM",
"lastOpDate": "Jun 7, 2017 9:20:40 PM",
"state": "Enabled"
  }
}
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 InstanceOfferingInventory 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
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
cpuNum Integer The CPU count. 0.6
cpuSpeed Integer The CPU speed. 0.6
memorySize Long The memory size. 0.6
type String The type. 0.6
allocatorStrategy String The allocator strategy. 0.6
sortKey Integer 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
state String The state, including Enabled and Disabled. 0.6

SDK Sample

Java SDK
CreateInstanceOfferingAction action = new CreateInstanceOfferingAction();
action.name = "instanceOffering";
action.cpuNum = 2.0;
action.memorySize = 2097152.0;
action.sortKey = 0.0;
action.type = "UserVm";
action.sessionId = "1567ec4024724d2ea60eba29b957158c";
CreateInstanceOfferingAction.Result res = action.call();

Python SDK

CreateInstanceOfferingAction action = CreateInstanceOfferingAction()
action.name = "instanceOffering"
action.cpuNum = 2.0
action.memorySize = 2097152.0
action.sortKey = 0.0
action.type = "UserVm"
action.sessionId = "427dd2d091a54a0999e7e31eac07fc83"
CreateInstanceOfferingAction.Result res = action.call()

DeleteInstanceOffering

API Request

URLs
DELETE zstack/v1/instance-offerings/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth cd94b78dc89842c19ea248ddb04816c0" \
-X DELETE http://localhost:8080/zstack/v1/instance-offerings/d4061032ef3940b990ba671acd1221fc?deleteMode=Permissive
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
deleteMode String body Optional. The delete mode. 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
DeleteInstanceOfferingAction action = new DeleteInstanceOfferingAction();
action.uuid = "07ce817b8d9d4f629c2bd65daae9b7bb";
action.deleteMode = "Permissive";
action.sessionId = "fd2aa30babca411780c7df97d3ae6f9f";
DeleteInstanceOfferingAction.Result res = action.call();
Python SDK
DeleteInstanceOfferingAction action = DeleteInstanceOfferingAction()
action.uuid = "694e24b4a64d4b45936a9bbcf878078b"
action.deleteMode = "Permissive"
action.sessionId = "a13ac6edf7f546e48c4dbfea66429610"
DeleteInstanceOfferingAction.Result res = action.call()

QueryInstanceOffering

API Request

URLs
GET zstack/v1/instance-offerings
GET zstack/v1/instance-offerings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth d4743a8bc4eb4dd7a827c58e20437e85" \
-X GET http://localhost:8080/zstack/v1/instance-offerings?q=uuid=3695f87b54594284b9ce542b2b653fb7
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth e053145ce7d74cad8686d9b2a91e2754" \
-X GET http://localhost:8080/zstack/v1/instance-offerings/b1c967830a5f4b198b291d7f22cc8a2f

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryInstanceOffering, and pressing the Tab key.

API Response

Sample Response

{
"inventories": [
    {
"uuid": "4f7e7eff5bb04f7cacc33a18006a0c72",
"name": "instanceOffering1",
"cpuNum": 2.0,
"cpuSpeed": 1.0,
"type": "UserVm",
"allocatorStrategy": "Mevoco",
"createDate": "Jun 7, 2017 9:20:13 PM",
"lastOpDate": "Jun 7, 2017 9:20:13 PM",
"state": "Enabled"
    }
  ]
}
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
inventories List See inventories. 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
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
cpuNum Integer The CPU count. 0.6
cpuSpeed Integer The CPU speed. 0.6
memorySize Long The memory size. 0.6
type String The type. 0.6
allocatorStrategy String The allocator strategy. 0.6
sortKey Integer 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
state String The state, including Enabled and Disabled. 0.6

SDK Sample

Java SDK
QueryInstanceOfferingAction action = new QueryInstanceOfferingAction();
action.conditions = asList("uuid=8c77205cdc114a9090bc5d978b9d5285");
action.sessionId = "7d91852598ca41ca904539b34396c2ec";
QueryInstanceOfferingAction.Result res = action.call();
Python SDK
QueryInstanceOfferingAction action = QueryInstanceOfferingAction()
action.conditions = ["uuid=6539c13e7a8843b7860ebc53c3f7e892"]
action.sessionId = "8700ab8ae22e48fb81a793b9a51e970a"
QueryInstanceOfferingAction.Result res = action.call()

ChangeInstanceOffering

API Request

URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"changeInstanceOffering": {
"instanceOfferingUuid": "818e8cad0af948baa9b8e7d8d7116abb"
  },
"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 '{"changeInstanceOffering":{"instanceOfferingUuid":"7c46b8e59bf63b5f94fda63fce797581"}}' \
http://localhost:8080/zstack/v1/vm-instances/6b322ba8e03136e6bf200431e550d1a6/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
vmInstanceUuid String url The VM instance UUID. 0.6
instanceOfferingUuid String body (contained in the changeInstanceOffering structure The instance offering UUID. 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
ChangeInstanceOfferingAction action = new ChangeInstanceOfferingAction();
action.vmInstanceUuid = "c63937d254e24da1b06afc433b0e27ff";
action.instanceOfferingUuid = "3186c364b49f485ba14591f81387010a";
action.sessionId = "3d53ea4d8e914d56ae795e9592a63317";
ChangeInstanceOfferingAction.Result res = action.call();
Python SDK
ChangeInstanceOfferingAction action = ChangeInstanceOfferingAction()
action.vmInstanceUuid = "5783bd4c68c04d9f9fe20783d92fa822"
action.instanceOfferingUuid = "8a9f3296030948b6bcda8c75a05458c9"
action.sessionId = "a19417648f9440c5b84b6ee4280dcefc"
ChangeInstanceOfferingAction.Result res = action.call()

UpdateInstanceOffering

API Request

URLs
PUT zstack/v1/instance-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateInstanceOffering": {
"name": "new name"
  },
"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 '{"updateInstanceOffering":{"name":"new name"}}' \
http://localhost:8080/zstack/v1/instance-offerings/d071c5278471319291f6d1b44522a044/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
name String body (contained in the updateInstanceOffering structure) Optional. The resource name. 0.6
description String body (contained in the updateInstanceOffering structure) Optional. The detailed description of the resource. 0.6
allocatorStrategy String body (contained in the updateInstanceOffering structure) Optional. The allocator strategy.
  • DefaultHostAllocatorStrategy
  • LastHostPreferredAllocatorStrategy
  • LeastVmPreferredHostAllocatorStrategy
  • MinimumCPUUsageHostAllocatorStrategy
  • MinimumMemoryUsageHostAllocatorStrategy
  • MaxInstancePerHostHostAllocatorStrategy
  • DesignatedHostAllocatorStrategy
2.3.1
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6

API Response

Sample Response
{
"inventory": {
"uuid": "341367815c8e45209787b2361837109e",
"name": "instanceOffering1",
"cpuNum": 2.0,
"cpuSpeed": 1.0,
"type": "UserVm",
"allocatorStrategy": "Mevoco",
"createDate": "Jun 7, 2017 9:20:13 PM",
"lastOpDate": "Jun 7, 2017 9:20:13 PM",
"state": "Enabled"
  }
}
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 InstanceOfferingInventory 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
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
cpuNum Integer The CPU count. 0.6
cpuSpeed Integer The CPU speed. 0.6
memorySize Long The memory size. 0.6
type String The type. 0.6
allocatorStrategy String The allocator strategy. 0.6
sortKey Integer 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
state String The state, including Enabled and Disabled. 0.6

SDK Sample

Java SDK
UpdateInstanceOfferingAction action = new UpdateInstanceOfferingAction();
action.uuid = "0d71c980598b4c7b8a8eeef3148ced95";
action.name = "new name";
action.sessionId = "12bf1da37d444e2fbb6de5dc98f8d5f0";
UpdateInstanceOfferingAction.Result res = action.call();
Python SDK
UpdateInstanceOfferingAction action = UpdateInstanceOfferingAction()
action.uuid = "bbe8cd1494d2413a8951623657a4f9c0"
action.name = "new name"
action.sessionId = "9251753d64fa477aa7cdd3956a94ff18"
UpdateInstanceOfferingAction.Result res = action.call()

ChangeInstanceOfferingState

API Request

URLs
PUT zstack/v1/instance-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"changeInstanceOfferingState": {
"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 318fe86dc2c2424c863623942dcf8e6f" \
-X PUT http://localhost:8080/zstack/v1/instance-offerings/049d4fa0268549c9b3e3e84f4c280d09/actions?
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 0.6
stateEvent String body (contained in the changeInstanceOfferingState structure) The state event.
  • enable
  • disable
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": {
"uuid": "372d111a940b46b39da8c32c5629ba66",
"name": "instanceOffering1",
"cpuNum": 2.0,
"cpuSpeed": 1.0,
"type": "UserVm",
"allocatorStrategy": "Mevoco",
"createDate": "Jun 7, 2017 9:20:36 PM",
"lastOpDate": "Jun 7, 2017 9:20:36 PM",
"state": "Enabled"
  }
}
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 InstanceOfferingInventory 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
uuid String The resource UUID. 0.6
name String The resource name. 0.6
description String The detailed description of the resource. 0.6
cpuNum Integer The CPU count. 0.6
cpuSpeed Integer The CPU speed. 0.6
memorySize Long The memory size. 0.6
type String The type. 0.6
allocatorStrategy String The allocator strategy. 0.6
sortKey Integer 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
state String The state, including Enabled and Disabled. 0.6

SDK Sample

Java SDK
ChangeInstanceOfferingStateAction action = new ChangeInstanceOfferingStateAction();
action.uuid = "ca7a911366f74e9b8e4222785cf963a1";
action.stateEvent = "enable";
action.sessionId = "86cf8ce78421434eb9458504f7449c64";
ChangeInstanceOfferingStateAction.Result res = action.call();
Python SDK
ChangeInstanceOfferingStateAction action = ChangeInstanceOfferingStateAction()
action.uuid = "5cfc5009c0b74319855ccd197fa04a16"
action.stateEvent = "enable"
action.sessionId = "c593d4f452fd498cb60679a0956f1929"
ChangeInstanceOfferingStateAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center