Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 节点管理插件支持安装通道 #7397 #7403

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: stable
rev: 22.8.0
hooks:
- id: black
language_version: python3.6
Expand Down
3 changes: 3 additions & 0 deletions api/collections/nodeman.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ def get_rsa_public_key(self, executor):
"names": ["DEFAULT"],
},
)

def install_channel(self):
return self._request(method="get", url=_get_nodeman_api_v2("install_channel"), data={})
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def execute(self, data, parent_data):
all_hosts, row_host_params_list = [], []
for host in nodeman_hosts:
bk_cloud_id = host["nodeman_bk_cloud_id"]
install_channel_id = host.get("nodeman_bk_install_channel")
use_inner_ip = True if host.get("inner_ip") else False
# use_inner_ip 判定用户输入的的是ipv4还是ipv6
inner_ip_list = self.get_ip_list(
Expand Down Expand Up @@ -135,7 +136,8 @@ def execute(self, data, parent_data):
"os_type": host["os_type"],
"is_manual": False,
}

if install_channel_id:
base_params["install_channel_id"] = install_channel_id
# 支持表格中一行多ip操作, 拼装表格内的inner_ip参数
for index, inner_ip in enumerate(inner_ip_list):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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
http://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 pipeline.component_framework.component import Component

from gcloud.conf import settings

__group_name__ = _("节点管理(Nodeman)")

from pipeline_plugins.components.collections.sites.open.nodeman.create_task.v4_0 import (
NodemanCreateTaskService as NodemanCreateTaskV4Service,
)

VERSION = "v6.0"


class NodemanCreateTaskService(NodemanCreateTaskV4Service):
pass


class NodemanCreateTaskComponent(Component):
name = _("新建任务")
code = "nodeman_create_task"
bound_service = NodemanCreateTaskService
form = "%scomponents/atoms/nodeman/create_task/v6_0.js" % settings.STATIC_URL
version = VERSION
desc = _("v6.0版本 支持选择安装通道 \n" "注意:bk_apigateway版本>=1.12.17")
27 changes: 26 additions & 1 deletion pipeline_plugins/components/query/sites/open/nodeman.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import logging
import os

from django.conf.urls import url
from django.http import JsonResponse
from django.utils.translation import ugettext_lazy as _
from django.conf.urls import url

from api.collections.nodeman import BKNodeManClient
from gcloud.iam_auth.utils import check_and_raise_raw_auth_fail_exception
Expand Down Expand Up @@ -112,10 +112,35 @@ def nodeman_is_support_tjj(request):
return JsonResponse({"result": True, "message": "success", "code": 0, "data": BKAPP_NODEMAN_SUPPORT_TJJ})


def nodeman_get_install_channel(request, cloud_id: int):
client = BKNodeManClient(username=request.user.username)
install_channel_result = client.install_channel()

if not install_channel_result["result"]:
message = handle_api_error(_("节点管理(NODEMAN)"), "nodeman.install_channel", {}, install_channel_result)
logger.error(message)
check_and_raise_raw_auth_fail_exception(install_channel_result, message)
return JsonResponse(
{
"result": install_channel_result["result"],
"code": install_channel_result.get("code", "-1"),
"message": message,
}
)

data = install_channel_result["data"]
result = [
{"text": channel["name"], "value": channel["id"]} for channel in data if channel["bk_cloud_id"] == int(cloud_id)
]
install_channel_result["data"] = result
return JsonResponse(install_channel_result)


nodeman_urlpatterns = [
url(r"^nodeman_get_cloud_area/$", nodeman_get_cloud_area),
url(r"^nodeman_get_ap_list/$", nodeman_get_ap_list),
url(r"^nodeman_is_support_tjj/$", nodeman_is_support_tjj),
url(r"^nodeman_get_plugin_list/(?P<category>\w+)/$", nodeman_get_plugin_list),
url(r"^nodeman_get_plugin_version/(?P<plugin>\w+)/(?P<os_type>\w+)/$", nodeman_get_plugin_version),
url(r"^nodeman_get_install_channel/(?P<cloud_id>\w+)/$", nodeman_get_install_channel),
]
Loading
Loading