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(backend): 非托管业务主机模型增加dbm_meta自定义字段 #2960 #2963

Merged
merged 1 commit into from
Jan 8, 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
7 changes: 6 additions & 1 deletion dbm-ui/backend/flow/utils/cc_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ def batch_update_host(host_info_list: List[Dict[str, Any]], need_monitor: bool):
def update_host_properties(
self, bk_host_ids: List[int], need_monitor: bool, dbm_meta=None, update_operator: bool = True
):
"""批量更新主机属性"""
"""
批量更新主机属性
"""
# 给业务主机模型增加dbm_meta自定义字段
Services.init_cc_dbm_meta(self.bk_biz_id)

# 如果传递了dbm_meta信息和选择不更新维护人,则无需查询machine表,可以直接构造主机属性
if dbm_meta is not None and not update_operator:
dbm_meta = json.dumps(dbm_meta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TestHandler:
@patch("backend.db_meta.api.machine.apis.CCApi", CCApiMock())
@patch("backend.db_meta.models.app.CCApi", CCApiMock())
@patch("backend.flow.utils.cc_manage.CCApi", CCApiMock())
@patch("backend.dbm_init.services.CCApi", CCApiMock())
@patch("backend.flow.utils.cc_manage.ResourceQueryHelper", ResourceQueryHelperMock())
def test_create_success(self, init_db_module, create_city):
cluster_name = "test"
Expand Down
11 changes: 11 additions & 0 deletions dbm-ui/backend/tests/mock_data/components/cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
MOCK_SEARCH_SET_RETURN = {"info": [{"bk_set_id": constant.BK_SET_ID, "bk_set_name": "mock集群"}], "count": 1}
MOCK_SEARCH_MODULE_RETURN = {"info": [{"bk_module_id": constant.DB_MODULE_ID, "bk_biz_name": "mock模块"}], "count": 1}
MOCK_LIST_SERVICE_INSTANCE_DETAIL_RETURN = {"info": []}
MOCK_SEARCH_OBJECT_ATTRIBUTE_RETURN = []

MOCK_SEARCH_BUSINESS_WITH_MULTI_BIZ_RETURN = {
"info": [
Expand Down Expand Up @@ -158,6 +159,7 @@ class CCApiMock(object):
find_host_biz_relations_return = copy.deepcopy(MOCK_FIND_HOST_BIZ_RELATIONS_RETURN)
get_biz_internal_module_return = copy.deepcopy(MOCK_GET_BIZ_INTERNAL_MODULE_RETURN)
list_service_instance_detail_return = copy.deepcopy(MOCK_LIST_SERVICE_INSTANCE_DETAIL_RETURN)
search_object_attribute_return = copy.deepcopy(MOCK_SEARCH_OBJECT_ATTRIBUTE_RETURN)

def __init__(
self,
Expand All @@ -167,6 +169,7 @@ def __init__(
search_module_return=None,
find_host_biz_relations_return=None,
list_service_instance_detail_return=None,
search_object_attribute_return=None,
):
# 提供接口默认返回值,可根据不同的需求进行构造
self.search_business_return = search_business_return or self.search_business_return
Expand All @@ -177,6 +180,7 @@ def __init__(
self.list_service_instance_detail_return = (
list_service_instance_detail_return or self.list_service_instance_detail_return
)
self.search_object_attribute_return = search_object_attribute_return or self.search_object_attribute_return

def search_business(self, *args, **kwargs):
return self.search_business_return
Expand All @@ -202,6 +206,9 @@ def list_hosts_without_biz(self, *args, **kwargs):
def list_biz_hosts(self, *args, **kwargs):
return self.list_hosts_without_biz_return

def search_object_attribute(self, *args, **kwargs):
return self.search_object_attribute_return

@staticmethod
def batch_update_host(*args, **kwargs):
if kwargs.get("raw"):
Expand All @@ -226,6 +233,10 @@ def create_module(*args, **kwargs):
def transfer_host_module(*args, **kwargs):
return {}

@staticmethod
def create_biz_custom_field(*args, **kwargs):
return {}

@staticmethod
def add_label_for_service_instance(*args, **kwargs):
return {}
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/db-resource/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.0.1-alpha.81
appVersion: 0.0.1-alpha.82
description: A Helm chart for Kubernetes
name: db-resource
type: application
Expand Down
Loading