From 380037f19c4ce491160f6ea3d05c187d0818689a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Fri, 2 Dec 2022 10:08:44 +0800 Subject: [PATCH] fix(region): hcs vpc emulated (#15478) --- go.mod | 2 +- go.sum | 4 ++-- pkg/compute/models/capabilities.go | 8 ++++++++ vendor/modules.txt | 2 +- vendor/yunion.io/x/cloudmux/pkg/cloudprovider/consts.go | 1 + vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/aws.go | 1 + vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/eip.go | 7 +++++-- .../x/cloudmux/pkg/multicloud/hcs/external_vpc.go | 4 ++++ vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go | 1 + vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/huawei.go | 1 + .../yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go | 1 + 11 files changed, 26 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 78a27de763..cb45391185 100644 --- a/go.mod +++ b/go.mod @@ -84,7 +84,7 @@ require ( k8s.io/client-go v0.19.3 k8s.io/cluster-bootstrap v0.19.3 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221130104643-41851efdcf63 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221201121456-cf1db7634925 yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd yunion.io/x/log v1.0.0 diff --git a/go.sum b/go.sum index c36cf831d8..ee127ff6b1 100644 --- a/go.sum +++ b/go.sum @@ -1176,8 +1176,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221130104643-41851efdcf63 h1:8XDImQk0JY5KTJ6ZCscjTxXAM0rwSZ2Qu9OYtiPMjdk= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221130104643-41851efdcf63/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221201121456-cf1db7634925 h1:Su0puwQV2d/SBAdGz4MfY6NcQR6wXfo2Nwf0m+hC294= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221201121456-cf1db7634925/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ= yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII= yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/compute/models/capabilities.go b/pkg/compute/models/capabilities.go index 1c4321e914..950b569425 100644 --- a/pkg/compute/models/capabilities.go +++ b/pkg/compute/models/capabilities.go @@ -73,6 +73,9 @@ type SCapabilities struct { ContainerBrands []string `json:",allowempty"` DisabledContainerBrands []string `json:",allowempty"` + VpcPeerBrands []string `json:",allowempty"` + DisabledVpcPeerBrands []string `json:",allowempty"` + ReadOnlyBrands []string `json:",allowempty"` ReadOnlyDisabledBrands []string `json:",allowempty"` ReadOnlyComputeEngineBrands []string `json:",allowempty"` @@ -106,6 +109,9 @@ type SCapabilities struct { ReadOnlyContainerBrands []string `json:",allowempty"` ReadOnlyDisabledContainerBrands []string `json:",allowempty"` + ReadOnlyVpcPeerBrands []string `json:",allowempty"` + ReadOnlyDisabledVpcPeerBrands []string `json:",allowempty"` + ResourceTypes []string `json:",allowempty"` StorageTypes []string `json:",allowempty"` // going to remove on 2.14 DataStorageTypes []string `json:",allowempty"` // going to remove on 2.14 @@ -432,6 +438,8 @@ func getBrands(region *SCloudregion, zone *SZone, domainId string, capa *SCapabi appendBrand(&capa.CdnBrands, &capa.DisabledCdnBrands, &capa.ReadOnlyCdnBrands, &capa.ReadOnlyDisabledCdnBrands, brand, capability, enabled, readOnly) case cloudprovider.CLOUD_CAPABILITY_CONTAINER: appendBrand(&capa.ContainerBrands, &capa.DisabledContainerBrands, &capa.ReadOnlyContainerBrands, &capa.ReadOnlyDisabledContainerBrands, brand, capability, enabled, readOnly) + case cloudprovider.CLOUD_CAPABILITY_VPC_PEER: + appendBrand(&capa.VpcPeerBrands, &capa.DisabledVpcPeerBrands, &capa.ReadOnlyVpcPeerBrands, &capa.ReadOnlyDisabledVpcPeerBrands, brand, capability, enabled, readOnly) default: } } diff --git a/vendor/modules.txt b/vendor/modules.txt index f0a5af23c3..2073153584 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1439,7 +1439,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221130104643-41851efdcf63 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221201121456-cf1db7634925 ## explicit; go 1.18 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/consts.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/consts.go index df5f215b2c..27861d44f1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/consts.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/consts.go @@ -54,6 +54,7 @@ const ( CLOUD_CAPABILITY_IPV6_GATEWAY = "ipv6_gateway" // IPv6网关 CLOUD_CAPABILITY_TABLESTORE = "tablestore" // 表格存储 CLOUD_CAPABILITY_MODELARTES = "modelarts" + CLOUD_CAPABILITY_VPC_PEER = "vpcpeer" // 对等连接 CLOUD_CAPABILITY_MISC = "misc" ) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/aws.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/aws.go index 8959813af7..8d67a05c3c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/aws.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/aws.go @@ -563,6 +563,7 @@ func (self *SAwsClient) GetCapabilities() []string { cloudprovider.CLOUD_CAPABILITY_DNSZONE, cloudprovider.CLOUD_CAPABILITY_SAML_AUTH, cloudprovider.CLOUD_CAPABILITY_WAF, + cloudprovider.CLOUD_CAPABILITY_VPC_PEER, } return caps } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/eip.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/eip.go index 17edfdd02c..4ccd6460a7 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/eip.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/eip.go @@ -283,7 +283,7 @@ func (self *SRegion) GetInstancePortId(instanceId string) (string, error) { } // https://support.huaweicloud.com/api-vpc/zh-cn_topic_0020090596.html -func (self *SRegion) AllocateEIP(name string, bwMbps int, chargeType TInternetChargeType, bgpType, subnetId string, projectId string) (*SEip, error) { +func (self *SRegion) AllocateEIP(name, ip string, bwMbps int, chargeType TInternetChargeType, bgpType, subnetId string, projectId string) (*SEip, error) { publicip := map[string]interface{}{ "type": bgpType, "ip_version": 4, @@ -292,6 +292,9 @@ func (self *SRegion) AllocateEIP(name string, bwMbps int, chargeType TInternetCh if len(subnetId) > 0 { publicip["subnet_id"] = subnetId } + if len(ip) > 0 { + publicip["ip_address"] = ip + } params := map[string]interface{}{ "bandwidth": map[string]interface{}{ "name": name, @@ -445,7 +448,7 @@ func (self *SRegion) CreateEIP(eip *cloudprovider.SEip) (cloudprovider.ICloudEIP eip.Name = eip.Name[:64] } - ieip, err := self.AllocateEIP(eip.Name, eip.BandwidthMbps, ctype, eip.BGPType, eip.NetworkExternalId, eip.ProjectId) + ieip, err := self.AllocateEIP(eip.Name, eip.IP, eip.BandwidthMbps, ctype, eip.BGPType, eip.NetworkExternalId, eip.ProjectId) ieip.region = self if err != nil { return nil, err diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_vpc.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_vpc.go index 22b289d4f0..104fd5ec6a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_vpc.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_vpc.go @@ -58,6 +58,10 @@ func (self *SExternalVpc) Refresh() error { return nil } +func (self *SExternalVpc) IsEmulated() bool { + return true +} + func (self *SExternalVpc) GetRegion() cloudprovider.ICloudRegion { return self.region } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go index cd98baafca..587d5b4275 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go @@ -740,6 +740,7 @@ func (self *SHcsClient) GetCapabilities() []string { cloudprovider.CLOUD_CAPABILITY_RDS, cloudprovider.CLOUD_CAPABILITY_LOADBALANCER, cloudprovider.CLOUD_CAPABILITY_NAT, + cloudprovider.CLOUD_CAPABILITY_VPC_PEER, } // huawei objectstore is shared across projects(subscriptions) // to avoid multiple project access the same bucket diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/huawei.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/huawei.go index 27fdb2e4c3..c26e95023c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/huawei.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/huawei.go @@ -484,6 +484,7 @@ func (self *SHuaweiClient) GetCapabilities() []string { cloudprovider.CLOUD_CAPABILITY_NAT, cloudprovider.CLOUD_CAPABILITY_NAS, cloudprovider.CLOUD_CAPABILITY_MODELARTES, + cloudprovider.CLOUD_CAPABILITY_VPC_PEER, } // huawei objectstore is shared across projects(subscriptions) // to avoid multiple project access the same bucket diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go index 305aff9cf8..32372c8d87 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go @@ -775,6 +775,7 @@ func (self *SHuaweiClient) GetCapabilities() []string { cloudprovider.CLOUD_CAPABILITY_NAS, cloudprovider.CLOUD_CAPABILITY_QUOTA + cloudprovider.READ_ONLY_SUFFIX, cloudprovider.CLOUD_CAPABILITY_MODELARTES, + cloudprovider.CLOUD_CAPABILITY_VPC_PEER, } // huawei objectstore is shared across projects(subscriptions) // to avoid multiple project access the same bucket