From 1eb493b1118b3b384811d907f6eb465cec5f3580 Mon Sep 17 00:00:00 2001 From: rainzm Date: Thu, 22 Apr 2021 17:05:49 +0800 Subject: [PATCH] fix(region): allow owner to operate snapshotpolicy cache --- pkg/compute/models/snapshotpolicycache.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/compute/models/snapshotpolicycache.go b/pkg/compute/models/snapshotpolicycache.go index 3e340d5ab7..68a688671e 100644 --- a/pkg/compute/models/snapshotpolicycache.go +++ b/pkg/compute/models/snapshotpolicycache.go @@ -21,6 +21,7 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/sqlchemy" @@ -32,6 +33,7 @@ import ( "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -539,3 +541,16 @@ func (manager *SSnapshotPolicyCacheManager) ListItemExportKeys(ctx context.Conte return q, nil } + +func (manager *SSnapshotPolicyCacheManager) ResourceScope() rbacutils.TRbacScope { + return rbacutils.ScopeProject +} + +func (spc *SSnapshotPolicyCache) GetOwnerId() mcclient.IIdentityProvider { + p, err := spc.GetSnapshotPolicy() + if err != nil { + log.Errorf("unable to get snapshotpolicy of snapshotpolicycache %s: %v", spc.GetId(), err) + return nil + } + return p.GetOwnerId() +}