refact(region): resource tags

This commit is contained in:
lvyangyang
2020-12-26 16:00:26 +08:00
parent 35bc01687d
commit 68cf1eaea5
275 changed files with 1103 additions and 1004 deletions
+7 -4
View File
@@ -39,10 +39,11 @@ import (
)
const (
SYSTEM_ADMIN_PREFIX = "__sys_"
SYS_TAG_PREFIX = "__"
CLOUD_TAG_PREFIX = "ext:"
USER_TAG_PREFIX = "user:"
SYSTEM_ADMIN_PREFIX = "__sys_"
SYS_TAG_PREFIX = "__"
CLOUD_TAG_PREFIX = "ext:"
USER_TAG_PREFIX = "user:"
SYS_CLOUD_TAG_PREFIX = "sys:"
// TAG_DELETE_RANGE_USER = "user"
// TAG_DELETE_RANGE_CLOUD = CLOUD_TAG_PREFIX // "cloud"
@@ -568,6 +569,8 @@ func (manager *SMetadataManager) SetAll(ctx context.Context, obj IModel, store m
q = q.Like("key", USER_TAG_PREFIX+"%")
case CLOUD_TAG_PREFIX:
q = q.Like("key", CLOUD_TAG_PREFIX+"%")
case SYS_CLOUD_TAG_PREFIX:
q = q.Like("key", SYS_CLOUD_TAG_PREFIX+"%")
}
q = q.Filter(sqlchemy.NOT(sqlchemy.In(q.Field("key"), keys)))
if err := FetchModelObjects(manager, q, &records); err != nil {
+8
View File
@@ -293,6 +293,14 @@ func (model *SStandaloneAnonResourceBase) SetCloudMetadataAll(ctx context.Contex
return nil
}
func (model *SStandaloneAnonResourceBase) SetSysCloudMetadataAll(ctx context.Context, dictstore map[string]interface{}, userCred mcclient.TokenCredential) error {
err := Metadata.SetAll(ctx, model, dictstore, userCred, SYS_CLOUD_TAG_PREFIX)
if err != nil {
return errors.Wrap(err, "SetAll")
}
return nil
}
func (model *SStandaloneAnonResourceBase) RemoveMetadata(ctx context.Context, key string, userCred mcclient.TokenCredential) error {
err := Metadata.SetValue(ctx, model, key, "", userCred)
if err != nil {