mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update for qcloud nat sync (#20638)
This commit is contained in:
@@ -89,7 +89,7 @@ require (
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
k8s.io/cri-api v0.22.17
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240624093546-ec3bdebc874f
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240625073308-e7f818389af0
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401
|
||||
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
|
||||
|
||||
@@ -1215,8 +1215,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.20240624093546-ec3bdebc874f h1:YHNmkCONVacoz2tnEIy9IvmdvzLMefL8yD3LiWB0zGY=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240624093546-ec3bdebc874f/go.mod h1:quoJjGTJ2PjAY0+3YeN5JuN136whECKmfkJQwIsXKjM=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240625073308-e7f818389af0 h1:tHwLq3t3M8JxJ1IPOYarEQQmFy7YB4PVCtmdzn3C/7Q=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240625073308-e7f818389af0/go.mod h1:quoJjGTJ2PjAY0+3YeN5JuN136whECKmfkJQwIsXKjM=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -749,6 +749,9 @@ func (self *SNatGateway) GetVpc() (*SVpc, error) {
|
||||
}
|
||||
|
||||
func (self *SNatGateway) GetINatGateway(ctx context.Context) (cloudprovider.ICloudNatGateway, error) {
|
||||
if len(self.ExternalId) == 0 {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "empty external id")
|
||||
}
|
||||
vpc, err := self.GetVpc()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetVpc")
|
||||
|
||||
Vendored
+1
-1
@@ -1489,7 +1489,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.20240624093546-ec3bdebc874f
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240625073308-e7f818389af0
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+1
-24
@@ -30,12 +30,10 @@ type SDTable struct {
|
||||
CreatedTime string `json:"CreatedTime"`
|
||||
Description string `json:"Description"`
|
||||
IpProtocol string `json:"IpProtocol"`
|
||||
NatGatewayId string `json:"NatGatewayId"`
|
||||
PrivateIpAddress string `json:"PrivateIpAddress"`
|
||||
PrivatePort int `json:"PrivatePort"`
|
||||
PublicIpAddress string `json:"PublicIpAddress"`
|
||||
PublicPort int `json:"PublicPort"`
|
||||
VpcId string `json:"VpcId"`
|
||||
}
|
||||
|
||||
func (table *SDTable) GetName() string {
|
||||
@@ -46,7 +44,7 @@ func (table *SDTable) GetName() string {
|
||||
}
|
||||
|
||||
func (table *SDTable) GetId() string {
|
||||
return fmt.Sprintf("%s/%s/%d", table.NatGatewayId, table.PublicIpAddress, table.PublicPort)
|
||||
return fmt.Sprintf("%s/%s/%d", table.nat.GetId(), table.PublicIpAddress, table.PublicPort)
|
||||
}
|
||||
|
||||
func (table *SDTable) GetGlobalId() string {
|
||||
@@ -80,24 +78,3 @@ func (table *SDTable) GetIpProtocol() string {
|
||||
func (table *SDTable) Delete() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (region *SRegion) GetDTables(natId string, offset, limit int) ([]SDTable, int, error) {
|
||||
params := map[string]string{}
|
||||
if limit < 1 || limit > 50 {
|
||||
limit = 50
|
||||
}
|
||||
params["Limit"] = fmt.Sprintf("%d", limit)
|
||||
params["Offset"] = fmt.Sprintf("%d", offset)
|
||||
params["NatGatewayIds.0"] = natId
|
||||
body, err := region.vpcRequest("DescribeNatGatewayDestinationIpPortTranslationNatRules", params)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
tables := []SDTable{}
|
||||
err = body.Unmarshal(&tables, "NatGatewayDestinationIpPortTranslationNatRuleSet")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
total, _ := body.Float("TotalCount")
|
||||
return tables, int(total), nil
|
||||
}
|
||||
|
||||
+22
-35
@@ -28,14 +28,11 @@ type SNatGateway struct {
|
||||
QcloudTags
|
||||
vpc *SVpc
|
||||
|
||||
NatId string `json:"natId"`
|
||||
NatName string `json:"natName"`
|
||||
ProductionStatus string `json:"productionStatus"`
|
||||
State string `json:"state"`
|
||||
VpcId string
|
||||
Zone string `json:"zone"`
|
||||
NatGatewayName string
|
||||
NatGatewayId string
|
||||
State string
|
||||
VpcId string
|
||||
Zone string
|
||||
NatGatewayName string
|
||||
NatGatewayId string
|
||||
|
||||
Bandwidth string `json:"bandwidth"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
@@ -45,27 +42,23 @@ type SNatGateway struct {
|
||||
PublicIpAddressSet []struct {
|
||||
AddressId string
|
||||
}
|
||||
SourceIpTranslationNatRuleSet []SSTable
|
||||
DestinationIpPortTranslationNatRuleSet []SDTable
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetName() string {
|
||||
if len(nat.NatGatewayId) > 0 {
|
||||
return nat.NatGatewayId
|
||||
}
|
||||
if len(nat.NatGatewayName) > 0 {
|
||||
return nat.NatName
|
||||
return nat.NatGatewayName
|
||||
}
|
||||
if len(nat.NatName) > 0 {
|
||||
return nat.NatName
|
||||
}
|
||||
return nat.NatId
|
||||
return nat.NatGatewayId
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetId() string {
|
||||
return nat.NatId + nat.NatGatewayId
|
||||
return nat.NatGatewayId
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetGlobalId() string {
|
||||
return nat.NatId + nat.NatGatewayId
|
||||
return nat.NatGatewayId
|
||||
}
|
||||
|
||||
func (self *SNatGateway) GetINetworkId() string {
|
||||
@@ -124,27 +117,21 @@ func (nat *SNatGateway) GetIEips() ([]cloudprovider.ICloudEIP, error) {
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetINatSTable() ([]cloudprovider.ICloudNatSEntry, error) {
|
||||
return []cloudprovider.ICloudNatSEntry{}, nil
|
||||
ret := []cloudprovider.ICloudNatSEntry{}
|
||||
for i := 0; i < len(nat.SourceIpTranslationNatRuleSet); i++ {
|
||||
nat.SourceIpTranslationNatRuleSet[i].nat = nat
|
||||
ret = append(ret, &nat.SourceIpTranslationNatRuleSet[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetINatDTable() ([]cloudprovider.ICloudNatDEntry, error) {
|
||||
tables := []SDTable{}
|
||||
for {
|
||||
part, total, err := nat.vpc.region.GetDTables(nat.NatId, len(tables), 50)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tables = append(tables, part...)
|
||||
if len(tables) >= total || len(part) == 0 {
|
||||
break
|
||||
}
|
||||
ret := []cloudprovider.ICloudNatDEntry{}
|
||||
for i := 0; i < len(nat.DestinationIpPortTranslationNatRuleSet); i++ {
|
||||
nat.DestinationIpPortTranslationNatRuleSet[i].nat = nat
|
||||
ret = append(ret, &nat.DestinationIpPortTranslationNatRuleSet[i])
|
||||
}
|
||||
itables := []cloudprovider.ICloudNatDEntry{}
|
||||
for i := 0; i < len(tables); i++ {
|
||||
tables[i].nat = nat
|
||||
itables = append(itables, &tables[i])
|
||||
}
|
||||
return itables, nil
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (nat *SNatGateway) GetINatDEntryById(id string) (cloudprovider.ICloudNatDEntry, error) {
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package qcloud
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/cloudmux/pkg/multicloud"
|
||||
)
|
||||
|
||||
type SSTable struct {
|
||||
multicloud.SResourceBase
|
||||
QcloudTags
|
||||
nat *SNatGateway
|
||||
|
||||
CreatedTime string
|
||||
Description string
|
||||
NatGatewayId string
|
||||
NatGatewaySnatId string
|
||||
PrivateIpAddress string
|
||||
PublicIpAddresses []string
|
||||
ResourceId string
|
||||
ResourceType string
|
||||
VpcId string
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetName() string {
|
||||
return stable.NatGatewaySnatId
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetId() string {
|
||||
return stable.NatGatewaySnatId
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetGlobalId() string {
|
||||
return stable.NatGatewaySnatId
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetStatus() string {
|
||||
return api.NAT_STAUTS_AVAILABLE
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetIP() string {
|
||||
return strings.Join(stable.PublicIpAddresses, ",")
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetSourceCIDR() string {
|
||||
return stable.PrivateIpAddress
|
||||
}
|
||||
|
||||
func (stable *SSTable) GetNetworkId() string {
|
||||
return stable.ResourceId
|
||||
}
|
||||
|
||||
func (stable *SSTable) Delete() error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
Reference in New Issue
Block a user