From 9f3b11bf492c7b9aa171febec28d2a9b53082a88 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Mon, 12 Aug 2019 10:17:05 +0800 Subject: [PATCH] fix: when turning off non-default-domain-projects, network public scope should swtich to system scope --- pkg/compute/models/networks.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index fc6748eb0e..e70e67d6a6 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -34,6 +34,7 @@ import ( "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" @@ -678,7 +679,11 @@ func (manager *SNetworkManager) newFromCloudNetwork(ctx context.Context, userCre net.GuestGateway = extNet.GetGateway() net.ServerType = extNet.GetServerType() net.IsPublic = extNet.GetIsPublic() - net.PublicScope = string(extNet.GetPublicScope()) + extScope := extNet.GetPublicScope() + if extScope == rbacutils.ScopeDomain && !consts.GetNonDefaultDomainProjects() { + extScope = rbacutils.ScopeSystem + } + net.PublicScope = string(extScope) net.AllocTimoutSeconds = extNet.GetAllocTimeoutSeconds()