Skip to content

Commit

Permalink
fix: if there is no cluster to create a default cluster (#1383)
Browse files Browse the repository at this point in the history
Co-authored-by: 曲源成 <[email protected]>
  • Loading branch information
quyuancheng and 曲源成 authored Aug 15, 2023
1 parent dc96b87 commit 8ed32d5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions console/views/enterprise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf8 -*-
import json
import logging
import os
import time

from django.http import StreamingHttpResponse, FileResponse
Expand Down Expand Up @@ -72,6 +73,17 @@ def get(self, request, enterprise_id, *args, **kwargs):
enter = enterprise_repo.get_enterprise_by_enterprise_id(enterprise_id=enterprise_id)
ent = enter.to_dict()
if ent:
regions = region_repo.get_regions_by_enterprise_id(self.enterprise.enterprise_id, 1)
default_region = {}
if os.getenv("ENABLE_CLUSTER") == "true" and not regions:
region = region_services.create_default_region(self.enterprise.enterprise_id, request.user)
if region:
ent["disable_install_cluster_log"] = True
_, total = team_services.get_enterprise_teams(self.enterprise.enterprise_id)
if total == 0:
region_services.create_sample_application(enter, region, request.user)
default_region = region.to_dict()
ent["default_region"] = default_region
ent.update(EnterpriseConfigService(enterprise_id).initialization_or_get_config)
result = general_message(200, "success", "查询成功", bean=ent)
return Response(result, status=result["code"])
Expand Down

0 comments on commit 8ed32d5

Please sign in to comment.