From d318d98e057e381e08d70dbb084c2444180fed81 Mon Sep 17 00:00:00 2001 From: wcy00000000000000 <2269766985@qq.com> Date: Thu, 12 May 2022 21:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8D=E5=8F=AF=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=AD=97=E6=AE=B5+IPv6=E5=AD=97=E6=AE=B5+CPU=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=8F=AF=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E4=B8=BB=E6=9C=BA=E8=87=AA=E5=8A=A8=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/metadata/attribute.go | 12 ++++++++++-- .../topo_server/service/object_attribute.go | 2 +- .../coreservice/core/hostapplyrule/plan.go | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/metadata/attribute.go b/src/common/metadata/attribute.go index 6b6ab5bb2a..3a038ee6f4 100644 --- a/src/common/metadata/attribute.go +++ b/src/common/metadata/attribute.go @@ -1208,11 +1208,19 @@ var HostApplyFieldMap = map[string]bool{ common.BKCloudInstIDField: false, common.BKCloudHostStatusField: false, common.BKCloudVendor: false, + common.BKHostInnerIPv6Field: false, + common.BKHostOuterIPv6Field: false, + common.BKAgentIDField: false, + "bk_cpu_architecture": false, } // CheckAllowHostApplyOnField 检查字段是否能用于主机属性自动应用 -func CheckAllowHostApplyOnField(field string) bool { - if allow, exist := HostApplyFieldMap[field]; exist == true { +func CheckAllowHostApplyOnField(field *Attribute) bool { + if !field.IsEditable { + return false + } + + if allow, exist := HostApplyFieldMap[field.PropertyID]; exist == true { return allow } return true diff --git a/src/scene_server/topo_server/service/object_attribute.go b/src/scene_server/topo_server/service/object_attribute.go index 2a06ff0777..e75292d221 100644 --- a/src/scene_server/topo_server/service/object_attribute.go +++ b/src/scene_server/topo_server/service/object_attribute.go @@ -341,7 +341,7 @@ func (s *Service) ListHostModelAttribute(ctx *rest.Contexts) { hostAttributes := make([]metadata.HostObjAttDes, 0) for _, item := range result.Info { - hostApplyEnabled := metadata.CheckAllowHostApplyOnField(item.PropertyID) + hostApplyEnabled := metadata.CheckAllowHostApplyOnField(&item) hostAttribute := metadata.HostObjAttDes{ ObjAttDes: metadata.ObjAttDes{ Attribute: item, diff --git a/src/source_controller/coreservice/core/hostapplyrule/plan.go b/src/source_controller/coreservice/core/hostapplyrule/plan.go index 3f285ec2ff..26fc91149d 100644 --- a/src/source_controller/coreservice/core/hostapplyrule/plan.go +++ b/src/source_controller/coreservice/core/hostapplyrule/plan.go @@ -237,7 +237,7 @@ func preCheckRules(targetRules []metadata.HostApplyRule, attributeID int64, attr blog.Infof("attribute id field not exist, attributeID: %s, rid: %s", attributeID, rid) return metadata.Attribute{}, false } - if metadata.CheckAllowHostApplyOnField(attribute.PropertyID) == false { + if !metadata.CheckAllowHostApplyOnField(&attribute) { return metadata.Attribute{}, false } return attribute, true