From cedfd6410ea4954d297745f37f1993598b37a6b2 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Fri, 14 Aug 2020 17:30:49 +0800 Subject: [PATCH] fix: init wire domain_id for local vpc (#7566) Co-authored-by: Qiu Jian --- pkg/compute/models/vpcs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index 0c5a52604a..dcb3ce7070 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -1062,6 +1062,11 @@ func (self *SVpc) initWire(ctx context.Context, zone *SZone) (*SWire, error) { wire.ZoneId = zone.Id wire.IsEmulated = true wire.Name = fmt.Sprintf("vpc-%s", self.Name) + + wire.DomainId = self.DomainId + wire.IsPublic = self.IsPublic + wire.PublicScope = self.PublicScope + wire.SetModelManager(WireManager, wire) err := WireManager.TableSpec().Insert(ctx, wire) if err != nil { @@ -1216,7 +1221,7 @@ func (manager *SVpcManager) ListItemExportKeys(ctx context.Context, } func (vpc *SVpc) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicDomainInput) (jsonutils.JSONObject, error) { - if rbacutils.String2ScopeDefault(input.Scope, rbacutils.ScopeSystem) != rbacutils.ScopeSystem { + if vpc.Id == api.DEFAULT_VPC_ID && rbacutils.String2ScopeDefault(input.Scope, rbacutils.ScopeSystem) != rbacutils.ScopeSystem { return nil, httperrors.NewForbiddenError("For default vpc, only system level sharing can be set") } _, err := vpc.SEnabledStatusInfrasResourceBase.PerformPublic(ctx, userCred, query, input)