From b474b557907ab3be2302958e28f88e6e55884099 Mon Sep 17 00:00:00 2001 From: hanshuaikang <1758504262@qq.com> Date: Thu, 31 Aug 2023 15:28:45 +0800 Subject: [PATCH] =?UTF-8?q?minor:=20=E4=BF=AE=E6=94=B9=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_plugins/cmdb_ip_picker/query.py | 4 ++-- pipeline_plugins/cmdb_ip_picker/utils.py | 16 ++++++++++------ .../collections/sites/open/ip_filter_base.py | 6 +++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pipeline_plugins/cmdb_ip_picker/query.py b/pipeline_plugins/cmdb_ip_picker/query.py index f08a732ead..d77aa3f9ff 100644 --- a/pipeline_plugins/cmdb_ip_picker/query.py +++ b/pipeline_plugins/cmdb_ip_picker/query.py @@ -28,7 +28,7 @@ from .constants import ERROR_CODES, NO_ERROR from .utils import ( get_cmdb_topo_tree, - get_ges_agent_status_ipv6, + get_gse_agent_status_ipv6, get_modules_id, get_modules_of_bk_obj, get_objects_of_topo_tree, @@ -143,7 +143,7 @@ def cmdb_search_host(request, bk_biz_id, bk_supplier_account="", bk_supplier_id= bk_agent_id_list.append(bk_agent_id) try: - agent_id_status_map = get_ges_agent_status_ipv6(bk_agent_id_list) + agent_id_status_map = get_gse_agent_status_ipv6(bk_agent_id_list) except Exception as e: result = {"result": False, "code": ERROR_CODES.API_GSE_ERROR, "message": e} return JsonResponse(result) diff --git a/pipeline_plugins/cmdb_ip_picker/utils.py b/pipeline_plugins/cmdb_ip_picker/utils.py index 8d6b4e9f93..89ba5838bc 100644 --- a/pipeline_plugins/cmdb_ip_picker/utils.py +++ b/pipeline_plugins/cmdb_ip_picker/utils.py @@ -328,7 +328,11 @@ def fetch_host_ip_with_property_filter(self): fields.append("bk_host_innerip_v6") host_info = cmdb.get_business_host_topo( - self.username, self.bk_biz_id, self.bk_supplier_account, fields, property_filters=self.property_filters, + self.username, + self.bk_biz_id, + self.bk_supplier_account, + fields, + property_filters=self.property_filters, ) logger.info("[fetch_host_info] cmdb.get_business_host_topo return: {host_info}".format(host_info=host_info)) @@ -702,27 +706,27 @@ def get_bk_cloud_id_for_host(host_info, cloud_key="cloud"): return host_info[cloud_key][0]["id"] -def get_ges_agent_status_ipv6(bk_agent_id_list): +def get_gse_agent_status_ipv6(bk_agent_id_list): if not bk_agent_id_list: return {} ENV_MAP = {"PRODUCT": "prod", "STAGING": "stag"} gse_url = settings.BK_API_URL_TMPL.format(api_name="bk-gse") get_agent_status_url = "{}/{}/api/v2/cluster/list_agent_state".format( - gse_url, ENV_MAP.get(settings.RUN_MODE, "stag") + gse_url, ENV_MAP.get(settings.RUN_MODE, "prod") ) params = {"bk_app_code": settings.APP_CODE, "bk_app_secret": settings.SECRET_KEY, "agent_id_list": bk_agent_id_list} resp = requests.post(url=get_agent_status_url, json=params) if resp.status_code != 200: - raise Exception("[get_ges_agent_status_ipv6] 查询agent状态错误,返回值非200, content = {}".format(resp.content)) + raise Exception("[get_gse_agent_status_ipv6] 查询agent状态错误,返回值非200, content = {}".format(resp.content)) try: data = resp.json() except Exception as e: - raise Exception("[get_ges_agent_status_ipv6] 查询agent状态错误,返回值非Json, err={}".format(e)) + raise Exception("[get_gse_agent_status_ipv6] 查询agent状态错误,返回值非Json, err={}".format(e)) if data["code"] != 0: - raise Exception("[get_ges_agent_status_ipv6] 查询agent状态错误,返回值非code非0") + raise Exception("[get_gse_agent_status_ipv6] 查询agent状态错误,返回值非code非0") agent_id_status_map = {} for item in data.get("data", []): diff --git a/pipeline_plugins/variables/collections/sites/open/ip_filter_base.py b/pipeline_plugins/variables/collections/sites/open/ip_filter_base.py index 9d129b2874..affd51d9c6 100644 --- a/pipeline_plugins/variables/collections/sites/open/ip_filter_base.py +++ b/pipeline_plugins/variables/collections/sites/open/ip_filter_base.py @@ -24,7 +24,7 @@ from gcloud.utils.handlers import handle_api_error from gcloud.utils.ip import IpRegexType, extract_ip_from_ip_str, get_ip_by_regex_type from pipeline_plugins.base.utils.inject import supplier_account_for_business, supplier_id_for_project -from pipeline_plugins.cmdb_ip_picker.utils import get_ges_agent_status_ipv6 +from pipeline_plugins.cmdb_ip_picker.utils import get_gse_agent_status_ipv6 from pipeline_plugins.components.collections.sites.open.cc.base import cc_get_host_by_innerip_with_ipv6 logger = logging.getLogger("root") @@ -67,7 +67,7 @@ def match_ges_v2(self, gse_agent_status, username, bk_biz_id, bk_supplier_id, or remote_hosts[bk_agent_id] = remote_host_value # 去查询agent状态 - agent_map = get_ges_agent_status_ipv6(bk_agent_id_list=list(remote_hosts.keys())) + agent_map = get_gse_agent_status_ipv6(bk_agent_id_list=list(remote_hosts.keys())) agent_online_ip_list = [] # 在线的ip的列表 agent_offline_ip_list = [] # 不在线的ip的列表 @@ -179,7 +179,7 @@ def get_match_ip(self): bk_agent_id_list.append(bk_agent_id) try: - agent_id_status_map = get_ges_agent_status_ipv6(bk_agent_id_list) + agent_id_status_map = get_gse_agent_status_ipv6(bk_agent_id_list) except Exception as e: raise ApiRequestError(f"ERROR:{e}")