diff --git a/configmanage/server/internal/confignode.go b/configmanage/server/internal/confignode.go index 366ff6983cf88254bdad88411323ba02350738f1..68c56b708b5580dc77cfd5df3c0cffda27fc93aa 100644 --- a/configmanage/server/internal/confignode.go +++ b/configmanage/server/internal/confignode.go @@ -19,6 +19,15 @@ func GetConfigNodesByUUID(uuid string) ([]string, error) { return nodes, err } +func IsExistNode(uuid string) bool { + var cns []ConfigNode + err := db.MySQL().Model(&ConfigNode{}).Where("node_id=?", uuid).Find(&cns).Error + if err != nil || len(cns) == 0 { + return false + } + return true +} + type ConfigBatch struct { ID int `gorm:"primary_key;AUTO_INCREMENT"` ConfigInfo ConfigInfo `gorm:"Foreignkey:ConfigInfoUUID"` diff --git a/configmanage/server/main.go b/configmanage/server/main.go index 815c6a17d1d889f588040e7a2d6f478e54806d5f..01bb884cc5b58d49ff99e69b1350b716e55ad29b 100644 --- a/configmanage/server/main.go +++ b/configmanage/server/main.go @@ -50,6 +50,7 @@ func main() { } global.GlobalClient = client.DefaultClient(global.Init(config.Config().ConfigPlugin)) + service.GetTags() service.AddExtentions() service.AddPermission() diff --git a/configmanage/server/service/tags.go b/configmanage/server/service/tags.go new file mode 100644 index 0000000000000000000000000000000000000000..8f4a28e899cb97ac65240dc8e140b7d84e256915 --- /dev/null +++ b/configmanage/server/service/tags.go @@ -0,0 +1,33 @@ +package service + +import ( + "gitee.com/openeuler/PilotGo/sdk/common" + "openeuler.org/PilotGo/configmanage-plugin/global" + "openeuler.org/PilotGo/configmanage-plugin/internal" +) + +func GetTags() { + tag_cb := func(uuids []string) []common.Tag { + var tags []common.Tag + for _, uuid := range uuids { + ok := internal.IsExistNode(uuid) + if ok { + tag := common.Tag{ + UUID: uuid, + Type: common.TypeOk, + Data: "configmanage", + } + tags = append(tags, tag) + } else { + tag := common.Tag{ + UUID: uuid, + Type: common.TypeError, + Data: "", + } + tags = append(tags, tag) + } + } + return tags + } + global.GlobalClient.OnGetTags(tag_cb) +}