mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix(region): remove useless code (#18454)
This commit is contained in:
@@ -16,12 +16,9 @@ package regiondrivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -110,34 +107,3 @@ func (self *SAzureRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(q
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SAzureRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -16,11 +16,8 @@ package regiondrivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -69,34 +66,3 @@ func (self *SBingoCloudRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (f
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SBingoCloudRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@ package regiondrivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
@@ -77,34 +74,3 @@ func (self *SCloudpodsRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (fu
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SCloudpodsRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -16,12 +16,9 @@ package regiondrivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -90,34 +87,3 @@ func (self *SCtyunRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(q
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SCtyunRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -627,34 +626,3 @@ func (self *SHuaWeiRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId).Equals("manager_id", vpc.ManagerId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SHuaWeiRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -3497,6 +3497,7 @@ func (self *SManagedVirtualizationRegionDriver) CreateDefaultSecurityGroup(
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
// 部分云可能不需要vpcId, 创建完安全组后会自动置空
|
||||
newGroup.VpcId = vpc.Id
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
|
||||
@@ -17,12 +17,9 @@ package regiondrivers
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -133,34 +130,3 @@ func (self *SOpenStackRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (fu
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SOpenStackRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -626,34 +626,3 @@ func (self *SQcloudRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SQcloudRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -16,12 +16,9 @@ package regiondrivers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/secrules"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
@@ -97,34 +94,3 @@ func (self *SUcloudRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SUcloudRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
@@ -17,11 +17,8 @@ package regiondrivers
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -94,34 +91,3 @@ func (self *SZStackRegionDriver) GetSecurityGroupFilter(vpc *models.SVpc) (func(
|
||||
return q.Equals("cloudregion_id", vpc.CloudregionId)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SZStackRegionDriver) CreateDefaultSecurityGroup(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider,
|
||||
vpc *models.SVpc,
|
||||
) (*models.SSecurityGroup, error) {
|
||||
newGroup := &models.SSecurityGroup{}
|
||||
newGroup.SetModelManager(models.SecurityGroupManager, newGroup)
|
||||
newGroup.Name = fmt.Sprintf("default-auto-%d", time.Now().Unix())
|
||||
newGroup.Description = "auto generage"
|
||||
newGroup.ManagerId = vpc.ManagerId
|
||||
newGroup.CloudregionId = vpc.CloudregionId
|
||||
newGroup.DomainId = ownerId.GetDomainId()
|
||||
newGroup.ProjectId = ownerId.GetProjectId()
|
||||
err := models.SecurityGroupManager.TableSpec().Insert(ctx, newGroup)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "insert")
|
||||
}
|
||||
|
||||
region, err := vpc.GetRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetRegion")
|
||||
}
|
||||
driver := region.GetDriver()
|
||||
err = driver.RequestCreateSecurityGroup(ctx, userCred, newGroup, api.SSecgroupRuleResourceSet{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestCreateSecurityGroup")
|
||||
}
|
||||
return newGroup, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user