-
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.
feat(backend): 镜像文件编译参数改造 & riak开发 #1688
- Loading branch information
Showing
25 changed files
with
317 additions
and
94 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- 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 gettext as _ | ||
|
||
from backend.db_meta.api.cluster.base.graph import Graphic, LineLabel | ||
from backend.db_meta.enums import InstanceRole | ||
from backend.db_meta.models import Cluster | ||
|
||
|
||
def scan_cluster(cluster: Cluster) -> Graphic: | ||
""" | ||
绘制kafka的拓扑结构图 | ||
""" | ||
graph = Graphic(node_id=Graphic.generate_graphic_id(cluster)) | ||
graph.add_instance_nodes(cluster=cluster, roles=InstanceRole.RIAK_NODE, group_name=_("Riak 节点")) | ||
return graph |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- 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. | ||
""" |
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,12 @@ | ||
# -*- 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. | ||
""" | ||
|
||
RESOURCE_TAG = "db_services/resources/riak" |
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,34 @@ | ||
# -*- 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 backend.db_meta.api.cluster.riak.detail import scan_cluster | ||
from backend.db_meta.enums import InstanceRole | ||
from backend.db_meta.enums.cluster_type import ClusterType | ||
from backend.db_meta.models import Cluster | ||
from backend.db_services.bigdata.resources.query import BigDataBaseListRetrieveResource | ||
|
||
|
||
class RiakListRetrieveResource(BigDataBaseListRetrieveResource): | ||
|
||
cluster_types = [ClusterType.Riak] | ||
instance_roles = [InstanceRole.RIAK_NODE] | ||
fields = [ | ||
*BigDataBaseListRetrieveResource.fields, | ||
{"name": _("riak节点"), "key": "riak_node"}, | ||
] | ||
|
||
@classmethod | ||
def get_topo_graph(cls, bk_biz_id: int, cluster_id: int) -> dict: | ||
cluster = Cluster.objects.get(bk_biz_id=bk_biz_id, id=cluster_id) | ||
graph = scan_cluster(cluster).to_dict() | ||
return graph |
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,19 @@ | ||
# -*- 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 rest_framework.routers import DefaultRouter | ||
|
||
from backend.db_services.bigdata.riak.views import RiakClusterViewSet | ||
|
||
router = DefaultRouter(trailing_slash=True) | ||
router.register(r"riak_resources", RiakClusterViewSet, basename="riak_resources") | ||
|
||
urlpatterns = router.urls |
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,75 @@ | ||
# -*- 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.decorators import method_decorator | ||
from django.utils.translation import ugettext as _ | ||
from rest_framework import status | ||
|
||
from backend.bk_web.swagger import common_swagger_auto_schema | ||
from backend.db_services.bigdata.kafka import constants | ||
from backend.db_services.bigdata.resources import yasg_slz | ||
from backend.db_services.bigdata.resources.views import ResourceViewSet | ||
from backend.db_services.bigdata.riak.query import RiakListRetrieveResource | ||
from backend.db_services.dbbase.resources import serializers | ||
|
||
|
||
@method_decorator( | ||
name="list", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取集群列表"), | ||
query_serializer=serializers.ListResourceSLZ(), | ||
responses={status.HTTP_200_OK: yasg_slz.PaginatedResourceSLZ()}, | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
@method_decorator( | ||
name="retrieve", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取集群详情"), | ||
responses={status.HTTP_200_OK: yasg_slz.ResourceSLZ()}, | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
@method_decorator( | ||
name="list_instances", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取实例列表"), | ||
query_serializer=serializers.ListInstancesSerializer(), | ||
responses={status.HTTP_200_OK: yasg_slz.PaginatedResourceSLZ()}, | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
@method_decorator( | ||
name="retrieve_instance", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取实例详情"), | ||
query_serializer=serializers.RetrieveInstancesSerializer(), | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
@method_decorator( | ||
name="get_table_fields", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取查询返回字段"), | ||
responses={status.HTTP_200_OK: yasg_slz.ResourceFieldSLZ()}, | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
@method_decorator( | ||
name="get_topo_graph", | ||
decorator=common_swagger_auto_schema( | ||
operation_summary=_("获取集群拓扑"), | ||
responses={status.HTTP_200_OK: yasg_slz.ResourceTopoGraphSLZ()}, | ||
tags=[constants.RESOURCE_TAG], | ||
), | ||
) | ||
class RiakClusterViewSet(ResourceViewSet): | ||
query_class = RiakListRetrieveResource | ||
query_serializer_class = serializers.ListResourceSLZ |
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
Oops, something went wrong.