Exemplo n.º 1
0
    def test_get_cluster_by_id(self, cluster_id, requests_mock):
        requests_mock.get(ANY, json={'code': 0, 'data': {'cluster_id': cluster_id}})

        client = PaaSCCClient(ComponentAuth('token'))
        resp = client.get_cluster_by_id(cluster_id)
        assert resp == {'cluster_id': cluster_id}
        assert requests_mock.called
Exemplo n.º 2
0
    def _list_namespaces(self, cluster_id: str, shared_cluster_ids: List[str]) -> List[Dict]:
        paas_cc = PaaSCCClient(auth=ComponentAuth(get_system_token()))
        if cluster_id not in shared_cluster_ids:
            cluster = paas_cc.get_cluster_by_id(cluster_id=cluster_id)
            ns_data = paas_cc.get_cluster_namespace_list(project_id=cluster['project_id'], cluster_id=cluster_id)
            return ns_data['results'] or []

        # 共享集群获取
        ns_data = paas_cc.list_namespaces_in_shared_cluster(cluster_id)
        return ns_data['results'] or []
Exemplo n.º 3
0
 def _list_namespaces(self, cluster_id: str) -> List[Dict]:
     paas_cc = PaaSCCClient(auth=ComponentAuth(get_system_token()))
     cluster = paas_cc.get_cluster_by_id(cluster_id=cluster_id)
     ns_data = paas_cc.get_cluster_namespace_list(
         project_id=cluster['project_id'], cluster_id=cluster_id)
     return ns_data['results']