-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Reviewed, transaction id: 25576
- Loading branch information
Showing
11 changed files
with
256 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- 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.apps import AppConfig | ||
from django.db.models.signals import post_migrate | ||
|
||
logger = logging.getLogger("root") | ||
|
||
|
||
def init_default_modules(sender, **kwargs): | ||
from backend.db_services.redis.redis_modules.models import TbRedisModuleSupport | ||
|
||
try: | ||
TbRedisModuleSupport.init_default_modules() | ||
except Exception as err: # pylint: disable=broad-except: | ||
logger.warning(f"init_default_modules occur error, {err}") | ||
|
||
|
||
class InstanceConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "backend.db_services.redis.redis_modules" | ||
|
||
def ready(self): | ||
post_migrate.connect(init_default_modules, sender=self) |
27 changes: 27 additions & 0 deletions
27
...ui/backend/db_services/redis/redis_modules/migrations/0004_clusterredismoduleassociate.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,27 @@ | ||
# Generated by Django 3.2.25 on 2024-11-07 09:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("redis_modules", "0003_alter_tbredismodulesupport_so_file"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ClusterRedisModuleAssociate", | ||
fields=[ | ||
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("cluster_id", models.IntegerField(default=0, verbose_name="集群ID")), | ||
("module_names", models.JSONField(default=list, verbose_name="module名称列表")), | ||
], | ||
options={ | ||
"verbose_name": "Cluster Redis module关联", | ||
"verbose_name_plural": "Cluster Redis module关联", | ||
"db_table": "tb_cluster_redis_module_associate", | ||
"unique_together": {("cluster_id",)}, | ||
}, | ||
), | ||
] |
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
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
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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
dbm-ui/backend/ticket/builders/redis/redis_toolbox_load_module.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,51 @@ | ||
# -*- 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. | ||
""" | ||
from django.utils.translation import ugettext_lazy as _ | ||
from rest_framework import serializers | ||
|
||
from backend.flow.engine.controller.redis import RedisController | ||
from backend.ticket import builders | ||
from backend.ticket.builders.common.base import DisplayInfoSerializer, SkipToRepresentationMixin | ||
from backend.ticket.builders.redis.base import BaseRedisTicketFlowBuilder, ClusterValidateMixin | ||
from backend.ticket.constants import LoadConfirmType, TicketType | ||
|
||
|
||
class RedisLoadModuleSerializer(SkipToRepresentationMixin, serializers.Serializer): | ||
"""redis集群加载module""" | ||
|
||
class InfoSerializer(DisplayInfoSerializer, ClusterValidateMixin, serializers.Serializer): | ||
|
||
cluster_id = serializers.IntegerField(help_text=_("集群ID")) | ||
db_version = serializers.CharField(help_text=_("版本号")) | ||
load_modules = serializers.ListField( | ||
help_text=_("module类型列表"), | ||
child=serializers.ChoiceField( | ||
help_text=_("module类型"), choices=LoadConfirmType.get_choices(), default=LoadConfirmType.REDIS_BLOOM | ||
), | ||
required=False, | ||
) | ||
|
||
bk_cloud_id = serializers.IntegerField(help_text=_("云区域ID")) | ||
infos = serializers.ListField(help_text=_("批量操作参数列表"), child=InfoSerializer()) | ||
|
||
|
||
class RedisLoadModuleParamBuilder(builders.FlowParamBuilder): | ||
controller = RedisController.redis_cluster_load_modules | ||
|
||
def format_ticket_data(self): | ||
super().format_ticket_data() | ||
|
||
|
||
@builders.BuilderFactory.register(TicketType.REDIS_CLUSTER_LOAD_MODULES, is_apply=True) | ||
class RedisLoadModuleFlowBuilder(BaseRedisTicketFlowBuilder): | ||
serializer = RedisLoadModuleSerializer | ||
inner_flow_builder = RedisLoadModuleParamBuilder | ||
inner_flow_name = _("Redis 存量集群安装module") |
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