Esempio n. 1
0
    def cluster_info(self, request, project_id, cluster_id):
        # can view cluster
        self.can_view_cluster(request, project_id, cluster_id)
        cluster = self.get_cluster(request, project_id, cluster_id)
        cluster['cluster_name'] = cluster.get('name')
        cluster['created_at'] = normalize_datetime(cluster['created_at'])
        cluster['updated_at'] = normalize_datetime(cluster['updated_at'])
        status = cluster.get('status', 'normal')
        cluster['chinese_status_name'] = ClusterStatusName[status].value
        # get area info
        area_info = self.get_area(request, cluster.get('area_id'))
        cluster['area_name'] = _(area_info.get('chinese_name'))
        # get master count
        cluster['master_count'] = self.get_master_count(
            request, project_id, cluster_id)
        # get node count
        cluster['node_count'] = self.get_node_count(request, project_id,
                                                    cluster_id)
        if request.project.kind == app_constants.MESOS_KIND:
            # mesos单位是MB,需要转换为GB
            total_mem = normalize_metric(cluster['total_mem'] / 1024)
        else:
            total_mem = normalize_metric(cluster['total_mem'])
        cluster['total_mem'] = total_mem

        return response.Response(cluster)
Esempio n. 2
0
    def cluster_info(self, request, project_id, cluster_id):
        # can view cluster
        self.can_view_cluster(request, project_id, cluster_id)
        cluster = self.get_cluster(request, project_id, cluster_id)
        cluster["cluster_name"] = cluster.get("name")
        cluster["created_at"] = normalize_datetime(cluster["created_at"])
        cluster["updated_at"] = normalize_datetime(cluster["updated_at"])
        status = cluster.get("status", "normal")
        cluster["chinese_status_name"] = ClusterStatusName[status].value
        # get area info
        area_info = self.get_area(request, cluster.get("area_id"))
        cluster["area_name"] = _(area_info.get("chinese_name"))
        # get master count
        cluster["master_count"] = self.get_master_count(
            request, project_id, cluster_id)
        # get node count
        cluster["node_count"] = self.get_node_count(request, project_id,
                                                    cluster_id)
        if request.project.kind == app_constants.MESOS_KIND:
            # mesos单位是MB,需要转换为GB
            total_mem = normalize_metric(cluster["total_mem"] / 1024)
        else:
            total_mem = normalize_metric(cluster["total_mem"])
        cluster["total_mem"] = total_mem

        return response.Response(cluster)