@@ -54,70 +54,3 @@ class SpecMachineType(str, StructuredEnum):
5454 DORIS_FOLLOWER = EnumField ("doris_follower" , _ ("doris_follower" ))
5555 DORIS_OBSERVER = EnumField ("doris_observer" , _ ("doris_observer" ))
5656 DORIS_BACKEND = EnumField ("doris_backend" , _ ("doris_backend" ))
57-
58-
59- # TODO: 规格迁移脚本函数,迁移完成后删除
60- def migrate_spec ():
61- from django .db import transaction
62-
63- from backend .configuration .constants import DBType
64- from backend .db_meta .enums import ClusterType , MachineType
65- from backend .db_meta .models .spec import Spec
66-
67- # 原规格层级和新规格层级的映射
68- MIGRATE_SPEC_MACHINE_MAP = {
69- MachineType .SINGLE : SpecMachineType .BACKEND ,
70- MachineType .BACKEND : SpecMachineType .BACKEND ,
71- MachineType .PROXY : SpecMachineType .PROXY ,
72- MachineType .SPIDER : SpecMachineType .PROXY ,
73- MachineType .REMOTE : SpecMachineType .BACKEND ,
74- ClusterType .TendisTwemproxyRedisInstance : {
75- MachineType .TENDISCACHE : SpecMachineType .TendisTwemproxyRedisInstance ,
76- MachineType .TWEMPROXY : SpecMachineType .PROXY ,
77- },
78- ClusterType .TwemproxyTendisSSDInstance : {
79- MachineType .TENDISSSD : SpecMachineType .TwemproxyTendisSSDInstance ,
80- MachineType .TWEMPROXY : SpecMachineType .PROXY ,
81- },
82- ClusterType .TendisPredixyTendisplusCluster : {
83- MachineType .TENDISPLUS : SpecMachineType .TendisPredixyTendisplusCluster ,
84- MachineType .PREDIXY : SpecMachineType .PROXY ,
85- },
86- ClusterType .TendisPredixyRedisCluster : {
87- MachineType .TENDISCACHE : SpecMachineType .TendisTwemproxyRedisInstance ,
88- MachineType .PREDIXY : SpecMachineType .PROXY ,
89- },
90- ClusterType .TendisRedisInstance : {
91- MachineType .TENDISCACHE : SpecMachineType .TendisTwemproxyRedisInstance ,
92- },
93- MachineType .SQLSERVER_HA : SpecMachineType .SQLSERVER ,
94- MachineType .SQLSERVER_SINGLE : SpecMachineType .SQLSERVER ,
95- MachineType .MONGOS : SpecMachineType .MONGOS ,
96- MachineType .MONGODB : SpecMachineType .MONGODB ,
97- MachineType .MONOG_CONFIG : SpecMachineType .MONOG_CONFIG ,
98- }
99-
100- specs = Spec .objects .all ()
101- with transaction .atomic ():
102- for spec in specs :
103- db_type = ClusterType .cluster_type_to_db_type (spec .spec_cluster_type )
104- if db_type in [
105- DBType .Es ,
106- DBType .Kafka ,
107- DBType .Hdfs ,
108- DBType .InfluxDB ,
109- DBType .Pulsar ,
110- DBType .Vm ,
111- DBType .Doris ,
112- DBType .Riak ,
113- ]:
114- continue
115-
116- if db_type == DBType .Redis :
117- spec .spec_machine_type = MIGRATE_SPEC_MACHINE_MAP [spec .spec_cluster_type ][spec .spec_machine_type ]
118- spec .spec_cluster_type = db_type
119- spec .save ()
120- else :
121- spec .spec_machine_type = MIGRATE_SPEC_MACHINE_MAP [spec .spec_machine_type ]
122- spec .spec_cluster_type = db_type
123- spec .save ()
0 commit comments