Skip to content

Commit

Permalink
minor: 修改拼写问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang authored and ZhuoZhuoCrayon committed Sep 4, 2023
1 parent a2ad300 commit b474b55
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pipeline_plugins/cmdb_ip_picker/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions pipeline_plugins/cmdb_ip_picker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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", []):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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的列表
Expand Down Expand Up @@ -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}")

Expand Down

0 comments on commit b474b55

Please sign in to comment.