Creating an Exclusive Cluster

Sample Code

You can use the API to create an exclusive cluster for CS users with the cs_adm role. The exclusive cluster is converted to stream processing units (SPUs) for on-demand charging. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// Import classes:
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.ClusterApi;


ClusterApi apiInstance = new ClusterApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
NewReservedClusterRequest body = new NewReservedClusterRequest(); // NewReservedClusterRequest | Create an exclusive cluster, for which the request parameters are in JSON format.
try {
    CreateClusterResponse result = apiInstance.createReservedCluster(xProjectId, body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling ClusterApi#createReservedCluster");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameter Description

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

body

Yes

NewReservedClusterRequest

Create an exclusive cluster, for which the request parameters are in JSON format. For details about parameter types, see Table 2.

Table 2 Parameters involved in NewReservedClusterRequest

Parameter

Mandatory

Type

Description

name

Yes

String

Cluster name.

desc

No

String

Cluster description.

maximumSpuQuota

No

Integer

Maximum SPU quota of a cluster.

vpcCidr

No

String

VPC CIDR block.

subnetCidr

No

String

Subnet CIDR block.

subnetGateway

No

String

Subnet gateway.

tags

No

String

Job tag.

sysEnterpriseProjectId

No

String

ID of the enterprise project to which a job belongs.

managerNodeSpu

No

String

SPU specifications of management nodes.

Table 3 Parameters involved in CreateClusterResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.

payload

No

Integer

Cluster ID.