更新时间:2024-08-07 GMT+08:00
分享

查询集群节点列表

功能介绍

查询集群节点列表。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/clusters/{cluster_id}/nodes

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目编号。获取方法,请参见获取项目ID

约束限制:

不涉及

取值范围:

只能由英文字母和数字组成,且长度为[1-64]个字符。

默认取值:

不涉及

cluster_id

String

参数解释:

集群ID。如果指定集群ID,则获取该集群做过补丁更新的最新版本元数据。获取方法,请参见获取集群ID

约束限制:

不涉及

取值范围:

只能由英文字母、数字以及“_”和“-”组成,且长度为[1-64]个字符。

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

node_group

String

参数解释:

要查询的节点组名称。

约束限制:

不涉及

取值范围:

长度为[3-14]个字符。

默认取值:

不涉及

limit

Integer

参数解释:

返回结果中每页显示条数。

约束限制:

不涉及

取值范围:

≥1

默认取值:

10

offset

Integer

参数解释:

表示作业列表从该偏移量开始查询。

约束限制:

不涉及

取值范围:

≥1

默认取值:

1

node_name

String

参数解释:

指定节点名称,支持模糊搜索。

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

sort_key

String

参数解释:

排序键,支持对节点名称排序。

约束限制:

不涉及

取值范围:

node_name:节点名称。

默认取值:

不涉及

sort_dir

String

参数解释:

列表排序方式,desc为降序,asc为升序。

约束限制:

不涉及

取值范围:

desc:降序排列

asc:升序排列

默认取值:

不涉及

query_node_detail

Boolean

参数解释:

是否查询节点详情。该字段设为true时可能会影响接口性能。

约束限制:

不涉及

取值范围:

true:查询节点详情

false:不查询节点详情

默认取值:

false

query_ecs_detail

Boolean

参数解释:

是否查询ECS详情信息,会涉及对ECS接口调用。

约束限制:

不涉及

取值范围:

true:查询ECS详情信息

false:不查询ECS详情信息

默认取值:

false

internal_ip

String

参数解释:

指定内网IP。

约束限制:

不涉及

取值范围:

长度为[7-15]个字符。

默认取值:

不涉及

请求参数

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

nodes

Array of ClusterNode objects

参数解释:

节点列表。

node_total

Integer

参数解释:

节点数。

取值范围:

不涉及

表4 ClusterNode

参数

参数类型

描述

node_name

String

参数解释:

节点名称,对应manager里的节点名称。

取值范围:

不涉及

resource_id

String

参数解释:

资源id。确定节点的唯一性,包周期节点可用于计费的查询。

取值范围:

不涉及

node_group_name

String

参数解释:

节点组名称。

取值范围:

不涉及

node_type

String

参数解释:

节点类型。Task、Core、Master等。

取值范围:

不涉及

billing_type

String

参数解释:

on-period包周期或者on-quantity按需。

取值范围:

不涉及

deployment_type

String

参数解释:

部署类型。支持Server主机类型。

取值范围:

不涉及

server_info

ServerInfo object

参数解释:

如果部署类型为Server类型,则该字段不为空。

tags

Array of Tag objects

参数解释:

节点标签。

node_detail

NodeDetail object

参数解释:

节点监控信息。需要IAM同步后才能返回。

node_status

String

参数解释:

节点状态。对应页面上的操作状态。

取值范围:

不涉及

component_infos

Array of ComponentInfo objects

参数解释:

组件实例信息数组。

表5 ServerInfo

参数

参数类型

描述

server_id

String

参数解释:

服务器ID。

取值范围:

不涉及

server_name

String

参数解释:

服务器名称。

取值范围:

不涉及

server_type

String

参数解释:

服务器类型。ECS或者BMS。

取值范围:

不涉及

data_volumes

Array of VolumeInfo objects

参数解释:

数据盘。

root_volume

VolumeInfo object

参数解释:

系统盘。

cpu_type

String

参数解释:

CPU类型。x86或者ARM。

取值范围:

不涉及

cpu

String

参数解释:

CPU大小。

取值范围:

不涉及

mem

String

参数解释:

内存大小。

取值范围:

不涉及

internal_ip

String

参数解释:

内部IP。

取值范围:

不涉及

表6 VolumeInfo

参数

参数类型

描述

type

String

参数解释:

磁盘类型。

取值范围:

  • SATA:普通IO磁盘类型。

  • SAS:高IO磁盘类型。

  • SSD:超高IO磁盘类型。

  • GPSSD:通用型SSD磁盘类型。

size

Integer

参数解释:

磁盘大小。单位为GB。

取值范围:

不涉及

count

Integer

参数解释:

磁盘数量。

取值范围:

不涉及

表7 Tag

参数

参数类型

描述

key

String

参数解释:

标签键。

取值范围:

不涉及

value

String

参数解释:

标签值。

取值范围:

不涉及

表8 NodeDetail

参数

参数类型

描述

running_status

String

参数解释:

运行状态。

取值范围:

不涉及

cpu_usage

String

参数解释:

CPU使用率。

取值范围:

不涉及

memory_usage

String

参数解释:

内存使用率。

取值范围:

不涉及

disk_usage

String

参数解释:

硬盘使用率。

取值范围:

不涉及

total_memory

String

参数解释:

总内存。单位MB。

取值范围:

不涉及

available_memory

String

参数解释:

可用内存。单位MB。

取值范围:

不涉及

total_hard_disk_space

String

参数解释:

总硬盘空间。单位GB。

