Skip to content

Commit

Permalink
feat:ICloudVpc增加IsPublic、ICloudRegion增加GetISecurityGroups接口,所有driver增…
Browse files Browse the repository at this point in the history
…加默认实现。
  • Loading branch information
李锐 committed Apr 26, 2023
1 parent 48f4b44 commit 2ae7f32
Show file tree
Hide file tree
Showing 41 changed files with 160 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ type ProviderConfig struct {

AliyunResourceGroupIds []string

ManagerProviderConfig *ProviderConfig

UpdatePermission func(service, permission string)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cloudprovider/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ type DiskCreateConfig struct {
SizeGb int
Desc string
ProjectId string
ZoneId string
}
2 changes: 2 additions & 0 deletions pkg/cloudprovider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type ICloudRegion interface {
GetISecurityGroupById(secgroupId string) (ICloudSecurityGroup, error)
GetISecurityGroupByName(opts *SecurityGroupFilterOptions) (ICloudSecurityGroup, error)
CreateISecurityGroup(conf *SecurityGroupCreateInput) (ICloudSecurityGroup, error)
GetISecurityGroups() ([]ICloudSecurityGroup, error)

CreateIVpc(opts *VpcCreateOptions) (ICloudVpc, error)
CreateInternetGateway() (ICloudInternetGateway, error)
Expand Down Expand Up @@ -607,6 +608,7 @@ type ICloudVpc interface {
ProposeJoinICloudInterVpcNetwork(opts *SVpcJointInterVpcNetworkOption) error

GetICloudIPv6Gateways() ([]ICloudIPv6Gateway, error)
IsPublic() bool
}

type ICloudInternetGateway interface {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloudprovider/subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ import (
)

type SSubAccount struct {
Id string // ID
// 若Account不为空,可不传
Name string
// 描述信息
Desc string
// 输入必填,若为空,需要指定子账号名称
Account string
Secret string // 子账号SK
HealthStatus string // 云端服务健康状态。例如欠费、项目冻结都属于不健康状态。
IsSubAccount bool // 是否子账号
DefaultProjectId string // 默认云订阅项目Id
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/multicloud/aliyun/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func (self *SRegion) GetOssClient() (*oss.Client, error) {
return self.ossClient, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) ecsRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
client, err := self.getSdkClient()
if err != nil {
Expand Down Expand Up @@ -297,7 +301,7 @@ func (self *SRegion) _lbRequest(client *sdk.Client, apiName string, domain strin
return jsonRequest(client, domain, ALIYUN_API_VERSION_LB, apiName, params, self.client.debug)
}

/////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
func (self *SRegion) GetId() string {
return self.RegionId
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/aliyun/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetIsDefault() bool {
return self.IsDefault
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/multicloud/apsara/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func (self *SRegion) tagRequest(serviceType string, action string, params map[st
}
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) lbRequest(apiName string, params map[string]string) (jsonutils.JSONObject, error) {
client, err := self.getSdkClient()
if err != nil {
Expand All @@ -158,7 +162,7 @@ func (self *SRegion) lbRequest(apiName string, params map[string]string) (jsonut
return self.productRequest(client, APSARA_PRODUCT_SLB, domain, APSARA_API_VERSION_LB, apiName, params, self.client.debug)
}

/////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
func (self *SRegion) GetId() string {
return self.RegionId
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/apsara/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetIsDefault() bool {
return self.IsDefault
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/multicloud/aws/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (self *SAwsClient) monitorRequest(regionId, apiName string, params map[stri
return self.request(regionId, CLOUDWATCH_SERVICE_NAME, CLOUDWATCH_SERVICE_ID, "2010-08-01", apiName, params, retval, true)
}

/////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
func (self *SRegion) fetchZones() error {
ec2Client, err := self.getEc2Client()
if err != nil {
Expand Down Expand Up @@ -410,6 +410,10 @@ func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) {
return self.izones, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) {
if self.ivpcs == nil {
err := self.fetchInfrastructure()
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/aws/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
return self.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/azure/classic_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (self *SClassicVpc) GetIsDefault() bool {
return false
}

func (self *SClassicVpc) IsPublic() bool {
return false
}

func (self *SClassicVpc) GetCidrBlock() string {
if len(self.Properties.AddressSpace.AddressPrefixes) > 0 {
return self.Properties.AddressSpace.AddressPrefixes[0]
Expand Down
6 changes: 5 additions & 1 deletion pkg/multicloud/azure/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type SRegion struct {
Longitude string
}

/////////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
func (self *SRegion) Refresh() error {
// do nothing
return nil
Expand Down Expand Up @@ -104,6 +104,10 @@ func (self *SRegion) GetName() string {
return fmt.Sprintf("%s %s", CLOUD_PROVIDER_AZURE_CN, self.DisplayName)
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetI18n() cloudprovider.SModelI18nTable {
en := fmt.Sprintf("%s %s", CLOUD_PROVIDER_AZURE_EN, self.DisplayName)
table := cloudprovider.SModelI18nTable{}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/azure/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetIsDefault() bool {
return true
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/ctyun/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ func (self *SRegion) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
return iStores, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
izones, err := self.GetIZones()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/ctyun/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
return self.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/ecloud/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func (r *SRegion) fetchVpcs() error {
return nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (r *SRegion) getVpcs() ([]SVpc, error) {
request := NewConsoleRequest(r.ID, "/api/v2/netcenter/vpc", nil, nil)
vpcs := make([]SVpc, 0)
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/ecloud/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func (v *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (v *SVpc) GetRegion() cloudprovider.ICloudRegion {
return v.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/esxi/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ func (cli *SESXiClient) GetVersion() string {
return cli.client.ServiceContent.About.Version
}

func (self *SESXiClient) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (cli *SESXiClient) About() jsonutils.JSONObject {
about := jsonutils.Marshal(&cli.client.ServiceContent.About)
aboutDict := about.(*jsonutils.JSONDict)
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/google/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (region *SRegion) GetProvider() string {
return CLOUD_PROVIDER_GOOGLE
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (region *SRegion) GetStatus() string {
if region.Status == "UP" || utils.IsInStringArray(region.Name, MultiRegions) || utils.IsInStringArray(region.Name, DualRegions) {
return api.CLOUD_REGION_STATUS_INSERVER
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/google/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (vpc *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (vpc *SVpc) GetIsDefault() bool {
return false
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/hcso/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (self *SRegion) GetGeographicInfo() cloudprovider.SGeographicInfo {
return cloudprovider.SGeographicInfo{}
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetILoadBalancers() ([]cloudprovider.ICloudLoadbalancer, error) {
elbs, err := self.GetLoadBalancers()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/hcso/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
return self.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/huawei/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type SRegion struct {
storageCache *SStoragecache
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetClient() *SHuaweiClient {
return self.client
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/huawei/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func (self *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
return self.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/jdcloud/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ func (r *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) {
return nil, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (r *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
vpc, err := r.GetVpcById(id)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/jdcloud/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (v *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (v *SVpc) GetRegion() cloudprovider.ICloudRegion {
return v.region
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/nutanix/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
return vpc, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) {
vpcs, err := self.GetVpcs()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/nutanix/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (self *SVpc) GetName() string {
return self.Name
}

func (self *SVpc) IsPublic() bool {
return false
}

func (self *SVpc) GetId() string {
return self.UUID
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/objectstore/objectstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (cli *SObjectStoreClient) GetIRegion() cloudprovider.ICloudRegion {
return cli.GetVirtualObject().(cloudprovider.ICloudRegion)
}

func (self *SObjectStoreClient) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (cli *SObjectStoreClient) GetIBucketProvider() IBucketProvider {
return cli.GetVirtualObject().(IBucketProvider)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/openstack/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func (region *SRegion) GetIStorages() ([]cloudprovider.ICloudStorage, error) {
return iStorages, nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (region *SRegion) getStoragecache() *SStoragecache {
if region.storageCache == nil {
region.storageCache = &SStoragecache{region: region}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/openstack/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (vpc *SVpc) IsEmulated() bool {
return false
}

func (self *SVpc) IsPublic() bool {
return false
}

func (vpc *SVpc) GetIsDefault() bool {
return vpc.IsDefault
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/multicloud/proxmox/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func (self *SRegion) Refresh() error {
return nil
}

func (self *SRegion) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
return nil, nil
}

func (self *SRegion) GetISecurityGroupById(secgroupId string) (cloudprovider.ICloudSecurityGroup, error) {
return nil, cloudprovider.ErrNotSupported
}
Expand Down
Loading

0 comments on commit 2ae7f32

Please sign in to comment.