Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: if there is no cluster to create a default cluster #1383

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading