-
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.
- Loading branch information
Showing
5 changed files
with
76 additions
and
38 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
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 |
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,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] |
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 was deleted.
Oops, something went wrong.