Affinity Group
Overview
Affinity Group Policy
Currently, ZStack Cloud provides two affinity group policies to better manage VM instances and hosts: anti-affinity group (soft) and anti-affinity group (hard).
Anti-affinity group (soft):
Allocate VM instances in the affinity group to different hosts as much as possible. If no more hosts are available, the VM instances will be allocated randomly.
Anti-affinity group (hard):
Strictly allocate VM instances in the affinity group to different hosts. If no more hosts are available, the allocation fails.
The logic of these two anti-affinity groups is shown in Anti-Affinity Group (Soft) and Anti-Affinity Group (Hard).
Usage Scenario
This section provides some usage examples of anti-affinity group (soft) and anti-affinity group (hard) policies.
Anti-affinity group (soft):
You might want to deploy nodes with different Hadoop roles on different hosts to improve the overall system performance.
- For example, when you deploy a Hadoop system, you might find it difficult to calculate the exact number of nodes of different roles such as NameNode, DataNode, JobTracker, and TaskTracker. However, you might know that deploying these nodes on different hosts is more effective. With the anti-affinity group (soft) policy, you can deploy Hadoop clusters on different hosts as much as possible, which relieves the I/O pressure and improves the overall performance of the system.
Anti-affinity group (hard):
You might want to deploy two VM instances that run an active and a standby database on different hosts to ensure high availability.
- For example, you deploy two business VM instances to run an active and a standby MySQL database respectively, and requires that the active and standby databases cannot be down at the same time. Therefore, you must deploy these two VM instances on different hosts. Due to deployment automation, you might not predict which hosts have sufficient resources. With the anti-affinity group (hard) policy, you can choose two different hosts to run these two VM instances respectively, which ensures the high availability.
Inventory
Properties
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| uuid | The UUID. For more information, see Resource Property. | 2.2 | ||
| name | The name. For more information, see Resource Property. | 2.2 | ||
| version | The version of the affinity group allocation algorithm. | 2.2 | ||
| type | The affinity group type. The current type is host. In the future, network, router, data center, and rack affinity groups will be supported. | Yes |
|
2.2 |
| policy | The affinity group policy. |
|
2.2 | |
| createDate | The creation date. For more information, see Resource Property. | 2.2 | ||
| lastOpDate | The last operation date. For more information, see Resource Property. | 2.2 | ||
| description | The description. For more information, see Resource Property. | Yes | 2.2 | |
| appliance | The resource that uses the affinity group. | 2.2 |
Sample
{
"inventories": [
{
"appliance": "VROUTER",
"createDate": "Mar 10, 2018 2:11:07 PM",
"description": "affinity.group.for.virtual.router",
"lastOpDate": "Mar 10, 2018 2:11:07 PM",
"name": "affinity.group.for.virtual.router",
"policy": "ANTISOFT",
"type": "HOST",
"usages": [],
"uuid": "d271b2fe242911e88fe0fa0754e77200",
"version": "1.0"
}
],
"success": true
}
Operations
CreateAffinityGroup
Creates an affinity group. For example,
CreateAffinityGroup name=affinity-group-test policy=antiSoft
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| name | The affinity group name. | 2.2 | ||
| description | The detailed description of the affinity group. | Yes | 2.2 | |
| policy | The affinity group policy. |
|
0.6 | |
| type | The affinity group type. The current type is host. In the future, network, router, data center, and rack affinity groups will be supported. | Yes |
|
2.2 |
| resourceUuid | The resource UUID. | Yes | 2.2 | |
| userTags | The user tags. For more information, see CreateUserTag. | Yes | 2.2 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | Yes | 2.2 | |
| timeout | Yes |
DeleteAffinityGroup
Deletes an affinity group. For example,
DeleteAffinityGroup uuid=1b8fa10dfe5a4cad81c341787f764c7c
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| uuid | The affinity group UUID. | 2.2 | ||
| deleteMode | The delete mode. | Yes | 2.2 | |
| userTags | The user tags. For more information, see CreateUserTag. | Yes | 2.2 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | Yes | 2.2 | |
| timeout | Yes |
QueryAffinityGroup
Queries an affinity group. For example,
QueryAffinityGroup appliance=vrouter
QueryAffinityGroup usages.resourceUuid=aa9acd98a8fb4958bcaa6ecb3a712a16
Primitive Fields of Query
See Affinity Group Inventory.
Nested and Expanded Fields of Query
| Field | Inventory | Description | Starting Version |
|---|---|---|---|
| usages | Usage Inventory | 2.2 |
UpdateAffinityGroup
Updates an affinity group. For example,
UpdateAffinityGroup uuid=acfc6a1e958148ab8e47d91cb7b26e7a
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| uuid | The affinity group UUID. | 2.2 | ||
| name | The affinity group name. | Yes | 2.2 | |
| description | The detailed description of the affinity group. | Yes | 2.2 | |
| userTags | The user tags. For more information, see CreateUserTag. | Yes | 2.2 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | Yes | 2.2 | |
| timeout | Yes |
AddVmToAffinityGroup
Adds a VM instance to an affinity group. For example,
AddVmToAffinityGroup affinityGroupUuid=acfc6a1e958148ab8e47d91cb7b26e7a \
uuid=9f3461b9021242268c51afe872662285
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| affinityGroupUuid | The affinity group UUID. | 2.2 | ||
| uuid | The resource UUID. | Yes | 2.2 | |
| userTags | The user tags. For more information, see CreateUserTag. | Yes | 2.2 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | Yes | 2.2 | |
| timeout | Yes |
RemoveVmFromAffinityGroup
Removes a VM instance from an affinity group. For example,
RemoveVmFromAffinityGroup affinityGroupUuid=acfc6a1e958148ab8e47d91cb7b26e7a \
uuid=9f3461b9021242268c51afe872662285
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| affinityGroupUuid | The affinity group UUID. | 2.2 | ||
| uuid | The resource UUID. | Yes | 2.2 | |
| userTags | The user tags. For more information, see CreateUserTag. | Yes | 2.2 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | Yes | 2.2 | |
| timeout | Yes |
ChangeAffinityGroupState
Changes the state of an affinity group. For example,
ChangeAffinityGroupState uuid=d8d6f572284611e8a675fa0754e77200 stateEvent=disable
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| uuid | The resource UUID. | 2.3 | ||
| stateEvent | Yes |
|
2.3 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | 2.3 | ||
| userTags | The user tags. For more information, see CreateUserTag. | 2.3 | ||
| timeout | 2.3 |
GetCandidateAffinityGroupForAttachingVm
Retrieves the affinity groups that can be attached to a VM instance. For example,
GetCandidateAffinityGroupForAttachingVm vmUuid=2cbb6f64b4e03753b8fb63f497bb003a
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| vmUuid | The VM UUID. | 4.0.0 | ||
| systemTags | The system tags. For more information, seeCreateSystemTag. | 4.0.0 | ||
| userTags | The user tags. For more information, seeCreateUserTag. | 4.0.0 | ||
| timeout | 4.0.0 |
GetCandidateVMForAttachingAffinityGroup
Retrieves VM instances that can be attached an affinity group. For example,
GetCandidateVMForAttachingAffinityGroup affinityGroupUuid=2cbb6f64b4e03753b8fb63f497bb003a
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| affinityGroupUuid | The UUID of the affinity group. | 4.0.0 | ||
| systemTags | The system tags. For more information, seeCreateSystemTag. | 4.0.0 | ||
| userTags | The user tags. For more information, seeCreateUserTag. | 4.0.0 | ||
| timeout | 4.0.0 |
GetCandidateAffinityGroupForCreatingVm
Retrieves available anti-affinity groups that can be attached to a VM instance that is being created. For example,
GetCandidateAffinityGroupForCreatingVm zoneUuid=2cbb6f64b4e03753b8fb63f497bb003a
Parameters
| Name | Description | Optional | Valid Value | Starting Version |
|---|---|---|---|---|
| zoneUuid | The zone UUID. | 4.1.0 | ||
| clusterUuid | The cluster UUID. | Yes | 4.1.0 | |
| hostUuid | The host UUID. | Yes | 4.1.0 | |
| systemTags | The system tags. For more information, see CreateSystemTag. | 4.1.0 | ||
| userTags | The user tags. For more information, see CreateUserTag. | 4.1.0 | ||
| timeout | 4.1.0 |
Tags
You can create a user tag on an affinity group by using resourceType=AffinityGroupVO. For example,
CreateUserTag tag=Test1 resourceUuid=d271b2fe242911e88fe0fa0754e77200 \
resourceType=AffinityGroupVO
