mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix: sync network publicScope
This commit is contained in:
@@ -104,7 +104,7 @@ func (model *SSharableVirtualResourceBase) AllowPerformPublic(ctx context.Contex
|
||||
|
||||
func (model *SSharableVirtualResourceBase) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if !model.IsPublic {
|
||||
targetScopeStr, _ := query.GetString("scope")
|
||||
targetScopeStr, _ := data.GetString("scope")
|
||||
targetScope := rbacutils.String2ScopeDefault(targetScopeStr, rbacutils.ScopeSystem)
|
||||
allowScope := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), model.GetModelManager().KeywordPlural(), policy.PolicyActionPerform, "public")
|
||||
if targetScope.HigherThan(allowScope) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type ICloudResource interface {
|
||||
@@ -420,6 +421,7 @@ type ICloudNetwork interface {
|
||||
GetGateway() string
|
||||
GetServerType() string
|
||||
GetIsPublic() bool
|
||||
GetPublicScope() rbacutils.TRbacScope
|
||||
|
||||
Delete() error
|
||||
|
||||
|
||||
@@ -572,6 +572,7 @@ func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclien
|
||||
self.GuestGateway = extNet.GetGateway()
|
||||
self.ServerType = extNet.GetServerType()
|
||||
self.IsPublic = extNet.GetIsPublic()
|
||||
self.PublicScope = string(extNet.GetPublicScope())
|
||||
|
||||
self.AllocTimoutSeconds = extNet.GetAllocTimeoutSeconds()
|
||||
|
||||
@@ -606,6 +607,7 @@ 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())
|
||||
|
||||
net.AllocTimoutSeconds = extNet.GetAllocTimeoutSeconds()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ func init() {
|
||||
Networks = NewComputeManager("network", "networks",
|
||||
[]string{"ID", "Name", "Guest_ip_start", "zone", "zone_id",
|
||||
"Guest_ip_end", "Guest_ip_mask",
|
||||
"wire_id", "wire", "is_public", "exit", "Ports",
|
||||
"wire_id", "wire", "is_public", "public_scope", "exit", "Ports",
|
||||
"vnics", "guest_gateway",
|
||||
"group_vnics", "bm_vnics", "reserve_vnics", "lb_vnics",
|
||||
"server_type", "Status"},
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
// {"AvailableIpAddressCount":4091,"CidrBlock":"172.31.32.0/20","CreationTime":"2017-03-19T13:37:44Z","Description":"System created default virtual switch.","IsDefault":true,"Status":"Available","VSwitchId":"vsw-j6c3gig5ub4fmi2veyrus","VSwitchName":"","VpcId":"vpc-j6c86z3sh8ufhgsxwme0q","ZoneId":"cn-hongkong-b"}
|
||||
@@ -137,6 +138,10 @@ func (self *SVSwitch) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SRegion) createVSwitch(zoneId string, vpcId string, name string, cidr string, desc string) (string, error) {
|
||||
params := make(map[string]string)
|
||||
params["ZoneId"] = zoneId
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
@@ -123,6 +124,10 @@ func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) Delete() error {
|
||||
return self.wire.zone.region.deleteNetwork(self.NetworkId)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SClassicNetwork struct {
|
||||
@@ -105,6 +106,10 @@ func (self *SClassicNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SClassicNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SClassicNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
@@ -111,6 +112,10 @@ func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/huawei/client/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -134,6 +135,10 @@ func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) Delete() error {
|
||||
return self.wire.region.deleteNetwork(self.VpcID, self.GetId())
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type AllocationPool struct {
|
||||
@@ -142,6 +143,10 @@ func (network *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (network *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (network *SNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
@@ -143,6 +144,10 @@ func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
// https://docs.ucloud.cn/api/vpc2.0-api/describe_subnet
|
||||
@@ -123,6 +124,10 @@ func (self *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (self *SNetwork) Delete() error {
|
||||
return self.wire.region.DeleteNetwork(self.GetId())
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SNetwork struct {
|
||||
@@ -192,6 +193,10 @@ func (network *SNetwork) GetIsPublic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeDomain
|
||||
}
|
||||
|
||||
func (network *SNetwork) GetServerType() string {
|
||||
return api.NETWORK_TYPE_GUEST
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user