Esempio n. 1
0
def get_cluster_namespaces(ctx_cluster: CtxCluster, namespace: str) -> Dict:
    """获取集群下的命名空间信息
    :returns: 返回集群下的命名空间信息,格式: {"count": 1, "results": []}
    """
    client = paas_cc.PaaSCCClient(
        ComponentAuth(ctx_cluster.context.auth.access_token))
    return client.get_cluster_namespace_list(project_id=ctx_cluster.project_id,
                                             cluster_id=ctx_cluster.id)
Esempio n. 2
0
def cache_api_host(access_token, project_id, cluster_id, env):
    """cached api host
    cache performance, importance, cluster id shoud be unique
    """
    if cluster_id:
        client = paas_cc.PaaSCCClient(auth=ComponentAuth(access_token))
        cluster = client.get_cluster_by_id(cluster_id)
        stag = settings.BCS_API_ENV[cluster['environment']]
    else:
        stag = env

    return f"{BCS_API_PRE_URL}/{stag}"
Esempio n. 3
0
 def _bcs_cc_client(self) -> comp_base.BkApiClient:
     token = paas_auth.get_access_token()
     access_token = token["access_token"]
     return paas_cc.PaaSCCClient(
         comp_base.ComponentAuth(access_token=access_token))