Document navigation

Affinity Group Operations

CreateAffinityGroup

API Request

URLs
POST zstack/v1/affinity-groups
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "vm-affinity-group",
    "description": "vm affinity group for test vms",
    "policy": "antiSoft",
    "type": "host"
  },
  "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":"vm-affinity-group","description":"vm affinity group for test vms","policy":"antiSoft","type":"host"}}' \
http://localhost:8080/zstack/v1/affinity-groups
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The affinity group name. 2.3
description String body (contained in the params structure) Optional. The detailed description of the affinity group. 2.3
policy String body (contained in the params structure) The affinity group policy.
  • antiSoft
2.3
type String body (contained in the params structure) Optional. The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
  • host
2.3
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 2.3
systemTags List body Optional. The system tags. 2.3
userTags List body Optional. The user tags. 2.3

API Response

Sample Response
{
  "inventory": {
    "uuid": "05ad02be7c5f4a6a9b6d164cb2980be6",
    "name": "affinity-group-test",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "version": "1.0",
    "type": "HOST"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventory AffinityGroupInventory See inventory. 2.3
#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.3
description String The brief description of the error. 2.3
details String The details about the error. 2.3
elaboration String The reserved field. Default value: null. 2.3
opaque LinkedHashMap The reserved field. Default value: null. 2.3
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.3
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 2.3
name String The resource name. 2.3
description String The detailed description of the resource. 2.3
policy String The affinity group policy. 2.3
version String The version of the affinity group allocation algorithm. 2.3
type String The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
2.3
appliance String The affinity group appliance. 2.3
state String 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3
usages List See usages. 2.3
#usages
Name Type Description Starting Version
uuid String The resource binding UUID of the affinity group. 2.3
affinityGroupUuid String The affinity group UUID. 2.3
resourceUuid String The UUID of the resource that joins the affinity group. 2.3
resourceType String The type of the resource that joins the affinity group. 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3

SDK Sample

Java SDK
CreateAffinityGroupAction action = new CreateAffinityGroupAction();
action.name = "vm-affinity-group";
action.description = "vm affinity group for test vms";
action.policy = "antiSoft";
action.type = "host";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAffinityGroupAction.Result res = action.call();
Python SDK
CreateAffinityGroupAction action = CreateAffinityGroupAction()
action.name = "vm-affinity-group"
action.description = "vm affinity group for test vms"
action.policy = "antiSoft"
action.type = "host"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAffinityGroupAction.Result res = action.call()

DeleteAffinityGroup

API Request

URLs
DELETE zstack/v1/affinity-groups/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/affinity-groups/ed0b2f029cc53ca385adc19dd36b51be?deleteMode=Permissive
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 2.2
deleteMode String url Optional. The delete mode. 2.2
systemTags List body Optional. The system tags. 2.2
userTags List body Optional. The user tags. 2.2

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
DeleteAffinityGroupAction action = new DeleteAffinityGroupAction();
action.uuid = "ed0b2f029cc53ca385adc19dd36b51be";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAffinityGroupAction.Result res = action.call();
Python SDK
DeleteAffinityGroupAction action = DeleteAffinityGroupAction()
action.uuid = "ed0b2f029cc53ca385adc19dd36b51be"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAffinityGroupAction.Result res = action.call()

QueryAffinityGroup

API Request

URLs
GET zstack/v1/affinity-groups
GET zstack/v1/affinity-groups/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/affinity-groups?q=uuid=656ebc992c3333fea209c6c90e6a76cf
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/affinity-groups/b49759dff8593098a1d106c8129974cf

Queryable Fields

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

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "99fa95af4aac4eaabd320dbdd6d36ef8",
      "name": "affinity-group-test",
      "description": "affinity group for test",
      "policy": "ANTISOFT",
      "version": "1.0",
      "type": "HOST",
      "usages": [
        {
          "resourceUuid": "acedd8848c874cd7b1c68df7c593f6c1",
          "resourceType": "HOST"
        }
      ]
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventories List See inventories. 2.3
#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.3
description String The brief description of the error. 2.3
details String The details about the error. 2.3
elaboration String The reserved field. Default value: null. 2.3
opaque LinkedHashMap The reserved field. Default value: null. 2.3
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.3
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 2.3
name String The resource name. 2.3
description String The detailed description of the resource. 2.3
policy String The affinity group policy. 2.3
version String The version of the affinity group allocation algorithm. 2.3
type String The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
2.3
appliance String The affinity group appliance. 2.3
state String 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3
usages List See usages. 2.3
#usages
Name Type Description Starting Version
uuid String The resource binding UUID of the affinity group. 2.3
affinityGroupUuid String The affinity group UUID. 2.3
resourceUuid String The UUID of the resource that joins the affinity group. 2.3
resourceType String The type of the resource that joins the affinity group. 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3

SDK Sample

Java SDK
QueryAffinityGroupAction action = new QueryAffinityGroupAction();
action.conditions = asList("uuid=bceb37906e673f37bb425933bdf2df46");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAffinityGroupAction.Result res = action.call();
Python SDK
QueryAffinityGroupAction action = QueryAffinityGroupAction()
action.conditions = ["uuid=3714ccec7a933aba94c073fcba6e52bd"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAffinityGroupAction.Result res = action.call()

UpdateAffinityGroup

API Request

URLs
PUT zstack/v1/affinity-groups/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid

Body

{
  "updateAffinityGroup": {
    "name": "new name",
    "description": "desc"
  },
  "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 '{"updateAffinityGroup":{"name":"new name","description":"desc"}}' \
http://localhost:8080/zstack/v1/affinity-groups/f287ad59b76c34b0917fa9f897b63d69/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 2.3
name String body (contained in the updateAffinityGroup structure) Optional. The resource name. 2.3
description String body (contained in the updateAffinityGroup structure) Optional. The detailed description of the resource. 2.3
systemTags List body Optional. The system tags. 2.3
userTags List body Optional. The user tags. 2.3

API Response

Sample Response
{
  "inventory": {
    "uuid": "f8c3b350df9a3bfd960359f302a4fba2",
    "name": "affinity group",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "type": "HOST"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventory AffinityGroupInventory See inventory. 2.3
#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.3
description String The brief description of the error. 2.3
details String The details about the error. 2.3
elaboration String The reserved field. Default value: null. 2.3
opaque LinkedHashMap The reserved field. Default value: null. 2.3
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.3
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 2.3
name String The resource name. 2.3
description String The detailed description of the resource. 2.3
policy String The affinity group policy. 2.3
version String The version of the affinity group allocation algorithm. 2.3
type String The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
2.3
appliance String The affinity group appliance. 2.3
state String 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3
usages List See usages. 2.3
#usages
Name Type Description Starting Version
uuid String The resource binding UUID of the affinity group. 2.3
affinityGroupUuid String The affinity group UUID. 2.3
resourceUuid String The UUID of the resource that joins the affinity group. 2.3
resourceType String The type of the resource that joins the affinity group. 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3

SDK Sample

Java SDK
UpdateAffinityGroupAction action = new UpdateAffinityGroupAction();
action.uuid = "f287ad59b76c34b0917fa9f897b63d69";
action.name = "new name";
action.description = "desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAffinityGroupAction.Result res = action.call();
Python SDK
UpdateAffinityGroupAction action = UpdateAffinityGroupAction()
action.uuid = "f287ad59b76c34b0917fa9f897b63d69"
action.name = "new name"
action.description = "desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAffinityGroupAction.Result res = action.call()

AddVmToAffinityGroup

API Request

URLs
POST zstack/v1/affinity-groups/{affinityGroupUuid}/vm-instances/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {},
  "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":{}}' \
http://localhost:8080/zstack/v1/affinity-groups/8e9398e9841b399693ab71fb722ea144/vm-instances/f67763f0793832619a22e2c53c66e7d8
Request Parameters
Name Type Location Description Optional Value Starting Version
affinityGroupUuid String url The affinity group UUID. 2.3
uuid String url The resource UUID. 2.3
systemTags List body Optional. The system tags. 2.3
userTags List body Optional. The user tags. 2.3

API Response

Sample Response
{
  "inventory": {
    "uuid": "cb4dee8a47d74f9986b4641648a4c85d",
    "name": "affinity-group-test",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "version": "1.0",
    "type": "HOST",
    "usages": [
      {
        "uuid": "cb4dee8a47d74f9986b4641648a4c85d",
        "resourceUuid": "cf44d25659f24cefafbadbf8ad9a207d",
        "resourceType": "HOST"
      }
    ]
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventory AffinityGroupInventory See inventory. 2.3
#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.2
description String The brief description of the error. 2.2
details String The details about the error. 2.2
elaboration String The reserved field. Default value: null. 2.2
opaque LinkedHashMap The reserved field. Default value: null. 2.2
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.2
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 2.2
name String The resource name. 2.2
description String The detailed description of the resource. 2.2
policy String The affinity group policy. 2.2
version String The version of the affinity group allocation algorithm. 2.2
type String The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
2.2
appliance String The affinity group appliance. 2.2
state String 2.3
createDate Timestamp The creation date. 2.2
lastOpDate Timestamp The last operation date. 2.2
usages List See usages. 2.2
#usages
Name Type Description Starting Version
uuid String The resource binding UUID of the affinity group. 2.2
affinityGroupUuid String The affinity group UUID. 2.2
resourceUuid String The UUID of the resource that joins the affinity group. 2.2
resourceType String The type of the resource that joins the affinity group. 2.2
createDate Timestamp The creation date. 2.2
lastOpDate Timestamp The last operation date. 2.2

SDK Sample

Java SDK
AddVmToAffinityGroupAction action = new AddVmToAffinityGroupAction();
action.affinityGroupUuid = "8e9398e9841b399693ab71fb722ea144";
action.uuid = "f67763f0793832619a22e2c53c66e7d8";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddVmToAffinityGroupAction.Result res = action.call();
Python SDK
AddVmToAffinityGroupAction action = AddVmToAffinityGroupAction()
action.affinityGroupUuid = "8e9398e9841b399693ab71fb722ea144"
action.uuid = "f67763f0793832619a22e2c53c66e7d8"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddVmToAffinityGroupAction.Result res = action.call()

RemoveVmFromAffinityGroup

API Request

URLs
DELETE zstack/v1/affinity-groups/{affinityGroupUuid}/vm-instances?uuid={uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/affinity-groups/6d1e8b61e30e38ceb8300ed722c6a85a/vm-instances?uuid=2736c4e5c4f3301e8a9ee7cc64847033
Request Parameters
Name Type Location Description Optional Value Starting Version
affinityGroupUuid String url The affinity group UUID. 2.3
uuid String url The resource UUID. 2.3
systemTags List body Optional. The system tags. 2.3
userTags List body Optional. The user tags. 2.3

API Response

Sample Response

{
  "inventory": {
    "uuid": "15b102d8d08947e6b38fc619c71a5cfe",
    "name": "affinity-group-test",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "version": "1.0",
    "type": "HOST"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventory AffinityGroupInventory See inventory. 2.3
#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.3
description String The brief description of the error. 2.3
details String The details about the error. 2.3
elaboration String The reserved field. Default value: null. 2.3
opaque LinkedHashMap The reserved field. Default value: null. 2.3
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.3
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 2.3
name String The resource name. 2.3
description String The detailed description of the resource. 2.3
policy String The affinity group policy. 2.3
version String The version of the affinity group allocation algorithm. 2.3
type String The affinity group type.
  • The current type is host.
  • In the future, network, router, data center, and rack affinity groups will be supported.
2.3
appliance String The affinity group appliance. 2.3
state String 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3
usages List See usages. 2.3
#usages
Name Type Description Starting Version
uuid String The resource binding UUID of the affinity group. 2.3
affinityGroupUuid String The affinity group UUID. 2.3
resourceUuid String The UUID of the resource that joins the affinity group. 2.3
resourceType String The type of the resource that joins the affinity group. 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3

SDK Sample

Java SDK
RemoveVmFromAffinityGroupAction action = new RemoveVmFromAffinityGroupAction();
action.affinityGroupUuid = "6d1e8b61e30e38ceb8300ed722c6a85a";
action.uuid = "2736c4e5c4f3301e8a9ee7cc64847033";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveVmFromAffinityGroupAction.Result res = action.call();
Python SDK
RemoveVmFromAffinityGroupAction action = RemoveVmFromAffinityGroupAction()
action.affinityGroupUuid = "6d1e8b61e30e38ceb8300ed722c6a85a"
action.uuid = "2736c4e5c4f3301e8a9ee7cc64847033"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveVmFromAffinityGroupAction.Result res = action.call()

ChangeAffinityGroupState

API Request

URLs
PUT zstack/v1/affinity-groups/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changeAffinityGroupState": {
    "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 '{"changeAffinityGroupState":{"stateEvent":"enable"}}' \
http://localhost:8080/zstack/v1/affinity-groups/f32fd1a910d439d7ab93cd4660a02837/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 2.3
stateEvent String body (contained in the changeAffinityGroupState structure)
  • enable
  • disable
2.3
systemTags List body Optional. The system tags. 2.3
userTags List body Optional. The user tags. 2.3

API Response

Sample Response
{
  "inventory": {
    "uuid": "034e3ef3798f3374b85d414057313a3c",
    "name": "Test-AffinityGroup",
    "description": "Test-AffinityGroup",
    "version": "1.0",
    "type": "HOST",
    "appliance": "CUSTOMER",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventory AffinityGroupInventory See inventory. 2.3
#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. 2.2
name String The resource name. 2.2
description String The detailed description of the resource. 2.2
policy String 2.2
version String 2.2
type String 2.2
appliance String 2.2
state String 2.3
createDate Timestamp The creation date. 2.2
lastOpDate Timestamp The last operation date. 2.2
usages List See usages. 2.2
#usages
Name Type Description Starting Version
uuid String The resource UUID. 2.2
affinityGroupUuid String 2.2
resourceUuid String 2.2
resourceType String 2.2
createDate Timestamp The creation date. 2.2
lastOpDate Timestamp The last operation date. 2.2

SDK Sample

Java SDK
ChangeAffinityGroupStateAction action = new ChangeAffinityGroupStateAction();
action.uuid = "f32fd1a910d439d7ab93cd4660a02837";
action.stateEvent = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAffinityGroupStateAction.Result res = action.call();
Python SDK
ChangeAffinityGroupStateAction action = ChangeAffinityGroupStateAction()
action.uuid = "f32fd1a910d439d7ab93cd4660a02837"
action.stateEvent = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeAffinityGroupStateAction.Result res = action.call()

GetCandidateAffinityGroupForAttachingVm

API Request

URLs
GET zstack/v1/affinityGroup/attachingVm
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/affinityGroup/attachingVm?vmUuid=2cbb6f64b4e03753b8fb63f497bb003a
Request Parameters
Name Type Location Description Valid Value Starting Version
vmUuid String query The VM UUID. 4.0.0
systemTags List query Optional. The system tags. 4.0.0
userTags List query Optional. The user tags. 4.0.0

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "06a212ca4cce3986ae05f3912fb3bd7d",
      "name": "affinity-group-test",
      "description": "affinity group for test",
      "policy": "ANTISOFT",
      "version": "1.0",
      "type": "HOST"
    }
  ]
}
Name Type Description Starting Version
success boolean 4.0.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.0.0
inventories List For more information, see inventories. 4.0.0
#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. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0
#inventory
Name Type Description Starting Version
uuid String The affinity group UUID. 4.0.0
name String The affinity group name. 4.0.0
description String The detailed description of the affinity group. 4.0.0
policy String 4.0.0
version String 4.0.0
type String 4.0.0
appliance String 4.0.0
state String 4.0.0
createDate Timestamp The time when the affinity group was created. 4.0.0
lastOpDate Timestamp The time when the affinity group was last modified. 4.0.0
usages List For more information, see usages. 4.0.0
#usages
Name Type Description Starting Version
uuid String The affinity group UUID. 4.0.0
affinityGroupUuid String 4.0.0
resourceUuid String 4.0.0
resourceType String 4.0.0
createDate Timestamp The time when the affinity group was created. 4.0.0
lastOpDate Timestamp The time when the affinity group was last modified. 4.0.0

SDK Sample

Java SDK
GetCandidateAffinityGroupForAttachingVmAction action = new GetCandidateAffinityGroupForAttachingVmAction();
action.vmUuid = "2cbb6f64b4e03753b8fb63f497bb003a";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateAffinityGroupForAttachingVmAction.Result res = action.call();
Python SDK
GetCandidateAffinityGroupForAttachingVmAction action = GetCandidateAffinityGroupForAttachingVmAction()
action.vmUuid = "2cbb6f64b4e03753b8fb63f497bb003a"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetCandidateAffinityGroupForAttachingVmAction.Result res = action.call()

GetCandidateVMForAttachingAffinityGroup

API Request

URLs
GET zstack/v1/VM/attachingGroup
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/VM/attachingGroup?affinityGroupUuid=a92158a6b1b333b296e93a4bd8d36e5e
Request Parameters
Name Type Location Description Valid Value Starting Version
affinityGroupUuid String query The UUID of the affinity group. 4.0.0
systemTags List query Optional. The system tags. 4.0.0
userTags List query Optional. The user tags. 4.0.0

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "ac1d56dec1d93a29a6cb43d7aff178a3",
      "name": "Test-VM",
      "description": "web server VM",
      "zoneUuid": "892fe4676f283785970b18b6c0f556f4",
      "clusterUuid": "440f315c2b0c3561850f610f7d200959",
      "imageUuid": "72da4314ad063029a40ebec8e1204c70",
      "hostUuid": "2cac9cfdc7d030bb8cfd80bb9d922e48",
      "lastHostUuid": "c60aa755fe2d30fb80d4029e9d337ee9",
      "instanceOfferingUuid": "3ce1eb11a41030499e3e74685a568dbb",
      "rootVolumeUuid": "e6cf673fb915361caa4ab93e03c6e3a6",
      "platform": "Linux",
      "defaultL3NetworkUuid": "aff87442d7d535a2a46914f6a312c285",
      "type": "UserVm",
      "hypervisorType": "KVM",
      "memorySize": 8.589934592E9,
      "cpuNum": 1.0,
      "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM",
      "state": "Stopped"
    }
  ]
}
Name Type Description Starting Version
success boolean 4.0.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.0.0
inventories List For more information, see inventories. 4.0.0
#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. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0
#inventory
Name Type Description Starting Version
uuid String The UUID of the VM instance. 4.0.0
name String The name of the VM instance. 4.0.0
description String The detailed description of the VM instance. 4.0.0
zoneUuid String The zone UUID. 4.0.0
clusterUuid String The cluster UUID. 4.0.0
imageUuid String The image UUID. 4.0.0
hostUuid String The host UUID. 4.0.0
lastHostUuid String 4.0.0
instanceOfferingUuid String The UUID of the instance offering. 4.0.0
rootVolumeUuid String The UUID of the root volume. 4.0.0
platform String 4.0.0
defaultL3NetworkUuid String 4.0.0
type String 4.0.0
hypervisorType String 4.0.0
memorySize Long 4.0.0
cpuNum Integer 4.0.0
cpuSpeed Long 4.0.0
allocatorStrategy String 4.0.0
createDate Timestamp The time when the VM Instance was created. 4.0.0
lastOpDate Timestamp The time when the VM Instance was last mpdified. 4.0.0
state String 4.0.0
vmNics List For more information, see vmNics. 4.0.0
allVolumes List For more information, see allVolumes. 4.0.0
#vmNics
Name Type Description Starting Version
uuid String The UUID of the NIC. 4.0.0
vmInstanceUuid String The UUID of the VM instance. 4.0.0
l3NetworkUuid String The L3 network UUID. 4.0.0
ip String The IP address of the NIC. 4.0.0
mac String The MAC address of the NIC. 4.0.0
hypervisorType String The type of the hypervisor. 4.0.0
netmask String The netmask. 4.0.0
gateway String The gateway. 4.0.0
metaData String 4.0.0
ipVersion Integer The IP version. 4.0.0
deviceId Integer The device ID. 4.0.0
type String The NIC type. 4.0.0
createDate Timestamp The time when the NIC was created. 4.0.0
lastOpDate Timestamp The time when the NIC was last modified. 4.0.0
usedIps List For more information, see usedIps. 4.0.0
#usedIps
Name Type Description Starting Version
uuid String The IP UUID. 4.0.0
ipRangeUuid String The IP range UUID. 4.0.0
l3NetworkUuid String The L3 network UUID. 4.0.0
ipVersion Integer The IP version. 4.0.0
ip String The IP address. 4.0.0
netmask String The netmask. 4.0.0
gateway String The gateway. 4.0.0
usedFor String 4.0.0
ipInLong long 4.0.0
vmNicUuid String The UUID of the VM NIC. 4.0.0
createDate Timestamp The time when the NIC was created. 4.0.0
lastOpDate Timestamp The time when the NIC was lastb modified. 4.0.0
#allVolumes
Name Type Description Starting Version
uuid String The volume UUID. 4.0.0
name String The volume name. 4.0.0
description String The detailed description the 4.0.0
primaryStorageUuid String The primary storage UUID. 4.0.0
vmInstanceUuid String The VM UUID. 4.0.0
diskOfferingUuid String The disk offering UUID. 4.0.0
rootImageUuid String The root image UUID. 4.0.0
installPath String The installation path of the volume in the primary storage. 4.0.0
type String The volume type. 4.0.0
format String The disk format. 4.0.0
size Long The volume size. 4.0.0
actualSize Long The actual size of the 4.0.0
deviceId Integer 4.0.0
state String The state of the volume. 4.0.0
status String The status of the volume. 4.0.0
createDate Timestamp The time when the volume was created. 4.0.0
lastOpDate Timestamp The time when the volume was last modified. 4.0.0
isShareable Boolean Indicates whether the volume is sharable. 4.0.0
volumeQos String The volume QoS. 4.0.0

SDK Sample

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

GetCandidateAffinityGroupForCreatingVm

API Request

URLs
GET zstack/v1/vm-instances/candidate-affinityGroup
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/candidate-affinityGroup?zoneUuid=eb4be792076530faa865def5bb1f43d2&clusterUuid=05033aee073b3bb69941eac180992e74&hostUuid=7007ba51ded339fab41ec19f2d721135
Request Parameters
Name Type Location Description Valid Value Starting Version
zoneUuid String query Optional. The zone UUID. 4.1.0
clusterUuid String query Optional. The cluster UUID. 4.1.0
hostUuid String query Optional. The host UUID. 4.1.0
systemTags List query Optional. The system tags. 4.1.0
userTags List query Optional. The user tags. 4.1.0

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "7c5c014902fa309b91e0e01b2f5e6cfb",
      "name": "affinity-group",
      "description": "affinity group for test",
      "policy": "ANTISOFT",
      "version": "1.0",
      "type": "HOST"
    }
  ]
}
Name Type Description Starting Version
success boolean 4.1.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.1.0
inventories List See inventories 4.1.0
#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. 4.1.0
description String The brief description of the error. 4.1.0
details String The details about the error. 4.1.0
elaboration String The reserved field. Default value: null. 4.1.0
opaque LinkedHashMap The reserved field. Default value: null. 4.1.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.1.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.1.0
name String The resource name. 4.1.0
description String Optional. Optional. The detailed description of the resource. 4.1.0
policy String 4.1.0
version String 4.1.0
type String 4.1.0
appliance String 4.1.0
state String 4.1.0
createDate Timestamp The creation time. 4.1.0
lastOpDate Timestamp The last update time. 4.1.0
usages List See usages 4.1.0
#usages
Name Type Description Starting Version
uuid String The resource UUID. 4.1.0
affinityGroupUuid String 4.1.0
resourceUuid String 4.1.0
resourceType String 4.1.0
createDate Timestamp The creation time. 4.1.0
lastOpDate Timestamp The last update time. 4.1.0

SDK Sample

Java SDK
GetCandidateAffinityGroupForCreatingVmAction action = new GetCandidateAffinityGroupForCreatingVmAction();
action.zoneUuid = "eb4be792076530faa865def5bb1f43d2";
action.clusterUuid = "05033aee073b3bb69941eac180992e74";
action.hostUuid = "7007ba51ded339fab41ec19f2d721135";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateAffinityGroupForCreatingVmAction.Result res = action.call();
Python SDK
GetCandidateAffinityGroupForCreatingVmAction action = GetCandidateAffinityGroupForCreatingVmAction()
action.zoneUuid = "eb4be792076530faa865def5bb1f43d2"
action.clusterUuid = "05033aee073b3bb69941eac180992e74"
action.hostUuid = "7007ba51ded339fab41ec19f2d721135"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetCandidateAffinityGroupForCreatingVmAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center