Skip to content

Commit

Permalink
Merge pull request #6137 from wcy00000000000000/v3.10.x-bugfix
Browse files Browse the repository at this point in the history
设置不可编辑字段+IPv6字段+CPU架构字段不可用于主机自动应用
  • Loading branch information
breezelxp authored May 16, 2022
2 parents eec1c02 + d318d98 commit 05ea6f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/common/metadata/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scene_server/topo_server/service/object_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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
Expand Down

0 comments on commit 05ea6f9

Please sign in to comment.