取值范围:

不涉及

available_hard_disk_space

String

参数解释:

可用硬盘空间。单位GB。

取值范围:

不涉及

network_read

String

参数解释:

网络读取速度。单位Byte/s。

取值范围:

不涉及

network_write

String

参数解释:

网络写入速度。单位Byte/s。

取值范围:

不涉及

表9 ComponentInfo

参数

参数类型

描述

id

String

参数解释:

组件ID。

取值范围:

不涉及

name

String

参数解释:

组件名。

取值范围:

不涉及

instance_group_name

String

参数解释:

组件所在组名称。

取值范围:

不涉及

running_status

String

参数解释:

运行状态。

取值范围:

不涉及

ha_status

String

参数解释:

HA状态。

取值范围:

不涉及

config_status

String

参数解释:

配置状态。

取值范围:

不涉及

role_name

String

参数解释:

角色名。

取值范围:

不涉及

role_short_name

String

参数解释:

角色缩写。

取值范围:

不涉及

role_type

String

参数解释:

角色类型。

取值范围:

不涉及

service_name

String

参数解释:

服务名。

取值范围:

不涉及

pair_name

String

参数解释:

对名。

取值范围:

不涉及

relation_pairs

String

参数解释:

关联对。

取值范围:

不涉及

support_decom

String

参数解释:

是否支持Decom。

取值范围:

不涉及

support_reinstall

String

参数解释:

是否支持重装。

取值范围:

不涉及

support_collect_stack_info

String

参数解释:

是否支持收集堆栈信息。

取值范围:

不涉及

请求示例

查询集群指定节点组的节点列表。

https://mrs.cn-north-7.myhuaweicloud.com/v2/174ee662a7e24cc99bfc858c4558dbf6/clusters/f0a91b14-8884-4ba1-9e8d-0a21086c0ab4/nodes?node_group=master_node_default_group

响应示例

状态码: 200

查询的节点列表信息。

{
  "nodes" : [ {
    "node_name" : "node-master1QxCW",
    "resource_id" : "fc1ed6bb-e3d8-4dc8-8162-ef673bff6b7b",
    "node_group_name" : "master_node_default_group",
    "node_type" : "Master",
    "billing_type" : "on-quantity",
    "deployment_type" : "SERVER",
    "server_info" : {
      "server_id" : "3687f50a-cd4e-4c67-8858-5d6555c8834c",
      "server_name" : "f28fb043-ecbc-401e-936e-fb321ca8d40a_node_master1QxCW",
      "server_type" : "ECS",
      "data_volumes" : [ {
        "type" : "SATA",
        "size" : 200,
        "count" : 1
      } ],
      "root_volume" : {
        "type" : "SATA",
        "size" : 100,
        "count" : 1
      },
      "cpu_type" : "X86",
      "internal_ip" : "192.168.10.142"
    },
    "tags" : [ {
      "key" : "1",
      "value" : "2"
    } ],
    "node_status" : "started"
  } ],
  "node_total" : 1
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.mrs.v2.region.MrsRegion;
import com.huaweicloud.sdk.mrs.v2.*;
import com.huaweicloud.sdk.mrs.v2.model.*;


public class ListNodesSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        MrsClient client = MrsClient.newBuilder()
                .withCredential(auth)
                .withRegion(MrsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListNodesRequest request = new ListNodesRequest();
        request.withNodeGroup("<node_group>");
        request.withLimit(<limit>);
        request.withOffset(<offset>);
        request.withNodeName("<node_name>");
        request.withSortKey(ListNodesRequest.SortKeyEnum.fromValue("<sort_key>"));
        request.withSortDir(ListNodesRequest.SortDirEnum.fromValue("<sort_dir>"));
        request.withQueryNodeDetail(<query_node_detail>);
        request.withQueryEcsDetail(<query_ecs_detail>);
        request.withInternalIp("<internal_ip>");
        try {
            ListNodesResponse response = client.listNodes(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkmrs.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = BasicCredentials(ak, sk)

    client = MrsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(MrsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListNodesRequest()
        request.node_group = "<node_group>"
        request.limit = <limit>
        request.offset = <offset>
        request.node_name = "<node_name>"
        request.sort_key = "<sort_key>"
        request.sort_dir = "<sort_dir>"
        request.query_node_detail = <QueryNodeDetail>
        request.query_ecs_detail = <QueryEcsDetail>
        request.internal_ip = "<internal_ip>"
        response = client.list_nodes(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := mrs.NewMrsClient(
        mrs.MrsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListNodesRequest{}
	nodeGroupRequest:= "<node_group>"
	request.NodeGroup = &nodeGroupRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	nodeNameRequest:= "<node_name>"
	request.NodeName = &nodeNameRequest
	sortKeyRequest:= model.GetListNodesRequestSortKeyEnum().<SORT_KEY>
	request.SortKey = &sortKeyRequest
	sortDirRequest:= model.GetListNodesRequestSortDirEnum().<SORT_DIR>
	request.SortDir = &sortDirRequest
	queryNodeDetailRequest:= <query_node_detail>
	request.QueryNodeDetail = &queryNodeDetailRequest
	queryEcsDetailRequest:= <query_ecs_detail>
	request.QueryEcsDetail = &queryEcsDetailRequest
	internalIpRequest:= "<internal_ip>"
	request.InternalIp = &internalIpRequest
	response, err := client.ListNodes(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

查询的节点列表信息。

错误码

请参见错误码

相关文档