fix: vender update

This commit is contained in:
ioito
2022-11-04 15:35:57 +08:00
parent 112991ea85
commit eba93fe354
16 changed files with 114 additions and 69 deletions
+1 -1
View File
@@ -83,7 +83,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.20221101083441-16667c2d550f
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221104072544-5e692eda880d
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
+2 -2
View File
@@ -1162,8 +1162,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.20221101083441-16667c2d550f h1:2+R3KK+2CHf+JA2ODt6b/XmxH148EyeBtMrfHJg4ZJ8=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221101083441-16667c2d550f/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221104072544-5e692eda880d h1:GiL8q1iq/F7ANcW58haya8ZjwaRHsCrc6N8mZ0GKrCk=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221104072544-5e692eda880d/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=
+1 -1
View File
@@ -1428,7 +1428,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.20221101083441-16667c2d550f
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221104072544-5e692eda880d
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+20
View File
@@ -0,0 +1,20 @@
// 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 compute
const (
MODELARTS_POOL_STATUS_RUNNING = "running"
MODELARTS_POOL_STATUS_CREATING = "creating"
)
+23 -3
View File
@@ -16,6 +16,7 @@ package aliyun
import (
"strconv"
"strings"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -260,6 +261,27 @@ func (self *SDomainRecord) GetPolicyType() cloudprovider.TDnsPolicyType {
case "oversea":
return cloudprovider.DnsPolicyTypeByGeoLocation
default:
for _, prefix := range []string{
"cn_telecom",
"cn_unicom",
"cn_mobile",
"cn_edu",
"cn_drpeng",
"cn_btvn",
} {
if strings.HasPrefix(self.Line, prefix) {
return cloudprovider.DnsPolicyTypeByCarrier
}
}
for _, prefix := range []string{
"cn_region",
"os_",
"aliyun_",
} {
if strings.HasPrefix(self.Line, prefix) {
return cloudprovider.DnsPolicyTypeByGeoLocation
}
}
return cloudprovider.DnsPolicyTypeSimple
}
}
@@ -276,7 +298,6 @@ func (self *SDomainRecord) GetPolicyValue() cloudprovider.TDnsPolicyValue {
return cloudprovider.DnsPolicyValueOversea
case "edu":
return cloudprovider.DnsPolicyValueCernet
case "drpeng":
return cloudprovider.DnsPolicyValueDrPeng
case "btvn":
@@ -289,9 +310,8 @@ func (self *SDomainRecord) GetPolicyValue() cloudprovider.TDnsPolicyValue {
return cloudprovider.DnsPolicyValueBing
case "youdao":
return cloudprovider.DnsPolicyValueYoudao
}
return ""
return cloudprovider.TDnsPolicyValue(self.Line)
}
func (self *SDomainRecord) GetPolicyOptions() *jsonutils.JSONDict {
+17 -4
View File
@@ -16,6 +16,7 @@ package cloudpods
import (
"context"
"fmt"
"net/http"
"strings"
@@ -59,10 +60,11 @@ type ModelManager interface {
type CloudpodsClientConfig struct {
cpcfg cloudprovider.ProviderConfig
authURL string
region string
accessKey string
accessSecret string
authURL string
region string
accessKey string
accessSecret string
adminProjectId string
debug bool
}
@@ -81,6 +83,11 @@ func (cfg *CloudpodsClientConfig) Debug(debug bool) *CloudpodsClientConfig {
return cfg
}
func (cfg *CloudpodsClientConfig) AdminProjectId(id string) *CloudpodsClientConfig {
cfg.adminProjectId = id
return cfg
}
func (cfg *CloudpodsClientConfig) CloudproviderConfig(cpcfg cloudprovider.ProviderConfig) *CloudpodsClientConfig {
cfg.cpcfg = cpcfg
return cfg
@@ -123,6 +130,12 @@ func (self *SCloudpodsClient) auth() error {
}
}
self.s = client.NewSession(context.Background(), serviceRegion, "", "publicURL", token)
if !self.s.GetToken().HasSystemAdminPrivilege() {
return fmt.Errorf("no system admin privilege")
}
if self.s.GetProjectDomainId() == self.adminProjectId {
return fmt.Errorf("You can't manage yourself environment")
}
return nil
}
+6 -1
View File
@@ -19,8 +19,10 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
@@ -74,12 +76,15 @@ func (self *SCloudpodsProviderFactory) ValidateUpdateCloudaccountCredential(ctx
}
func (self *SCloudpodsProviderFactory) GetProvider(cfg cloudprovider.ProviderConfig) (cloudprovider.ICloudProvider, error) {
adminProjectId := auth.GetAdminSession(context.TODO(), options.Options.Region).GetProjectDomainId()
client, err := cloudpods.NewCloudpodsClient(
cloudpods.NewCloudpodsClientConfig(
cfg.URL,
cfg.Account,
cfg.Secret,
).Debug(cfg.Debug).CloudproviderConfig(cfg),
).Debug(cfg.Debug).
CloudproviderConfig(cfg).
AdminProjectId(adminProjectId),
)
if err != nil {
return nil, err
+5 -8
View File
@@ -37,17 +37,17 @@ import (
"yunion.io/x/pkg/util/regutils"
"yunion.io/x/pkg/utils"
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
cloudtypes "yunion.io/x/onecloud/pkg/cloudcommon/types"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/cloudmux/pkg/multicloud"
"yunion.io/x/onecloud/pkg/util/billing"
"yunion.io/x/onecloud/pkg/util/imagetools"
"yunion.io/x/onecloud/pkg/util/netutils2"
"yunion.io/x/onecloud/pkg/util/version"
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)
var (
@@ -441,9 +441,6 @@ func (self *SVirtualMachine) startVM(ctx context.Context) error {
return errors.Wrap(httperrors.ErrInvalidStatus, "no valid host")
}
lockman.LockRawObject(ctx, "host", ihost.GetGlobalId())
defer lockman.ReleaseRawObject(ctx, "host", ihost.GetGlobalId())
err := self.makeNicsStartConnected(ctx)
if err != nil {
log.Errorf("self.makeNicsStartConnected %s", err)
+3 -7
View File
@@ -22,9 +22,9 @@ import (
"yunion.io/x/pkg/errors"
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
"yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/util/billing"
)
@@ -288,12 +288,8 @@ func (self *SModelartsPool) GetName() string {
func (self *SModelartsPool) GetStatus() string {
res := strings.ToLower(self.Status.Phase)
switch {
case res == api.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0:
res = api.MODELARTS_POOL_STATUS_CREATING
case self.Status.Phase == "CreationFailed":
res = api.MODELARTS_POOL_STATUS_CREATE_FAILED
case self.Status.Phase == "SeclingFailed":
res = api.MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED
case res == compute.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0:
res = compute.MODELARTS_POOL_STATUS_CREATING
}
return res
}
+24 -5
View File
@@ -220,12 +220,31 @@ func (self *SHuaweiClient) CreateSAMLProvider(opts *cloudprovider.SAMLProviderCr
name = append(name, '-')
}
}
opts.Name = string(name)
_, err = client.SAMLProviders.Update(opts.Name, params)
if err != nil {
if he, ok := err.(*modules.HuaweiClientError); ok && he.Code != 409 {
return nil, errors.Wrapf(err, "SAMLProviders.Update")
samlName := string(name)
err = func() error {
idx := 1
for {
_, err = client.SAMLProviders.Update(samlName, params)
if err == nil {
return nil
}
he, ok := err.(*modules.HuaweiClientError)
if !ok {
return errors.Wrapf(err, "SAMLProviders.Update")
}
if he.Code != 409 {
return errors.Wrapf(err, "SAMLProviders.Update")
}
samlName = fmt.Sprintf("%s-%d", string(name), idx)
idx++
if idx >= 40 {
break
}
}
return err
}()
if err != nil {
return nil, errors.Wrapf(err, "saml provider create")
}
ret := SAMLProvider{client: self, Id: opts.Name}
err = self.UpdateSAMLProviderMetadata(opts.Name, opts.Metadata.String())
+3 -7
View File
@@ -22,9 +22,9 @@ import (
"yunion.io/x/pkg/errors"
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
"yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/util/billing"
)
@@ -287,12 +287,8 @@ func (self *SModelartsPool) GetName() string {
func (self *SModelartsPool) GetStatus() string {
res := strings.ToLower(self.Status.Phase)
switch {
case res == api.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0:
res = api.MODELARTS_POOL_STATUS_CREATING
case self.Status.Phase == "CreationFailed":
res = api.MODELARTS_POOL_STATUS_CREATE_FAILED
case self.Status.Phase == "SeclingFailed":
res = api.MODELARTS_POOL_STATUS_CHANGE_CONFIG_FAILED
case res == compute.MODELARTS_POOL_STATUS_RUNNING && len(self.Status.Resource.Creating) != 0:
res = compute.MODELARTS_POOL_STATUS_CREATING
}
return res
}
-7
View File
@@ -27,7 +27,6 @@ import (
"yunion.io/x/pkg/utils"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)
@@ -103,9 +102,6 @@ func (self *SLoadbalancer) GetEgressMbps() int {
// https://cloud.tencent.com/document/product/214/30689
func (self *SLoadbalancer) Delete(ctx context.Context) error {
lockman.LockRawObject(ctx, "qcloud.SLoadbalancer.Delete", self.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLoadbalancer.Delete", self.region.client.ownerId)
if self.Forward == LB_TYPE_APPLICATION {
_, err := self.region.DeleteLoadbalancer(self.GetId())
if err != nil {
@@ -167,9 +163,6 @@ func onecloudHealthCodeToQcloud(codes string) int {
// todo: 1.限制比较多必须加参数校验 2.Onecloud 不支持双向证书可能存在兼容性问题
// 应用型负载均衡 传统型不支持设置SNI
func (self *SLoadbalancer) CreateILoadBalancerListener(ctx context.Context, listener *cloudprovider.SLoadbalancerListener) (cloudprovider.ICloudLoadbalancerListener, error) {
lockman.LockRawObject(ctx, "qcloud.SLoadbalancer.CreateILoadBalancerListener", self.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLoadbalancer.CreateILoadBalancerListener", self.region.client.ownerId)
sniSwitch := 0
hc := getHealthCheck(listener)
cert := getCertificate(listener)
@@ -21,7 +21,6 @@ import (
"yunion.io/x/jsonutils"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)
@@ -195,9 +194,6 @@ func (self *SLBBackend) GetProjectId() string {
}
func (self *SLBBackend) SyncConf(ctx context.Context, port, weight int) error {
lockman.LockRawObject(ctx, "qcloud.SLBBackend.SyncConf", self.group.lb.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLBBackend.SyncConf", self.group.lb.region.client.ownerId)
err := self.group.UpdateBackendServer(self.InstanceID, self.Weight, self.Port, weight, port)
if err != nil {
return err
+4 -15
View File
@@ -24,7 +24,6 @@ import (
"yunion.io/x/jsonutils"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)
@@ -151,9 +150,6 @@ func (self *SLBListener) Stop() error {
// https://cloud.tencent.com/document/product/214/30677
func (self *SLBListener) Sync(ctx context.Context, listener *cloudprovider.SLoadbalancerListener) error {
lockman.LockRawObject(ctx, "qcloud.SLBListener.Sync", self.lb.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLBListener.Sync", self.lb.region.client.ownerId)
hc := getHealthCheck(listener)
cert := getCertificate(listener)
requestId, err := self.lb.region.UpdateLoadbalancerListener(
@@ -173,9 +169,6 @@ func (self *SLBListener) Sync(ctx context.Context, listener *cloudprovider.SLoad
}
func (self *SLBListener) Delete(ctx context.Context) error {
lockman.LockRawObject(ctx, "qcloud.SLBListener.Delete", self.lb.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLBListener.Delete", self.lb.region.client.ownerId)
requestId, err := self.lb.region.DeleteLoadbalancerListener(self.lb.Forward, self.lb.GetId(), self.GetId())
if err != nil {
return err
@@ -524,7 +517,7 @@ func (self *SRegion) GetLoadbalancerListeners(lbid string, t LB_TYPE, protocol s
return listeners, nil
}
// 返回requestID
// 返回requestID
func (self *SRegion) CreateLoadbalancerListenerRule(lbid string, listenerId string, domain string, url string, scheduler string, sessionExpireTime int, hc *healthCheck) (string, error) {
if len(lbid) == 0 {
return "", fmt.Errorf("loadbalancer id should not be empty")
@@ -560,7 +553,7 @@ func (self *SRegion) CreateLoadbalancerListenerRule(lbid string, listenerId stri
return resp.GetString("RequestId")
}
// 返回requestID
// 返回requestID
func (self *SRegion) deleteLoadbalancerListener(lbid string, listenerId string) (string, error) {
if len(lbid) == 0 {
return "", fmt.Errorf("loadbalancer id should not be empty")
@@ -579,7 +572,7 @@ func (self *SRegion) deleteLoadbalancerListener(lbid string, listenerId string)
return resp.GetString("RequestId")
}
// 返回requestID
// 返回requestID
func (self *SRegion) deleteClassicLoadbalancerListener(lbid string, listenerId string) (string, error) {
if len(lbid) == 0 {
return "", fmt.Errorf("classic loadbalancer id should not be empty")
@@ -603,12 +596,8 @@ func (self *SRegion) deleteClassicLoadbalancerListener(lbid string, listenerId s
return fmt.Sprintf("%.f", _requestId), nil
}
// 返回requestID
// 返回requestID
func (self *SRegion) DeleteLoadbalancerListener(t LB_TYPE, lbid string, listenerId string) (string, error) {
ctx := context.Background()
lockman.LockRawObject(ctx, "qcloud.SRegion.DeleteLoadbalancerListener", self.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SRegion.DeleteLoadbalancerListener", self.client.ownerId)
if len(lbid) == 0 {
return "", fmt.Errorf("loadbalancer id should not be empty")
}
@@ -22,7 +22,6 @@ import (
"yunion.io/x/jsonutils"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
)
@@ -44,9 +43,6 @@ type SLBListenerRule struct {
// https://cloud.tencent.com/document/api/214/30688
func (self *SLBListenerRule) Delete(ctx context.Context) error {
lockman.LockRawObject(ctx, "qcloud.SLBListenerRule.Delete", self.listener.lb.region.client.ownerId)
defer lockman.ReleaseRawObject(ctx, "qcloud.SLBListenerRule.Delete", self.listener.lb.region.client.ownerId)
_, err := self.listener.lb.region.DeleteLBListenerRule(self.listener.lb.GetId(), self.listener.GetId(), self.GetId())
if err != nil {
return err
+5
View File
@@ -17,6 +17,7 @@ package remotefile
import (
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/pkg/utils"
)
type SEip struct {
@@ -25,6 +26,7 @@ type SEip struct {
IpAddr string
RegionId string
AssociateId string
Mode string
Bandwidth int
}
@@ -33,6 +35,9 @@ func (self *SEip) GetIpAddr() string {
}
func (self *SEip) GetMode() string {
if utils.IsInStringArray(self.Mode, []string{api.EIP_MODE_STANDALONE_EIP, api.EIP_MODE_INSTANCE_PUBLICIP}) {
return self.Mode
}
return api.EIP_MODE_STANDALONE_EIP
}