Skip to content

Commit

Permalink
fix(backend): stage
Browse files Browse the repository at this point in the history
  • Loading branch information
xfwduke committed Dec 10, 2024
1 parent 1accc65 commit da1fc5c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 38 deletions.
11 changes: 11 additions & 0 deletions dbm-ui/backend/db_proxy/reverse_api/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- 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 .views import CommonReverseApiView
55 changes: 55 additions & 0 deletions dbm-ui/backend/db_proxy/reverse_api/common/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- 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 typing import List

from django.http import JsonResponse
from django.utils.translation import ugettext_lazy as _

from backend.bk_web.swagger import common_swagger_auto_schema
from backend.db_proxy.constants import ExtensionType
from backend.db_proxy.models import DBExtension
from backend.db_proxy.reverse_api.base_reverse_api_view import BaseReverseApiView
from backend.db_proxy.reverse_api.decorators import reverse_api

logger = logging.getLogger("root")


class CommonReverseApiView(BaseReverseApiView):
@common_swagger_auto_schema(operation_summary=_("获取NGINX IP"))
@reverse_api(url_path="list_nginx_ips")
def list_nginx_ips(self, request, *args, **kwargs):
"""
返回特定云区域的 NGINX IP 列表
param: bk_cloud_id: int
return: ["ip1", "ip2", ...]
"""
bk_cloud_id, _, _ = self.get_api_params()
logger.info(f"bk_cloud_id: {bk_cloud_id}")

return JsonResponse(
{
"result": True,
"code": 0,
"data": self._list_nginx_ips(bk_cloud_id=bk_cloud_id),
"message": "",
"errors": None,
}
)

@staticmethod
def _list_nginx_ips(bk_cloud_id: int) -> List[str]:
nginx = DBExtension.get_extension_in_cloud(
bk_cloud_id=bk_cloud_id,
extension_type=ExtensionType.NGINX.value
)
logger.info(f"nginx: {nginx}")
return [n.details["ip"] for n in nginx]
8 changes: 8 additions & 0 deletions dbm-ui/backend/db_proxy/reverse_api/mysql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
specific language governing permissions and limitations under the License.
"""
import logging
from typing import List, Optional

from django.db.models import Q
from django.http import JsonResponse
Expand Down Expand Up @@ -55,3 +56,10 @@ def list_instance_info(self, request, *args, **kwargs):
"errors": None,
}
)

def _list_storageinstance_info(self, ip: str, port_list: Optional[List[int]] = None) -> List:
pass

def _list_proxyinstance_info(self, ip: str, port_list: Optional[List[int]] = None) -> List:

pass
4 changes: 2 additions & 2 deletions dbm-ui/backend/db_proxy/reverse_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from rest_framework.routers import DefaultRouter

from backend.db_proxy.reverse_api.mysql import MySQLReverseApiView
from backend.db_proxy.reverse_api.views import CommonReverseApiView
from backend.db_proxy.reverse_api.common import CommonReverseApiView

routers = DefaultRouter(trailing_slash=True)
routers.register("mysql", MySQLReverseApiView, basename="")
routers.register("", CommonReverseApiView, basename="")
routers.register("common", CommonReverseApiView, basename="")

urlpatterns = routers.urls
36 changes: 0 additions & 36 deletions dbm-ui/backend/db_proxy/reverse_api/views.py

This file was deleted.

0 comments on commit da1fc5c

Please sign in to comment.