Ejemplo n.º 1
0
def get_cluster_snapshot(access_token, project_id, cluster_id):
    """获取集群快照
    """
    resp = paas_cc.get_cluster_snapshot(access_token, project_id, cluster_id)
    if resp.get("code") != ErrorCode.NoError:
        raise error_codes.APIError(_("获取集群快照失败,{}").format(resp.get("message")))
    return resp.get("data") or {}
Ejemplo n.º 2
0
 def get_cluster_snapshot(self):
     snapshot_info = paas_cc.get_cluster_snapshot(self.access_token,
                                                  self.project_id,
                                                  self.cluster_id)
     if snapshot_info.get('code') != ErrorCode.NoError:
         raise error_codes.APIError(snapshot_info.get('message'))
     return snapshot_info.get('data', {})
Ejemplo n.º 3
0
 def get_cluster_snapshot(self):
     snapshot_info = paas_cc.get_cluster_snapshot(self.access_token,
                                                  self.project_id,
                                                  self.cluster_id)
     if snapshot_info.get('code') != ErrorCode.NoError:
         self.update_cluster_status(status=CommonStatus.RemoveFailed)
         raise error_codes.APIError(snapshot_info.get('message'))
     return snapshot_info.get('data', {})
Ejemplo n.º 4
0
def get_cluster_version(access_token, project_id, cluster_id):
    snapshot = paas_cc.get_cluster_snapshot(access_token, project_id,
                                            cluster_id)
    try:
        configure = json.loads(snapshot["data"]["configure"])
        version = configure["version"]  # "1.12.3"
    except Exception as e:
        version = ''
        logger.exception("get_cluster_version failed, %s", e)
    return version
Ejemplo n.º 5
0
def get_cluster_proper_kubectl(access_token, project_id, cluster_id):
    snapshot = paas_cc.get_cluster_snapshot(access_token, project_id,
                                            cluster_id)
    # version is default, not allow to select
    try:
        configure = json.loads(snapshot['data']['configure'])
        version = configure['version']  # "1.12.3"
        return settings.KUBECTL_BIN_MAP[version], version
    except Exception as e:
        logger.exception(f'get_cluster_proper_kubectl_bin failed, {e}')

    return settings.KUBECTL_BIN, None