Skip to content

Commit

Permalink
Merge branch 'feature_ip_selector_master' of https://github.com/Tence…
Browse files Browse the repository at this point in the history
…ntBlueKing/bk-sops into hotfix_release_master

# Conflicts:
#	gcloud/tests/utils/cmdb/test_business_host_topo.py
#	gcloud/utils/cmdb.py
#	pipeline_plugins/cmdb_ip_picker/query.py
  • Loading branch information
guohelu committed Oct 29, 2024
2 parents f48cdeb + c770f05 commit 387fd50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 43 deletions.
40 changes: 4 additions & 36 deletions gcloud/tests/utils/cmdb/test_business_host_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def setUp(self):
},
],
},
],
"count": 2,
]
},
}
self.get_business_host_topo_expect_return = [
Expand Down Expand Up @@ -143,37 +142,6 @@ def setUp(self):
],
},
]
self.get_filter_business_host_topo_expect_return = (
[
{
"host": {
"bk_cloud_id": 0,
"bk_host_id": 1,
"bk_host_innerip": "127.0.0.1",
"bk_mac": "",
"bk_os_type": None,
},
"set": [{"bk_set_id": 11, "bk_set_name": "set1"}],
"module": [{"bk_module_id": 56, "bk_module_name": "m1"}],
},
{
"host": {
"bk_cloud_id": 0,
"bk_host_id": 3,
"bk_host_innerip": "127.0.0.3",
"bk_mac": "",
"bk_os_type": None,
},
"set": [{"bk_set_id": 10, "bk_set_name": "空闲机池"}, {"bk_set_id": 11, "bk_set_name": "set1"}],
"module": [
{"bk_module_id": 54, "bk_module_name": "空闲机"},
{"bk_module_id": 55, "bk_module_name": "空闲机1"},
{"bk_module_id": 56, "bk_module_name": "m1"},
],
},
],
2,
)

def tearDown(self):
self.get_client_by_user_patcher.stop()
Expand Down Expand Up @@ -234,7 +202,7 @@ def test__get_contains_with_ip_list(self):
ip_str=self.ip_str,
)

self.assertEqual(hosts_topo, self.get_filter_business_host_topo_expect_return)
self.assertEqual(hosts_topo, self.get_business_host_topo_expect_return)
self.mock_client.cc.list_biz_hosts_topo.assert_called_once_with(
{
"bk_biz_id": self.bk_biz_id,
Expand All @@ -260,7 +228,7 @@ def test__get_many_contains_with_ip_list(self):
ip_str=self.ip_strs,
)

self.assertEqual(hosts_topo, self.get_filter_business_host_topo_expect_return)
self.assertEqual(hosts_topo, self.get_business_host_topo_expect_return)
self.mock_client.cc.list_biz_hosts_topo.assert_called_once_with(
{
"bk_biz_id": self.bk_biz_id,
Expand All @@ -283,7 +251,7 @@ def test__get_with_page_list(self):
self.username, self.bk_biz_id, self.supplier_account, self.host_fields, start=0, limit=10
)

self.assertEqual(hosts_topo, self.get_filter_business_host_topo_expect_return)
self.assertEqual(hosts_topo, self.get_business_host_topo_expect_return)
self.mock_client.cc.list_biz_hosts_topo.assert_called_once_with(
{
"bk_biz_id": self.bk_biz_id,
Expand Down
2 changes: 1 addition & 1 deletion gcloud/utils/cmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def get_filter_business_host_topo(username, bk_biz_id, supplier_account, host_fi

host_info_list.append(host_info)

return host_info_list, data["data"]["count"]
return host_info_list


def get_business_host(username, bk_biz_id, supplier_account, host_fields, ip_list=None, bk_cloud_id=None):
Expand Down
9 changes: 3 additions & 6 deletions pipeline_plugins/cmdb_ip_picker/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def cmdb_search_host(request, bk_biz_id, bk_supplier_account="", bk_supplier_id=
message = handle_api_error(_("配置平台(CMDB)"), "cc.search_cloud_area", {}, cloud_area_result)
result = {"result": False, "code": ERROR_CODES.API_GSE_ERROR, "message": message}
return JsonResponse(result)
count = None

if start and limit:
raw_host_info_list, count = cmdb.get_filter_business_host_topo(
raw_host_info_list = cmdb.get_filter_business_host_topo(
request.user.username, bk_biz_id, bk_supplier_account, fields, int(start), int(limit), ip_str
)
else:
Expand Down Expand Up @@ -219,10 +219,7 @@ def cmdb_search_host(request, bk_biz_id, bk_supplier_account="", bk_supplier_id=
host_lock_status = host_lock_status_data.get(host_detail["bk_host_id"])
if host_lock_status is not None:
host_detail["bk_host_lock_status"] = host_lock_status
if count:
result = {"result": True, "code": NO_ERROR, "data": {"data": data, "count": count}}
else:
result = {"result": True, "code": NO_ERROR, "data": data}
result = {"result": True, "code": NO_ERROR, "data": data}
return JsonResponse(result)


Expand Down

0 comments on commit 387fd50

Please sign in to comment.