Creating an ECS Group

Function

This API is used to create an ECS group.

Constraints

Only anti-affinity groups are supported.

URI

POST /v2.1/{project_id}/os-server-groups

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

Request

Table 2 describes the request parameters.

Table 2 Request parameters

Parameter

Mandatory

Type

Description

server_group

Yes

Object

Specifies an ECS group.

Table 3 server_group field description

Parameter

Mandatory

Type

Description

name

Yes

String

Specifies the ECS group name. The value contains 1 to 255 characters.

policies

Yes

Array of strings

Specifies the policies associated with the ECS group. Options:

  • anti-affinity: ECSs in this group must be deployed on different hosts.
  • affinity: ECSs in this group must be deployed on the same host.
  • soft-anti-affinity: ECSs in this group are deployed on different hosts if possible. If the ECSs cannot be deployed on different hosts, deploy them based on the actual condition for successful ECS creation.
  • soft-affinity: ECSs in this group are deployed on the same host if possible. If the ECSs cannot be deployed on the same host, deploy them based on the actual condition for successful ECS creation.
NOTE:

Only the anti-affinity policy is supported. The other three policies are retained to be compatible with native APIs. However, you are not advised to use the other three policies.

You are suggested to use the policy described in Creating an ECS Group.

Response

Table 4 describes the response parameters.

Table 4 Response parameters

Parameter

Type

Description

server_group

Object

Specifies an ECS group.

Table 5 server_group field description

Parameter

Type

Description

id

String

Specifies the ECS group UUID.

name

String

Specifies the ECS group name.

policies

Array of strings

Specifies the policies associated with the ECS group. Options:

anti-affinity: ECSs in this group must be deployed on different hosts.

affinity: ECSs in this group must be deployed on the same host.

soft-anti-affinity: ECSs in this group are deployed on different hosts if possible. If the ECSs cannot be deployed on different hosts, deploy them based on the actual condition for successful ECS creation.

soft-affinity: ECSs in this group are deployed on the same host if possible. If the ECSs cannot be deployed on the same host, deploy them based on the actual condition for successful ECS creation.

members

Array of strings

Specifies the ECSs contained in an ECS group.

metadata

Object

Specifies the ECS group metadata.

project_id

String

Specifies the tenant ID in UUID format for the ECS group.

NOTE:

This parameter is added in microversion 2.13.

user_id

String

Specifies the user ID in UUID format for the ECS group.

NOTE:

This parameter is added in microversion 2.13.

Example Request

POST https://{endpoint}/v2.1/9c53a566cb3443ab910cf0daebca90c4/os-server-groups
{
    "server_group": {
        "name": "test",
        "policies": ["anti-affinity"]
    }
}

Example Response

{
    "server_group": {
        "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
        "name": "test",
        "policies": [
            "anti-affinity"
        ],
        "members": [],
        "metadata": {}
    }
}