18
18
from backend .bk_web .constants import LEN_MIDDLE , SMALLEST_POSITIVE_INTEGER
19
19
from backend .components import DBConfigApi
20
20
from backend .components .dbconfig import constants as dbconf_const
21
- from backend .configuration .constants import MASTER_DOMAIN_INITIAL_VALUE
21
+ from backend .configuration .constants import MASTER_DOMAIN_INITIAL_VALUE , AffinityEnum
22
22
from backend .db_meta .enums import ClusterType
23
23
from backend .db_meta .models import AppCache , DBModule
24
24
from backend .db_services .dbbase .constants import IpSource
25
+ from backend .db_services .ipchooser .query .resource import ResourceQueryHelper
25
26
from backend .db_services .mysql .constants import DEFAULT_ORIGIN_MYSQL_PORT , SERVER_PORT_LIMIT_MAX , SERVER_PORT_LIMIT_MIN
26
27
from backend .exceptions import ValidationError
27
28
from backend .flow .engine .controller .mysql import MySQLController
@@ -66,6 +67,7 @@ class MysqlSingleApplyDetailSerializer(serializers.Serializer):
66
67
db_module_name = serializers .SerializerMethodField (help_text = _ ("DB模块名" ))
67
68
city_name = serializers .SerializerMethodField (help_text = _ ("城市名" ))
68
69
spec_display = serializers .SerializerMethodField (help_text = _ ("机器规格展示名" ))
70
+ bk_cloud_name = serializers .SerializerMethodField (help_text = _ ("云区域" ), read_only = True )
69
71
70
72
start_mysql_port = serializers .IntegerField (
71
73
help_text = _ ("MySQL起始端口" ),
@@ -74,6 +76,9 @@ class MysqlSingleApplyDetailSerializer(serializers.Serializer):
74
76
max_value = SERVER_PORT_LIMIT_MAX ,
75
77
default = DEFAULT_ORIGIN_MYSQL_PORT ,
76
78
)
79
+ disaster_tolerance_level = serializers .ChoiceField (
80
+ help_text = _ ("容灾级别" ), choices = AffinityEnum .get_choices (), required = False , default = AffinityEnum .NONE .value
81
+ )
77
82
78
83
def to_representation (self , instance ):
79
84
representation = super ().to_representation (instance )
@@ -107,6 +112,10 @@ def validate(self, attrs):
107
112
108
113
return attrs
109
114
115
+ def get_bk_cloud_name (self , obj ):
116
+ clouds = ResourceQueryHelper .search_cc_cloud (get_cache = True )
117
+ return clouds [str (obj ["bk_cloud_id" ])]["bk_cloud_name" ]
118
+
110
119
def get_db_module_name (self , obj ):
111
120
db_module_id = obj ["db_module_id" ]
112
121
return self .context ["ticket_ctx" ].db_module_map .get (db_module_id ) or f"db-module-{ db_module_id } "
0 commit comments