-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
dbm-ui/backend/ticket/builders/mysql/mysql_delete_clear_db.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
import logging | ||
|
||
from django.utils.translation import ugettext as _ | ||
|
||
from backend.db_services.mysql.sql_import.constants import SQLExecuteTicketMode | ||
from backend.flow.engine.controller.mysql import MySQLController | ||
from backend.ticket import builders | ||
from backend.ticket.builders.mysql.mysql_force_import_sqlfile import ( | ||
MysqlForceSqlImportDetailSerializer, | ||
MysqlForceSqlImportFlowBuilder, | ||
MysqlForceSqlImportFlowParamBuilder, | ||
) | ||
from backend.ticket.constants import FlowRetryType, FlowType, TicketType | ||
from backend.ticket.models import Flow | ||
|
||
logger = logging.getLogger("root") | ||
|
||
|
||
class MysqlDeleteClearDBDetailSerializer(MysqlForceSqlImportDetailSerializer): | ||
def validate(self, attrs): | ||
return attrs | ||
|
||
|
||
class MysqlDeleteClearDBFlowParamBuilder(MysqlForceSqlImportFlowParamBuilder): | ||
controller = MySQLController.mysql_import_sqlfile_scene | ||
|
||
def format_ticket_data(self): | ||
pass | ||
|
||
|
||
@builders.BuilderFactory.register(TicketType.MYSQL_DELETE_CLEAR_DB, is_sensitive=True) | ||
class MysqlDeleteClearDBFlowBuilder(MysqlForceSqlImportFlowBuilder): | ||
serializer = MysqlDeleteClearDBDetailSerializer | ||
inner_flow_builder = MysqlDeleteClearDBFlowParamBuilder | ||
editable = False | ||
|
||
@property | ||
def need_itsm(self): | ||
return False | ||
|
||
def init_ticket_flows(self): | ||
""" | ||
sql导入根据执行模式可分为三种执行流程: | ||
手动:手动确认-->(备份)--->sql导入 | ||
自动:(备份)--->sql导入 | ||
定时:定时触发-->(备份)--->sql导入 | ||
""" | ||
flows = [] | ||
mode = self.ticket.details["ticket_mode"]["mode"] | ||
|
||
if mode == SQLExecuteTicketMode.MANUAL.value: | ||
flows.append(Flow(ticket=self.ticket, flow_type=FlowType.PAUSE.value, flow_alias=_("人工确认执行"))) | ||
|
||
if mode == SQLExecuteTicketMode.TIMER.value: | ||
flows.append(Flow(ticket=self.ticket, flow_type=FlowType.TIMER.value, flow_alias=_("定时执行"))) | ||
|
||
flows.append( | ||
Flow( | ||
ticket=self.ticket, | ||
flow_type=FlowType.INNER_FLOW.value, | ||
details=self.inner_flow_builder(self.ticket).get_params(), | ||
retry_type=FlowRetryType.MANUAL_RETRY.value, | ||
flow_alias=_("删除清档备份库"), | ||
) | ||
) | ||
|
||
Flow.objects.bulk_create(flows) | ||
return list(Flow.objects.filter(ticket=self.ticket)) | ||
|
||
@classmethod | ||
def describe_ticket_flows(cls, flow_config_map): | ||
flow_desc = [_("定时执行/人工执行"), _("变更SQL执行")] | ||
return flow_desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
dbm-ui/backend/ticket/builders/tendbcluster/tendb_delete_clear_db.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
import logging | ||
|
||
from backend.configuration.constants import DBType | ||
from backend.flow.engine.controller.spider import SpiderController | ||
from backend.ticket import builders | ||
from backend.ticket.builders.mysql.mysql_delete_clear_db import ( | ||
MysqlDeleteClearDBDetailSerializer, | ||
MysqlDeleteClearDBFlowBuilder, | ||
MysqlDeleteClearDBFlowParamBuilder, | ||
) | ||
from backend.ticket.constants import TicketType | ||
|
||
logger = logging.getLogger("root") | ||
|
||
|
||
class TendbClusterDeleteClearDBDetailSerializer(MysqlDeleteClearDBDetailSerializer): | ||
pass | ||
|
||
|
||
class TendbClusterDeleteClearDBFlowParamBuilder(MysqlDeleteClearDBFlowParamBuilder): | ||
controller = SpiderController.spider_sql_import_scene | ||
|
||
|
||
@builders.BuilderFactory.register(TicketType.TENDBCLUSTER_DELETE_CLEAR_DB, is_sensitive=True) | ||
class TendbClusterDeleteClearDBFlowBuilder(MysqlDeleteClearDBFlowBuilder): | ||
group = DBType.TenDBCluster | ||
serializer = TendbClusterDeleteClearDBDetailSerializer | ||
inner_flow_builder = TendbClusterDeleteClearDBFlowParamBuilder | ||
editable = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters