def get(self, req, app_id, *args, **kwargs): app = group_service.get_app_by_id(self.team, self.region_name, app_id) if not app: raise ErrAppNotFound services = app_service.get_app_services_and_status(app) used_cpu, used_momory = app_service.get_app_memory_and_cpu_used( services) app_info = model_to_dict(app) app_info["service_count"] = app_service.get_app_service_count(app_id) app_info["enterprise_id"] = self.enterprise.enterprise_id running_count = app_service.get_app_running_service_count( self.team, services) app_info["running_service_count"] = running_count app_status = "closed" if running_count > 0 and running_count < len(services): app_status = "part_running" if running_count > 0 and running_count == len(services): app_status = "running" app_info["status"] = app_status app_info["team_name"] = self.team.tenant_name app_info["used_cpu"] = used_cpu app_info["used_momory"] = used_momory app_info["app_id"] = app_id reapp = AppInfoSerializer(data=app_info) reapp.is_valid() return Response(reapp.data, status=status.HTTP_200_OK)
def get(self, req, app_id, *args, **kwargs): services = app_service.get_app_services_and_status(self.app) serializer = ServiceBaseInfoSerializer(data=services, many=True) serializer.is_valid() return Response(serializer.data, status=status.HTTP_200_OK)