def test_get_node_list(self, project_id, cluster_id, requests_mock): requests_mock.get(ANY, json={"code": 0, "data": {"count": 1, "results": [{"inner_ip": "127.0.0.1"}]}}) client = PaaSCCClient(ComponentAuth("token")) resp = client.get_node_list(project_id, cluster_id) assert resp == {"count": 1, "results": [{"inner_ip": "127.0.0.1"}]} assert "desire_all_data" in requests_mock.last_request.qs
def query_bcs_cc_nodes(ctx_cluster: CtxCluster) -> List: """查询bcs cc中的节点数据""" client = PaaSCCClient( ComponentAuth(access_token=ctx_cluster.context.auth.access_token)) node_data = client.get_node_list(ctx_cluster.project_id, ctx_cluster.id) return { node["inner_ip"]: node for node in (node_data.get("results") or []) if node["status"] not in [NodeStatus.Removed] }