mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update
This commit is contained in:
@@ -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.20230725101829-eeaabf101216
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230726030452-d5f9e212ee4b
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1174,8 +1174,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.20230725101829-eeaabf101216 h1:JuP1SzV5J7BK/1NDJHxu10CFCVwilbF2Q6db+5DM3NI=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230725101829-eeaabf101216/go.mod h1:2sgCN7nRPQL3woLfdgqLDd92vwAHqtlz3KKiHxC5BAw=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230726030452-d5f9e212ee4b h1:vwsiN/JVzhuXNXh7+cg/RvLdVO02uaYDtjB0DNDQrGc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230726030452-d5f9e212ee4b/go.mod h1:2sgCN7nRPQL3woLfdgqLDd92vwAHqtlz3KKiHxC5BAw=
|
||||
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=
|
||||
|
||||
Vendored
+1
-1
@@ -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.20230725101829-eeaabf101216
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230726030452-d5f9e212ee4b
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+29
-14
@@ -59,6 +59,7 @@ type SNetworkInterface struct {
|
||||
InstanceId string
|
||||
CreationTime time.Time
|
||||
MacAddress string
|
||||
ServiceManaged bool
|
||||
NetworkInterfaceName string
|
||||
PrivateIpSets SPrivateIpSets
|
||||
ResourceGroupId string
|
||||
@@ -71,6 +72,12 @@ type SNetworkInterface struct {
|
||||
NetworkInterfaceId string
|
||||
PrimaryIpAddress string
|
||||
PrivateIpAddress string
|
||||
|
||||
Attachment struct {
|
||||
InstanceId string
|
||||
DeviceIndex int
|
||||
TrunkNetworkInterfaceId string
|
||||
}
|
||||
}
|
||||
|
||||
func (nic *SNetworkInterface) GetName() string {
|
||||
@@ -107,23 +114,26 @@ func (nic *SNetworkInterface) GetStatus() string {
|
||||
|
||||
func (region *SRegion) GetINetworkInterfaces() ([]cloudprovider.ICloudNetworkInterface, error) {
|
||||
interfaces := []SNetworkInterface{}
|
||||
nextToken := ""
|
||||
for {
|
||||
parts, total, err := region.GetNetworkInterfaces("", len(interfaces), 50)
|
||||
parts, _nextToken, err := region.GetNetworkInterfaces("", "Available", nextToken, 500)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
interfaces = append(interfaces, parts...)
|
||||
if len(interfaces) >= total {
|
||||
if len(_nextToken) == 0 {
|
||||
break
|
||||
}
|
||||
nextToken = _nextToken
|
||||
}
|
||||
ret := []cloudprovider.ICloudNetworkInterface{}
|
||||
for i := 0; i < len(interfaces); i++ {
|
||||
// 阿里云实例的弹性网卡已经在guestnetwork同步了
|
||||
if len(interfaces[i].InstanceId) == 0 {
|
||||
interfaces[i].region = region
|
||||
ret = append(ret, &interfaces[i])
|
||||
if interfaces[i].ServiceManaged {
|
||||
continue
|
||||
}
|
||||
interfaces[i].region = region
|
||||
ret = append(ret, &interfaces[i])
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
@@ -137,31 +147,36 @@ func (nic *SNetworkInterface) GetICloudInterfaceAddresses() ([]cloudprovider.ICl
|
||||
return address, nil
|
||||
}
|
||||
|
||||
func (region *SRegion) GetNetworkInterfaces(instanceId string, offset int, limit int) ([]SNetworkInterface, int, error) {
|
||||
if limit > 50 || limit <= 0 {
|
||||
limit = 50
|
||||
func (region *SRegion) GetNetworkInterfaces(instanceId, status string, nextToken string, maxResults int) ([]SNetworkInterface, string, error) {
|
||||
if maxResults > 500 || maxResults <= 0 {
|
||||
maxResults = 500
|
||||
}
|
||||
|
||||
params := map[string]string{
|
||||
"RegionId": region.RegionId,
|
||||
"PageSize": fmt.Sprintf("%d", limit),
|
||||
"PageNumber": fmt.Sprintf("%d", (offset/limit)+1),
|
||||
"MaxResults": fmt.Sprintf("%d", maxResults),
|
||||
}
|
||||
if len(nextToken) > 0 {
|
||||
params["NextToken"] = nextToken
|
||||
}
|
||||
|
||||
if len(instanceId) > 0 {
|
||||
params["InstanceId"] = instanceId
|
||||
}
|
||||
if len(status) > 0 {
|
||||
params["Status"] = status
|
||||
}
|
||||
|
||||
body, err := region.ecsRequest("DescribeNetworkInterfaces", params)
|
||||
if err != nil {
|
||||
return nil, 0, errors.Wrap(err, "DescribeNetworkInterfaces")
|
||||
return nil, "", errors.Wrap(err, "DescribeNetworkInterfaces")
|
||||
}
|
||||
|
||||
interfaces := []SNetworkInterface{}
|
||||
err = body.Unmarshal(&interfaces, "NetworkInterfaceSets", "NetworkInterfaceSet")
|
||||
if err != nil {
|
||||
return nil, 0, errors.Wrap(err, "Unmarshal")
|
||||
return nil, "", errors.Wrap(err, "Unmarshal")
|
||||
}
|
||||
total, _ := body.Int("TotalCount")
|
||||
return interfaces, int(total), nil
|
||||
nextToken, _ = body.GetString("NextToken")
|
||||
return interfaces, nextToken, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user