diff --git a/dbm-ui/backend/ticket/builders/common/bigdata.py b/dbm-ui/backend/ticket/builders/common/bigdata.py index f86cf5d5fc..6a4c6565e3 100644 --- a/dbm-ui/backend/ticket/builders/common/bigdata.py +++ b/dbm-ui/backend/ticket/builders/common/bigdata.py @@ -16,6 +16,7 @@ from rest_framework.serializers import ValidationError from backend.configuration.constants import AffinityEnum, DBType +from backend.db_meta.enums import ClusterType from backend.db_meta.enums.cluster_phase import ClusterPhase from backend.db_meta.models.cluster import Cluster from backend.db_meta.models.instance import StorageInstance @@ -269,26 +270,32 @@ def post_callback(self): class BaseEsTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Es.value + cluster_types = [ClusterType.Es.value] class BaseDorisTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Doris.value + cluster_types = [ClusterType.Doris.value] class BaseHdfsTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Hdfs.value + cluster_types = [ClusterType.Hdfs.value] class BaseKafkaTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Kafka.value + cluster_types = [ClusterType.Kafka.value] class BasePulsarTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Pulsar.value + cluster_types = [ClusterType.Pulsar.value] class BaseInfluxDBTicketFlowBuilder(InfluxdbTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.InfluxDB.value + cluster_types = [ClusterType.Influxdb.value] class BaseCloudTicketFlowBuilder(TicketFlowBuilder): diff --git a/dbm-ui/backend/ticket/builders/mongodb/base.py b/dbm-ui/backend/ticket/builders/mongodb/base.py index f58496d2de..109669ae8e 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/base.py +++ b/dbm-ui/backend/ticket/builders/mongodb/base.py @@ -16,6 +16,7 @@ from rest_framework import serializers from backend.configuration.constants import AffinityEnum, DBType +from backend.db_meta.enums import ClusterType from backend.db_meta.models import Cluster, Machine from backend.db_services.mongodb.resources.query import MongoDBListRetrieveResource from backend.flow.utils.mongodb.db_table_filter import MongoDbTableFilter @@ -44,6 +45,17 @@ def validate(self, attrs): class BaseMongoDBTicketFlowBuilder(MongoDBTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.MongoDB.value + cluster_types = [ClusterType.MongoReplicaSet.value, ClusterType.MongoShardedCluster.value] + + +class BaseMongoReplicaSetTicketFlowBuilder(MongoDBTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.MongoDB.value + cluster_types = [ClusterType.MongoReplicaSet.value] + + +class BaseMongoShardedTicketFlowBuilder(MongoDBTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.MongoDB.value + cluster_types = [ClusterType.MongoShardedCluster.value] class BaseMongoDBOperateDetailSerializer(SkipToRepresentationMixin, serializers.Serializer): diff --git a/dbm-ui/backend/ticket/builders/mongodb/mongo_add_mongos.py b/dbm-ui/backend/ticket/builders/mongodb/mongo_add_mongos.py index 131fd51c3a..c8af045322 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/mongo_add_mongos.py +++ b/dbm-ui/backend/ticket/builders/mongodb/mongo_add_mongos.py @@ -20,8 +20,8 @@ from backend.ticket.builders.mongodb.base import ( BaseMongoDBOperateDetailSerializer, BaseMongoDBOperateResourceParamBuilder, - BaseMongoDBTicketFlowBuilder, BaseMongoOperateFlowParamBuilder, + BaseMongoShardedTicketFlowBuilder, ) from backend.ticket.constants import TicketType @@ -68,7 +68,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MONGODB_ADD_MONGOS, is_apply=True) -class MongoDBAddMongosApplyFlowBuilder(BaseMongoDBTicketFlowBuilder): +class MongoDBAddMongosApplyFlowBuilder(BaseMongoShardedTicketFlowBuilder): serializer = MongoDBAddMongosDetailSerializer inner_flow_builder = MongoDBAddMongosFlowParamBuilder inner_flow_name = _("MongoDB 扩容接入层执行") diff --git a/dbm-ui/backend/ticket/builders/mongodb/mongo_reduce_mongos.py b/dbm-ui/backend/ticket/builders/mongodb/mongo_reduce_mongos.py index 4a4e6cb77c..bf430990ff 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/mongo_reduce_mongos.py +++ b/dbm-ui/backend/ticket/builders/mongodb/mongo_reduce_mongos.py @@ -18,8 +18,8 @@ from backend.ticket.builders.common.base import CommonValidate, HostInfoSerializer from backend.ticket.builders.mongodb.base import ( BaseMongoDBOperateDetailSerializer, - BaseMongoDBTicketFlowBuilder, BaseMongoOperateFlowParamBuilder, + BaseMongoShardedTicketFlowBuilder, ) from backend.ticket.constants import TicketType @@ -74,7 +74,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MONGODB_REDUCE_MONGOS) -class MongoDBAddMongosApplyFlowBuilder(BaseMongoDBTicketFlowBuilder): +class MongoDBAddMongosApplyFlowBuilder(BaseMongoShardedTicketFlowBuilder): serializer = MongoDBReduceMongosDetailSerializer inner_flow_builder = MongoDBReduceMongosFlowParamBuilder inner_flow_name = _("MongoDB 缩容接入层执行") diff --git a/dbm-ui/backend/ticket/builders/mongodb/mongo_replicaset_apply.py b/dbm-ui/backend/ticket/builders/mongodb/mongo_replicaset_apply.py index 60cdb2a65e..e0a0c07c2a 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/mongo_replicaset_apply.py +++ b/dbm-ui/backend/ticket/builders/mongodb/mongo_replicaset_apply.py @@ -18,7 +18,10 @@ from backend.flow.engine.controller.mongodb import MongoDBController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mongodb.base import BaseMongoDBOperateResourceParamBuilder, BaseMongoDBTicketFlowBuilder +from backend.ticket.builders.mongodb.base import ( + BaseMongoDBOperateResourceParamBuilder, + BaseMongoReplicaSetTicketFlowBuilder, +) from backend.ticket.constants import TicketType @@ -95,7 +98,7 @@ def post_callback(self): cluster_type=ClusterType.MongoReplicaSet, iam=ActionEnum.MONGODB_APPLY, ) -class MongoReplicaSetApplyFlowBuilder(BaseMongoDBTicketFlowBuilder): +class MongoReplicaSetApplyFlowBuilder(BaseMongoReplicaSetTicketFlowBuilder): serializer = MongoReplicaSetApplyDetailSerializer inner_flow_builder = MongoReplicaSetApplyFlowParamBuilder inner_flow_name = _("MongoDB 副本集集群部署执行") diff --git a/dbm-ui/backend/ticket/builders/mongodb/mongo_scale_updown.py b/dbm-ui/backend/ticket/builders/mongodb/mongo_scale_updown.py index 3f840c8e09..5419ca670c 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/mongo_scale_updown.py +++ b/dbm-ui/backend/ticket/builders/mongodb/mongo_scale_updown.py @@ -22,7 +22,7 @@ from backend.ticket.builders.mongodb.base import ( BaseMongoDBOperateDetailSerializer, BaseMongoDBOperateResourceParamBuilder, - BaseMongoDBTicketFlowBuilder, + BaseMongoShardedTicketFlowBuilder, ) from backend.ticket.builders.mongodb.mongo_backup import MongoDBBackupFlowParamBuilder from backend.ticket.constants import TicketType @@ -109,7 +109,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MONGODB_SCALE_UPDOWN, is_apply=True) -class MongoDBScaleUpDownFlowBuilder(BaseMongoDBTicketFlowBuilder): +class MongoDBScaleUpDownFlowBuilder(BaseMongoShardedTicketFlowBuilder): serializer = MongoDBScaleUpDownDetailSerializer inner_flow_builder = MongoDBScaleUpDownFlowParamBuilder inner_flow_name = _("MongoDB 集群容量变更执行") diff --git a/dbm-ui/backend/ticket/builders/mongodb/mongo_shard_apply.py b/dbm-ui/backend/ticket/builders/mongodb/mongo_shard_apply.py index 21cba0b8b0..c0fdc32260 100644 --- a/dbm-ui/backend/ticket/builders/mongodb/mongo_shard_apply.py +++ b/dbm-ui/backend/ticket/builders/mongodb/mongo_shard_apply.py @@ -18,7 +18,10 @@ from backend.flow.engine.controller.mongodb import MongoDBController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mongodb.base import BaseMongoDBOperateResourceParamBuilder, BaseMongoDBTicketFlowBuilder +from backend.ticket.builders.mongodb.base import ( + BaseMongoDBOperateResourceParamBuilder, + BaseMongoShardedTicketFlowBuilder, +) from backend.ticket.constants import TicketType @@ -95,7 +98,7 @@ def post_callback(self): cluster_type=ClusterType.MongoShardedCluster, iam=ActionEnum.MONGODB_APPLY, ) -class MongoShardedClusterApplyFlowBuilder(BaseMongoDBTicketFlowBuilder): +class MongoShardedClusterApplyFlowBuilder(BaseMongoShardedTicketFlowBuilder): serializer = MongoShardedClusterApplyDetailSerializer inner_flow_builder = MongoShardedClusterApplyFlowParamBuilder inner_flow_name = _("MongoDB 分片集群部署执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/base.py b/dbm-ui/backend/ticket/builders/mysql/base.py index 66725499f0..e67ac37ad8 100644 --- a/dbm-ui/backend/ticket/builders/mysql/base.py +++ b/dbm-ui/backend/ticket/builders/mysql/base.py @@ -35,6 +35,17 @@ class BaseMySQLTicketFlowBuilder(MySQLTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.MySQL.value + cluster_types = [ClusterType.TenDBSingle.value, ClusterType.TenDBHA.value] + + +class BaseMySQLSingleTicketFlowBuilder(MySQLTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.MySQL.value + cluster_types = [ClusterType.TenDBSingle.value] + + +class BaseMySQLHATicketFlowBuilder(MySQLTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.MySQL.value + cluster_types = [ClusterType.TenDBHA.value] class MySQLBasePauseParamBuilder(builders.PauseParamBuilder): diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_add_slave.py b/dbm-ui/backend/ticket/builders/mysql/mysql_add_slave.py index 35e040148c..aee33a3b05 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_add_slave.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_add_slave.py @@ -18,7 +18,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import BaseOperateResourceParamBuilder, HostInfoSerializer from backend.ticket.builders.common.constants import MySQLBackupSource -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import TicketType @@ -82,7 +82,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MYSQL_ADD_SLAVE, is_apply=True) -class MysqlAddSlaveFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlAddSlaveFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlAddSlaveDetailSerializer inner_flow_builder = MysqlAddSlaveParamBuilder inner_flow_name = _("添加从库执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_checksum.py b/dbm-ui/backend/ticket/builders/mysql/mysql_checksum.py index 86b65ef0ee..ff84cfa089 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_checksum.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_checksum.py @@ -25,7 +25,7 @@ from backend.ticket.builders.common.constants import MySQLChecksumTicketMode, MySQLDataRepairTriggerMode from backend.ticket.builders.common.field import DBTimezoneField from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, DBTableField, MySQLBaseOperateDetailSerializer, ) @@ -137,7 +137,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_CHECKSUM) -class MySQLChecksumFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLChecksumFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLChecksumDetailSerializer # 流程构造类 checksum_flow_builder = MySQLChecksumFlowParamBuilder diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_flashback.py b/dbm-ui/backend/ticket/builders/mysql/mysql_flashback.py index a6bad3e181..3be7be477f 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_flashback.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_flashback.py @@ -20,7 +20,7 @@ from backend.ticket.builders.common.constants import MYSQL_BINLOG_ROLLBACK from backend.ticket.builders.common.field import DBTimezoneField from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, DBTableField, MySQLBaseOperateDetailSerializer, ) @@ -72,7 +72,7 @@ class MySQLFlashbackFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_FLASHBACK) -class MySQLFlashbackFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLFlashbackFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLFlashbackDetailSerializer inner_flow_builder = MySQLFlashbackFlowParamBuilder inner_flow_name = _("闪回执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_apply.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_apply.py index c67761decd..6164cedd1b 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_apply.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_apply.py @@ -23,7 +23,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket.builders import BuilderFactory -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder from backend.ticket.builders.mysql.mysql_single_apply import ( MysqlSingleApplyDetailSerializer, MysqlSingleApplyFlowParamBuilder, @@ -124,7 +124,7 @@ def post_callback(self): @BuilderFactory.register( TicketType.MYSQL_HA_APPLY, is_apply=True, cluster_type=ClusterType.TenDBHA, iam=ActionEnum.MYSQL_APPLY ) -class MysqlHAApplyFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlHAApplyFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlHAApplyDetailSerializer inner_flow_builder = MysqlHAApplyFlowParamBuilder inner_flow_name = _("MySQL高可用部署执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_backup.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_backup.py index f5042eccf6..9a49e33e69 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_backup.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_backup.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, DBTableField, MySQLBaseOperateDetailSerializer, ) @@ -51,7 +51,7 @@ class MySQLHaBackupFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_HA_DB_TABLE_BACKUP) -class MySQLHaBackupFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLHaBackupFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLHaBackupDetailSerializer inner_flow_builder = MySQLHaBackupFlowParamBuilder inner_flow_name = _("库表备份执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_clear.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_clear.py index 6ed4e47a3f..5c28753863 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_clear.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_clear.py @@ -17,7 +17,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, DBTableField, MySQLBaseOperateDetailSerializer, ) @@ -56,7 +56,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_HA_TRUNCATE_DATA) -class MySQLHaClearFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLHaClearFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLHaClearDetailSerializer inner_flow_builder = MySQLHaClearFlowParamBuilder inner_flow_name = _("清档执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_destroy.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_destroy.py index 0a4c0b4ee2..48155291de 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_destroy.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_destroy.py @@ -18,7 +18,7 @@ from backend.flow.engine.controller.tbinlogdumper import TBinlogDumperController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.builders.tbinlogdumper.dumper_reduce_nodes import TbinlogdumperReduceNodesFlowParamBuilder from backend.ticket.constants import FlowRetryType, FlowType, TicketType from backend.ticket.models import Flow @@ -43,7 +43,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register( TicketType.MYSQL_HA_DESTROY, phase=ClusterPhase.DESTROY, iam=ActionEnum.MYSQL_DESTROY ) -class MysqlHaDestroyFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlHaDestroyFlowBuilder(BaseMySQLHATicketFlowBuilder): """Mysql下架流程的构建基类""" serializer = MysqlHADestroyDetailSerializer diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_disable.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_disable.py index 0c9213caa5..233a0c6398 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_disable.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_disable.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.constants import FlowRetryType, TicketType @@ -30,7 +30,7 @@ class MysqlHADisableFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.MYSQL_HA_DISABLE, phase=ClusterPhase.OFFLINE, iam=ActionEnum.MYSQL_ENABLE_DISABLE ) -class MysqlHaDisableFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlHaDisableFlowBuilder(BaseMySQLHATicketFlowBuilder): """Mysql下架流程的构建基类""" serializer = MysqlHADisableDetailSerializer diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_enable.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_enable.py index 64e8eef6f1..d91504ae5b 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_enable.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_enable.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.constants import FlowRetryType, TicketType @@ -30,7 +30,7 @@ class MysqlHAEnableFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.MYSQL_HA_ENABLE, phase=ClusterPhase.ONLINE, iam=ActionEnum.MYSQL_ENABLE_DISABLE ) -class MysqlHaEnableFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlHaEnableFlowBuilder(BaseMySQLHATicketFlowBuilder): """Mysql下架流程的构建基类""" serializer = MysqlHAEnableDetailSerializer diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_full_backup.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_full_backup.py index 9810cb5cef..8776c658a6 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_full_backup.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_full_backup.py @@ -18,7 +18,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders from backend.ticket.builders.common.base import fetch_cluster_ids -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import FlowRetryType, TicketType @@ -61,7 +61,7 @@ class MySQLHaFullBackupFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_HA_FULL_BACKUP) -class MySQLHaFullBackupFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLHaFullBackupFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLHaFullBackupDetailSerializer inner_flow_builder = MySQLHaFullBackupFlowParamBuilder inner_flow_name = _("全库备份执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_metadata_import.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_metadata_import.py index 8f766d19a2..907223b3fb 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_metadata_import.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_metadata_import.py @@ -21,7 +21,7 @@ from backend.db_meta.models import AppCache, DBModule, Spec from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import FlowRetryType, TicketType logger = logging.getLogger("root") @@ -237,7 +237,7 @@ class TenDBHAMetadataImportFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_HA_METADATA_IMPORT) -class TenDBHAMetadataImportFlowBuilder(BaseMySQLTicketFlowBuilder): +class TenDBHAMetadataImportFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = TenDBHAMetadataImportDetailSerializer inner_flow_builder = TenDBHAMetadataImportFlowParamBuilder inner_flow_name = _("MySQL高可用元数据导入") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_rename.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_rename.py index b0f0685e24..9adbb81953 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_rename.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_rename.py @@ -18,7 +18,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import CommonValidate from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, DBTableField, MySQLBaseOperateDetailSerializer, ) @@ -61,7 +61,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_HA_RENAME_DATABASE) -class MySQLHaRenameFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLHaRenameFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MySQLHaRenameSerializer inner_flow_builder = MySQLHaRenameFlowParamBuilder inner_flow_name = _("DB重命名执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_standardize.py b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_standardize.py index 33d83a8ec8..54479d298a 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_ha_standardize.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_ha_standardize.py @@ -17,7 +17,7 @@ from backend.db_meta.models import AppCache, Cluster from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import FlowRetryType, TicketType @@ -66,7 +66,7 @@ class MysqlHaStandardizeFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_HA_STANDARDIZE) -class MysqlStandardizeFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlStandardizeFlowBuilder(BaseMySQLHATicketFlowBuilder): """Mysql下架流程的构建基类""" serializer = TenDBHAStandardizeDetailSerializer diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_master_slave_switch.py b/dbm-ui/backend/ticket/builders/mysql/mysql_master_slave_switch.py index 83447725ef..7dce82db73 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_master_slave_switch.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_master_slave_switch.py @@ -22,7 +22,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import HostInfoSerializer from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer, MySQLBasePauseParamBuilder, ) @@ -98,7 +98,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_MASTER_SLAVE_SWITCH) -class MysqlMasterSlaveSwitchFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlMasterSlaveSwitchFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlMasterSlaveSwitchDetailSerializer inner_flow_builder = MysqlMasterSlaveSwitchParamBuilder inner_flow_name = _("主从互换执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_migrate_cluster.py b/dbm-ui/backend/ticket/builders/mysql/mysql_migrate_cluster.py index f25b3f920f..fc18d390eb 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_migrate_cluster.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_migrate_cluster.py @@ -18,7 +18,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import BaseOperateResourceParamBuilder, HostInfoSerializer from backend.ticket.builders.common.constants import MySQLBackupSource -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import FlowRetryType, TicketType @@ -84,7 +84,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MYSQL_MIGRATE_CLUSTER, is_apply=True) -class MysqlMigrateClusterFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlMigrateClusterFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlMigrateClusterDetailSerializer inner_flow_builder = MysqlMigrateClusterParamBuilder inner_flow_name = _("迁移主从执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_add.py b/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_add.py index b31ff5a3e5..55be8aa48a 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_add.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_add.py @@ -17,7 +17,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders from backend.ticket.builders.common.base import BaseOperateResourceParamBuilder, HostInfoSerializer -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import TicketType @@ -72,7 +72,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MYSQL_PROXY_ADD, is_apply=True) -class MysqlProxyAddFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlProxyAddFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlProxyAddDetailSerializer inner_flow_builder = MysqlProxyAddParamBuilder inner_flow_name = _("添加PROXY执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_switch.py b/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_switch.py index c954dc1b31..4e11a44fba 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_switch.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_proxy_switch.py @@ -22,7 +22,7 @@ InstanceInfoSerializer, ) from backend.ticket.builders.mysql.base import ( - BaseMySQLTicketFlowBuilder, + BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer, MySQLBasePauseParamBuilder, ) @@ -90,7 +90,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.MYSQL_PROXY_SWITCH, is_apply=True) -class MysqlProxySwitchFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlProxySwitchFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlProxySwitchDetailSerializer inner_flow_builder = MysqlProxySwitchParamBuilder inner_flow_name = _("替换PROXY执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_restore_local_slave.py b/dbm-ui/backend/ticket/builders/mysql/mysql_restore_local_slave.py index c128345518..d41db9a208 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_restore_local_slave.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_restore_local_slave.py @@ -17,7 +17,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import InstanceInfoSerializer from backend.ticket.builders.common.constants import MySQLBackupSource -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import TicketType @@ -66,7 +66,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_RESTORE_LOCAL_SLAVE) -class MysqlRestoreLocalSlaveFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlRestoreLocalSlaveFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlRestoreLocalSlaveDetailSerializer inner_flow_builder = MysqlRestoreLocalSlaveParamBuilder inner_flow_name = _("Slave原地重建执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_restore_slave.py b/dbm-ui/backend/ticket/builders/mysql/mysql_restore_slave.py index 3bf7793751..e61113ae61 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_restore_slave.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_restore_slave.py @@ -17,7 +17,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import HostInfoSerializer, InstanceInfoSerializer from backend.ticket.builders.common.constants import MySQLBackupSource -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLBaseOperateDetailSerializer +from backend.ticket.builders.mysql.base import BaseMySQLHATicketFlowBuilder, MySQLBaseOperateDetailSerializer from backend.ticket.constants import TicketType @@ -70,7 +70,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_RESTORE_SLAVE, is_apply=True) -class MysqlRestoreSlaveFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlRestoreSlaveFlowBuilder(BaseMySQLHATicketFlowBuilder): serializer = MysqlRestoreSlaveDetailSerializer inner_flow_builder = MysqlRestoreSlaveParamBuilder inner_flow_name = _("Slave重建执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_apply.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_apply.py index 333d992d98..63596456c6 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_apply.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_apply.py @@ -28,7 +28,7 @@ from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders from backend.ticket.builders.common.base import CommonValidate -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder from backend.ticket.constants import TicketType from backend.ticket.exceptions import TicketParamsVerifyException @@ -198,7 +198,7 @@ def post_callback(self): @builders.BuilderFactory.register( TicketType.MYSQL_SINGLE_APPLY, is_apply=True, cluster_type=ClusterType.TenDBSingle, iam=ActionEnum.MYSQL_APPLY ) -class MysqlSingleApplyFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlSingleApplyFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MysqlSingleApplyDetailSerializer inner_flow_builder = MysqlSingleApplyFlowParamBuilder inner_flow_name = _("MySQL单节点部署执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_clear.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_clear.py index b3405e7a21..d07ed3ac61 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_clear.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_clear.py @@ -14,7 +14,7 @@ from backend.db_meta.enums import ClusterType from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder from backend.ticket.builders.mysql.mysql_ha_clear import MySQLHaClearDetailSerializer, MySQLHaClearFlowParamBuilder from backend.ticket.constants import TicketType @@ -40,7 +40,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.MYSQL_SINGLE_TRUNCATE_DATA) -class MySQLSingleClearFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLSingleClearFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MySQLSingleClearDetailSerializer inner_flow_builder = MySQLSingleClearFlowParamBuilder inner_flow_name = _("MySQL 单节点清档执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_destroy.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_destroy.py index ebbc18dd09..d61ecabaef 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_destroy.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_destroy.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.constants import TicketType @@ -30,7 +30,7 @@ class MysqlSingleDestroyFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.MYSQL_SINGLE_DESTROY, phase=ClusterPhase.DESTROY, iam=ActionEnum.MYSQL_DESTROY ) -class MysqlSingleDestroyFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlSingleDestroyFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MysqlSingleDestroyDetailSerializer inner_flow_builder = MysqlSingleDestroyFlowParamBuilder inner_flow_name = _("MySQL单节点销毁执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_disable.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_disable.py index dfc8c74aab..7330bcf923 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_disable.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_disable.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.constants import TicketType @@ -30,7 +30,7 @@ class MysqlSingleDisableFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.MYSQL_SINGLE_DISABLE, phase=ClusterPhase.OFFLINE, iam=ActionEnum.MYSQL_ENABLE_DISABLE ) -class MysqlSingleDisableFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlSingleDisableFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MysqlSingleDisableDetailSerializer inner_flow_builder = MysqlSingleDisableFlowParamBuilder inner_flow_name = _("MySQL单节点禁用执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_enable.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_enable.py index 8372721d35..b02190f76b 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_enable.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_enable.py @@ -15,7 +15,7 @@ from backend.flow.engine.controller.mysql import MySQLController from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder, MySQLClustersTakeDownDetailsSerializer from backend.ticket.constants import TicketType @@ -30,7 +30,7 @@ class MysqlSingleEnableFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.MYSQL_SINGLE_ENABLE, phase=ClusterPhase.ONLINE, iam=ActionEnum.MYSQL_ENABLE_DISABLE ) -class MysqlSingleEnableFlowBuilder(BaseMySQLTicketFlowBuilder): +class MysqlSingleEnableFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MysqlSingleEnableDetailSerializer inner_flow_builder = MysqlSingleEnableFlowParamBuilder inner_flow_name = _("MySQL单节点启用执行") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_single_rename.py b/dbm-ui/backend/ticket/builders/mysql/mysql_single_rename.py index 33a6786667..0a68742259 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_single_rename.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_single_rename.py @@ -14,7 +14,7 @@ from backend.db_meta.enums import ClusterType from backend.flow.engine.controller.mysql import MySQLController from backend.ticket import builders -from backend.ticket.builders.mysql.base import BaseMySQLTicketFlowBuilder +from backend.ticket.builders.mysql.base import BaseMySQLSingleTicketFlowBuilder from backend.ticket.builders.mysql.mysql_ha_rename import MySQLHaRenameFlowParamBuilder, MySQLHaRenameSerializer from backend.ticket.constants import TicketType @@ -34,7 +34,7 @@ class MySQLSingleRenameFlowParamBuilder(MySQLHaRenameFlowParamBuilder): @builders.BuilderFactory.register(TicketType.MYSQL_SINGLE_RENAME_DATABASE) -class MySQLSingleClearFlowBuilder(BaseMySQLTicketFlowBuilder): +class MySQLSingleClearFlowBuilder(BaseMySQLSingleTicketFlowBuilder): serializer = MySQLSingleRenameDetailSerializer inner_flow_builder = MySQLSingleRenameFlowParamBuilder inner_flow_name = _("MySQL 单节点DB重命名执行") diff --git a/dbm-ui/backend/ticket/builders/redis/base.py b/dbm-ui/backend/ticket/builders/redis/base.py index 3e93b1ecf7..69fd4a341d 100644 --- a/dbm-ui/backend/ticket/builders/redis/base.py +++ b/dbm-ui/backend/ticket/builders/redis/base.py @@ -16,7 +16,7 @@ from backend.configuration.constants import DBType from backend.core.storages.storage import get_storage -from backend.db_meta.enums import ClusterPhase +from backend.db_meta.enums import ClusterPhase, ClusterType from backend.db_meta.models import Cluster from backend.db_services.redis.constants import KeyDeleteType from backend.ticket import builders @@ -29,6 +29,18 @@ class BaseRedisTicketFlowBuilder(RedisTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Redis.value + cluster_types = [ClusterType.TendisRedisInstance.value] + + +class BaseRedisInstanceTicketFlowBuilder(RedisTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.Redis.value + cluster_types = [ + ClusterType.TendisPredixyRedisCluster.value, + ClusterType.TendisPredixyTendisplusCluster.value, + ClusterType.TendisTwemproxyRedisInstance.value, + ClusterType.TwemproxyTendisSSDInstance.value, + ClusterType.TendisRedisInstance.value, + ] class RedisSingleOpsBaseDetailSerializer(SkipToRepresentationMixin, serializers.Serializer): diff --git a/dbm-ui/backend/ticket/builders/redis/redis_close.py b/dbm-ui/backend/ticket/builders/redis/redis_close.py index 7f92ff7e9b..db1fc0e483 100644 --- a/dbm-ui/backend/ticket/builders/redis/redis_close.py +++ b/dbm-ui/backend/ticket/builders/redis/redis_close.py @@ -16,7 +16,11 @@ from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders from backend.ticket.builders.common.base import SkipToRepresentationMixin -from backend.ticket.builders.redis.base import BaseRedisTicketFlowBuilder, RedisSingleOpsBaseDetailSerializer +from backend.ticket.builders.redis.base import ( + BaseRedisInstanceTicketFlowBuilder, + BaseRedisTicketFlowBuilder, + RedisSingleOpsBaseDetailSerializer, +) from backend.ticket.constants import TicketType @@ -63,7 +67,7 @@ class RedisInstanceCloseFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.REDIS_INSTANCE_CLOSE, phase=ClusterPhase.OFFLINE, iam=ActionEnum.REDIS_OPEN_CLOSE ) -class RedisInstanceCloseFlowBuilder(BaseRedisTicketFlowBuilder): +class RedisInstanceCloseFlowBuilder(BaseRedisInstanceTicketFlowBuilder): serializer = RedisInstanceCloseDetailSerializer inner_flow_builder = RedisInstanceCloseFlowParamBuilder inner_flow_name = _("禁用集群") diff --git a/dbm-ui/backend/ticket/builders/redis/redis_destroy.py b/dbm-ui/backend/ticket/builders/redis/redis_destroy.py index 85691f0587..09407f4327 100644 --- a/dbm-ui/backend/ticket/builders/redis/redis_destroy.py +++ b/dbm-ui/backend/ticket/builders/redis/redis_destroy.py @@ -16,6 +16,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import SkipToRepresentationMixin from backend.ticket.builders.redis.base import ( + BaseRedisInstanceTicketFlowBuilder, BaseRedisTicketFlowBuilder, RedisBasePauseParamBuilder, RedisSingleOpsBaseDetailSerializer, @@ -59,7 +60,7 @@ class RedisInstanceDestroyFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.REDIS_INSTANCE_DESTROY, phase=ClusterPhase.DESTROY) -class RedisInstanceCloseFlowBuilder(BaseRedisTicketFlowBuilder): +class RedisInstanceCloseFlowBuilder(BaseRedisInstanceTicketFlowBuilder): serializer = RedisInstanceDestroyDetailSerializer inner_flow_builder = RedisInstanceDestroyFlowParamBuilder inner_flow_name = _("下架集群") diff --git a/dbm-ui/backend/ticket/builders/redis/redis_instance_apply.py b/dbm-ui/backend/ticket/builders/redis/redis_instance_apply.py index ed456ec1b5..ddbed12be0 100644 --- a/dbm-ui/backend/ticket/builders/redis/redis_instance_apply.py +++ b/dbm-ui/backend/ticket/builders/redis/redis_instance_apply.py @@ -21,7 +21,7 @@ from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders from backend.ticket.builders.common.base import CommonValidate, SkipToRepresentationMixin -from backend.ticket.builders.redis.base import BaseRedisTicketFlowBuilder +from backend.ticket.builders.redis.base import BaseRedisInstanceTicketFlowBuilder from backend.ticket.constants import TicketType @@ -161,7 +161,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.REDIS_INS_APPLY, is_apply=True, iam=ActionEnum.REDIS_CLUSTER_APPLY) -class RedisClusterApplyFlowBuilder(BaseRedisTicketFlowBuilder): +class RedisClusterApplyFlowBuilder(BaseRedisInstanceTicketFlowBuilder): serializer = RedisInstanceApplyDetailSerializer inner_flow_builder = RedisInstanceApplyFlowParamBuilder inner_flow_name = _("Redis 主从部署") diff --git a/dbm-ui/backend/ticket/builders/redis/redis_open.py b/dbm-ui/backend/ticket/builders/redis/redis_open.py index 2b42e2789c..657cbf6609 100644 --- a/dbm-ui/backend/ticket/builders/redis/redis_open.py +++ b/dbm-ui/backend/ticket/builders/redis/redis_open.py @@ -16,7 +16,11 @@ from backend.iam_app.dataclass.actions import ActionEnum from backend.ticket import builders from backend.ticket.builders.common.base import SkipToRepresentationMixin -from backend.ticket.builders.redis.base import BaseRedisTicketFlowBuilder, RedisSingleOpsBaseDetailSerializer +from backend.ticket.builders.redis.base import ( + BaseRedisInstanceTicketFlowBuilder, + BaseRedisTicketFlowBuilder, + RedisSingleOpsBaseDetailSerializer, +) from backend.ticket.constants import TicketType @@ -60,7 +64,7 @@ class RedisInstanceOpenFlowParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register( TicketType.REDIS_INSTANCE_OPEN, phase=ClusterPhase.ONLINE, iam=ActionEnum.REDIS_OPEN_CLOSE ) -class RedisInstanceCloseFlowBuilder(BaseRedisTicketFlowBuilder): +class RedisInstanceCloseFlowBuilder(BaseRedisInstanceTicketFlowBuilder): serializer = RedisInstanceOpenDetailSerializer inner_flow_builder = RedisInstanceOpenFlowParamBuilder inner_flow_name = _("启用集群") diff --git a/dbm-ui/backend/ticket/builders/redis/redis_toolbox_master_slave_switch.py b/dbm-ui/backend/ticket/builders/redis/redis_toolbox_master_slave_switch.py index 23b2a69742..69755e6cdf 100644 --- a/dbm-ui/backend/ticket/builders/redis/redis_toolbox_master_slave_switch.py +++ b/dbm-ui/backend/ticket/builders/redis/redis_toolbox_master_slave_switch.py @@ -17,7 +17,7 @@ from backend.flow.engine.controller.redis import RedisController from backend.ticket import builders from backend.ticket.builders.common.base import SkipToRepresentationMixin -from backend.ticket.builders.redis.base import BaseRedisTicketFlowBuilder, ClusterValidateMixin +from backend.ticket.builders.redis.base import BaseRedisInstanceTicketFlowBuilder, ClusterValidateMixin from backend.ticket.constants import SwitchConfirmType, TicketType @@ -67,7 +67,7 @@ class RedisMasterSlaveSwitchParamBuilder(builders.FlowParamBuilder): @builders.BuilderFactory.register(TicketType.REDIS_MASTER_SLAVE_SWITCH) -class RedisMasterSlaveSwitchFlowBuilder(BaseRedisTicketFlowBuilder): +class RedisMasterSlaveSwitchFlowBuilder(BaseRedisInstanceTicketFlowBuilder): serializer = RedisMasterSlaveSwitchDetailSerializer inner_flow_builder = RedisMasterSlaveSwitchParamBuilder inner_flow_name = _("Redis 主从切换") diff --git a/dbm-ui/backend/ticket/builders/riak/base.py b/dbm-ui/backend/ticket/builders/riak/base.py index d9ae4e2dae..1759ef134a 100644 --- a/dbm-ui/backend/ticket/builders/riak/base.py +++ b/dbm-ui/backend/ticket/builders/riak/base.py @@ -10,6 +10,7 @@ """ from backend.configuration.constants import DBType +from backend.db_meta.enums import ClusterType from backend.ticket.builders import TicketFlowBuilder from backend.ticket.builders.common.base import BigDataTicketFlowBuilderPatchMixin @@ -19,3 +20,4 @@ class BaseRiakTicketFlowBuilder(BigDataTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Riak.value + cluster_types = [ClusterType.Riak.value] diff --git a/dbm-ui/backend/ticket/builders/sqlserver/base.py b/dbm-ui/backend/ticket/builders/sqlserver/base.py index 73b9462451..4c31a8ce65 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/base.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/base.py @@ -31,6 +31,19 @@ class BaseSQLServerTicketFlowBuilder(SQLServerTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.Sqlserver.value retry_type = FlowRetryType.MANUAL_RETRY + cluster_types = [ClusterType.SqlserverHA.value, ClusterType.SqlserverSingle.value] + + +class BaseSQLServerHATicketFlowBuilder(SQLServerTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.Sqlserver.value + retry_type = FlowRetryType.MANUAL_RETRY + cluster_types = [ClusterType.SqlserverHA.value] + + +class BaseSQLServerSingleTicketFlowBuilder(SQLServerTicketFlowBuilderPatchMixin, TicketFlowBuilder): + group = DBType.Sqlserver.value + retry_type = FlowRetryType.MANUAL_RETRY + cluster_types = [ClusterType.SqlserverSingle.value] class SQLServerBasePauseParamBuilder(builders.PauseParamBuilder): diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_add_slave.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_add_slave.py index a7d8f8fccf..7eef8102bd 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_add_slave.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_add_slave.py @@ -18,7 +18,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import HostInfoSerializer from backend.ticket.builders.sqlserver.base import ( - BaseSQLServerTicketFlowBuilder, + BaseSQLServerHATicketFlowBuilder, SQLServerBaseOperateDetailSerializer, SQLServerBaseOperateResourceParamBuilder, ) @@ -59,7 +59,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.SQLSERVER_ADD_SLAVE) -class SQLServerAddSlaveFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerAddSlaveFlowBuilder(BaseSQLServerHATicketFlowBuilder): serializer = SQLServerAddSlaveDetailSerializer resource_batch_apply_builder = SQLServerAddSlaveResourceParamBuilder inner_flow_builder = SQLServerAddSlaveFlowParamBuilder diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_fail_over.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_fail_over.py index 1d41b61b30..e80a330fe6 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_fail_over.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_fail_over.py @@ -15,7 +15,7 @@ from backend.db_meta.enums import ClusterType from backend.flow.engine.controller.sqlserver import SqlserverController from backend.ticket import builders -from backend.ticket.builders.sqlserver.base import BaseSQLServerTicketFlowBuilder +from backend.ticket.builders.sqlserver.base import BaseSQLServerHATicketFlowBuilder from backend.ticket.builders.sqlserver.sqlserver_master_slave_switch import SQLServerMasterSlaveSwitchDetailSerializer from backend.ticket.constants import TicketType @@ -38,7 +38,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.SQLSERVER_MASTER_FAIL_OVER) -class SQLServerMasterSlaveSwitchFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerMasterSlaveSwitchFlowBuilder(BaseSQLServerHATicketFlowBuilder): serializer = SQLServerMasterFailOverDetailSerializer inner_flow_builder = SQLServerMasterFailOverParamBuilder inner_flow_name = _("SQLServer 主故障切换执行") diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_slave_switch.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_slave_switch.py index a08a9e7ae3..8e8089c9a8 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_slave_switch.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_master_slave_switch.py @@ -15,7 +15,10 @@ from backend.flow.engine.controller.sqlserver import SqlserverController from backend.ticket import builders from backend.ticket.builders.common.base import CommonValidate, HostInfoSerializer -from backend.ticket.builders.sqlserver.base import BaseSQLServerTicketFlowBuilder, SQLServerBaseOperateDetailSerializer +from backend.ticket.builders.sqlserver.base import ( + BaseSQLServerHATicketFlowBuilder, + SQLServerBaseOperateDetailSerializer, +) from backend.ticket.constants import TicketType @@ -49,7 +52,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.SQLSERVER_MASTER_SLAVE_SWITCH) -class SQLServerMasterSlaveSwitchFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerMasterSlaveSwitchFlowBuilder(BaseSQLServerHATicketFlowBuilder): serializer = SQLServerMasterSlaveSwitchDetailSerializer inner_flow_builder = SQLServerMasterSlaveSwitchParamBuilder inner_flow_name = _("SQLServer 主从互换执行") diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_local_slave.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_local_slave.py index e9f2969ad6..667b46f7e0 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_local_slave.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_local_slave.py @@ -16,7 +16,10 @@ from backend.flow.engine.controller.sqlserver import SqlserverController from backend.ticket import builders from backend.ticket.builders.common.base import InstanceInfoSerializer -from backend.ticket.builders.sqlserver.base import BaseSQLServerTicketFlowBuilder, SQLServerBaseOperateDetailSerializer +from backend.ticket.builders.sqlserver.base import ( + BaseSQLServerHATicketFlowBuilder, + SQLServerBaseOperateDetailSerializer, +) from backend.ticket.constants import TicketType @@ -51,7 +54,7 @@ def format_ticket_data(self): @builders.BuilderFactory.register(TicketType.SQLSERVER_RESTORE_LOCAL_SLAVE) -class SQLServerRestoreLocalSlaveFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerRestoreLocalSlaveFlowBuilder(BaseSQLServerHATicketFlowBuilder): serializer = SQLServerRestoreLocalSlaveDetailSerializer inner_flow_builder = SQLServerRestoreLocalSlaveParamBuilder inner_flow_name = _("SQLServer Slave原地重建执行") diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py index 5fc53a845b..472b8d01d6 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py @@ -20,7 +20,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import HostInfoSerializer from backend.ticket.builders.sqlserver.base import ( - BaseSQLServerTicketFlowBuilder, + BaseSQLServerHATicketFlowBuilder, SQLServerBaseOperateDetailSerializer, SQLServerBaseOperateResourceParamBuilder, ) @@ -109,7 +109,7 @@ def post_callback(self): @builders.BuilderFactory.register(TicketType.SQLSERVER_RESTORE_SLAVE) -class SQLServerRestoreSlaveFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerRestoreSlaveFlowBuilder(BaseSQLServerHATicketFlowBuilder): serializer = SQLServerRestoreSlaveDetailSerializer resource_batch_apply_builder = SQLServerRestoreSlaveResourceParamBuilder inner_flow_builder = SQLServerRestoreSlaveFlowParamBuilder diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_single_apply.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_single_apply.py index 7285191301..1cf549d176 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_single_apply.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_single_apply.py @@ -29,7 +29,7 @@ from backend.ticket import builders from backend.ticket.builders.common.base import CommonValidate from backend.ticket.builders.sqlserver.base import ( - BaseSQLServerTicketFlowBuilder, + BaseSQLServerSingleTicketFlowBuilder, SQLServerBaseOperateResourceParamBuilder, ) from backend.ticket.constants import TicketType @@ -200,7 +200,7 @@ def post_callback(self): cluster_type=ClusterType.SqlserverSingle, iam=ActionEnum.SQLSERVER_APPLY, ) -class SQLServerSingleApplyFlowBuilder(BaseSQLServerTicketFlowBuilder): +class SQLServerSingleApplyFlowBuilder(BaseSQLServerSingleTicketFlowBuilder): serializer = SQLServerSingleApplyDetailSerializer inner_flow_builder = SQLServerSingleApplyFlowParamBuilder inner_flow_name = _("SQLServer 单节点部署执行") diff --git a/dbm-ui/backend/ticket/builders/tendbcluster/base.py b/dbm-ui/backend/ticket/builders/tendbcluster/base.py index 1183a7ee64..632f3a42f6 100644 --- a/dbm-ui/backend/ticket/builders/tendbcluster/base.py +++ b/dbm-ui/backend/ticket/builders/tendbcluster/base.py @@ -13,7 +13,7 @@ from rest_framework import serializers from backend.configuration.constants import DBType -from backend.db_meta.enums import ClusterTenDBClusterStatusFlag, TenDBClusterSpiderRole +from backend.db_meta.enums import ClusterTenDBClusterStatusFlag, ClusterType, TenDBClusterSpiderRole from backend.db_meta.models import Cluster from backend.flow.consts import MAX_SPIDER_MASTER_COUNT, MIN_SPIDER_MASTER_COUNT, MIN_SPIDER_SLAVE_COUNT from backend.ticket import builders @@ -30,10 +30,12 @@ class BaseTendbTicketFlowBuilder(MySQLTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.TenDBCluster.value + cluster_types = [ClusterType.TenDBCluster.value] class BaseDumperTicketFlowBuilder(DumperTicketFlowBuilderPatchMixin, TicketFlowBuilder): group = DBType.MySQL.value + cluster_types = [ClusterType.TBinlogDumper] class TendbBasePauseParamBuilder(builders.PauseParamBuilder): diff --git a/dbm-ui/backend/ticket/constants.py b/dbm-ui/backend/ticket/constants.py index a51fc431a2..11807d966f 100644 --- a/dbm-ui/backend/ticket/constants.py +++ b/dbm-ui/backend/ticket/constants.py @@ -156,6 +156,17 @@ def get_db_type_by_ticket(cls, ticket_type, raise_exception=False): return "" raise TicketBaseException(_("无法找到{}关联的组件类型").format(ticket_type)) + @classmethod + def get_cluster_type_by_ticket(cls, ticket_type): + """根据单据类型找到集群类型""" + # 延迟导入避免循环依赖 + from backend.ticket.builders import BuilderFactory + + builder = BuilderFactory.get_builder_cls(ticket_type) + if not builder.cluster_types: + raise TicketBaseException(_("无法找到{}关联的集群类型").format(ticket_type)) + return builder.cluster_types + # fmt: off # MYSQL MYSQL_SINGLE_APPLY = TicketEnumField("MYSQL_SINGLE_APPLY", _("MySQL 单节点部署"), register_iam=False)