Skip to content

Commit 9b1b60c

Browse files
authored
fix(region): support ocean base (#23586)
1 parent 9951c7b commit 9b1b60c

File tree

23 files changed

+2061
-35
lines changed

23 files changed

+2061
-35
lines changed

cmd/climc/shell/compute/cloudaccounts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func init() {
6363
cmd.CreateWithKeyword("create-oracle", &options.SOracleCloudAccountCreateOptions{})
6464
cmd.CreateWithKeyword("create-cephfs", &options.SCephFSCloudAccountCreateOptions{})
6565
cmd.CreateWithKeyword("create-cnware", &options.SCNwareCloudAccountCreateOptions{})
66+
cmd.CreateWithKeyword("create-oceanbase", &options.SOceanbaseCloudAccountCreateOptions{})
6667

6768
cmd.UpdateWithKeyword("update-vmware", &options.SVMwareCloudAccountUpdateOptions{})
6869
cmd.UpdateWithKeyword("update-aliyun", &options.SAliyunCloudAccountUpdateOptions{})
@@ -90,6 +91,7 @@ func init() {
9091
cmd.UpdateWithKeyword("update-cucloud", &options.SCucloudCloudAccountUpdateOptions{})
9192
cmd.UpdateWithKeyword("update-qingcloud", &options.SQingCloudCloudAccountUpdateOptions{})
9293
cmd.UpdateWithKeyword("update-cnware", &options.SCNwareCloudAccountUpdateOptions{})
94+
cmd.UpdateWithKeyword("update-oceanbase", &options.SOceanbaseCloudAccountUpdateOptions{})
9395

9496
cmd.Perform("update-credential", &options.CloudaccountUpdateCredentialOptions{})
9597

@@ -136,6 +138,7 @@ func init() {
136138
cmd.PerformWithKeyword("test-connectivity-ctyun", "test-connectivity", &options.SCtyunCloudAccountUpdateCredentialOptions{})
137139
cmd.PerformWithKeyword("test-connectivity-jdcloud", "test-connectivity", &options.SJDcloudCloudAccountUpdateCredentialOptions{})
138140
cmd.PerformWithKeyword("test-connectivity-cloudpods", "test-connectivity", &options.SCloudpodsCloudAccountUpdateCredentialOptions{})
141+
cmd.PerformWithKeyword("test-connectivity-oceanbase", "test-connectivity", &options.SOceanbaseCloudAccountUpdateCredentialOptions{})
139142

140143
cmd.Perform("enable", &options.SCloudAccountIdOptions{})
141144
cmd.Perform("disable", &options.SCloudAccountIdOptions{})

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ require (
9797
k8s.io/cri-api v0.22.17
9898
k8s.io/klog/v2 v2.20.0
9999
moul.io/http2curl/v2 v2.3.0
100-
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022024155-0af17b1ec9e6
100+
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022062406-17f2571b6fd2
101101
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0
102102
yunion.io/x/jsonutils v1.0.1-0.20250507052344-1abcf4f443b1
103103
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
@@ -239,6 +239,7 @@ require (
239239
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
240240
github.com/huandu/xstrings v1.2.0 // indirect
241241
github.com/huaweicloud/huaweicloud-sdk-go v1.0.26 // indirect
242+
github.com/icholy/digest v1.1.0 // indirect
242243
github.com/imdario/mergo v0.3.6 // indirect
243244
github.com/invopop/jsonschema v0.13.0 // indirect
244245
github.com/jdcloud-api/jdcloud-sdk-go v1.55.0 // indirect
@@ -351,7 +352,6 @@ require (
351352
gopkg.in/inf.v0 v0.9.1 // indirect
352353
gopkg.in/ini.v1 v1.62.0 // indirect
353354
gopkg.in/yaml.v3 v3.0.1 // indirect
354-
gotest.tools/v3 v3.5.1 // indirect
355355
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
356356
sigs.k8s.io/structured-merge-diff/v4 v4.0.1 // indirect
357357
sigs.k8s.io/yaml v1.2.0 // indirect

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63
566566
github.com/huaweicloud/huaweicloud-sdk-go v1.0.26 h1:aWTl4Ng9lZUW1DupYyqYiqkTwuTKMmqUZBKLmX0iWxo=
567567
github.com/huaweicloud/huaweicloud-sdk-go v1.0.26/go.mod h1:YHXxw/bm7AohI4jTY8Z43JYw+DPCDLqjxoLTqmcyja4=
568568
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
569+
github.com/icholy/digest v1.1.0 h1:HfGg9Irj7i+IX1o1QAmPfIBNu/Q5A5Tu3n/MED9k9H4=
570+
github.com/icholy/digest v1.1.0/go.mod h1:QNrsSGQ5v7v9cReDI0+eyjsXGUoRSUZQHeQ5C4XLa0Y=
569571
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
570572
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
571573
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
@@ -1431,6 +1433,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
14311433
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14321434
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
14331435
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1436+
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
14341437
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
14351438
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
14361439
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
@@ -1470,8 +1473,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
14701473
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
14711474
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
14721475
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
1473-
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022024155-0af17b1ec9e6 h1:rClhWP2jjm9IZG2+c8ixOgR5RXeLHh+GFiFsrmmcKk4=
1474-
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022024155-0af17b1ec9e6/go.mod h1:qn8eC11Gn4/41YJRzQcwB/G1Z3rQRxRrDNC8LDvQR48=
1476+
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022062406-17f2571b6fd2 h1:jLYvF9XjLII4t1eDGhWvE0pGgq3ec7/3mdIrwrHr0GQ=
1477+
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20251022062406-17f2571b6fd2/go.mod h1:nya/IL1IXSMmFgB48P27CppyGpkT5coG150PD+xVJrc=
14751478
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 h1:msG4SiDSVU7CrXH06WuHlNEZXIooTcmNbfrIGHuIHBU=
14761479
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
14771480
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=

pkg/apis/compute/cloudaccount_const.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const (
7777
CLOUD_PROVIDER_CAS = compute.CLOUD_PROVIDER_CAS
7878
CLOUD_PROVIDER_CLOUDFLARE = compute.CLOUD_PROVIDER_CLOUDFLARE
7979
CLOUD_PROVIDER_CNWARE = compute.CLOUD_PROVIDER_CNWARE
80+
CLOUD_PROVIDER_OCEANBASE = compute.CLOUD_PROVIDER_OCEANBASE
8081

8182
CLOUD_PROVIDER_GENERICS3 = compute.CLOUD_PROVIDER_GENERICS3
8283
CLOUD_PROVIDER_CEPH = compute.CLOUD_PROVIDER_CEPH
@@ -186,6 +187,7 @@ var (
186187
CLOUD_PROVIDER_CAS,
187188
CLOUD_PROVIDER_CLOUDFLARE,
188189
CLOUD_PROVIDER_CNWARE,
190+
CLOUD_PROVIDER_OCEANBASE,
189191
}
190192

191193
CLOUD_PROVIDER_HOST_TYPE_MAP = map[string][]string{

pkg/compute/models/dbinstances.go

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,13 +1623,13 @@ func (self *SDBInstance) SetZoneIds(extInstance cloudprovider.ICloudDBInstance)
16231623
return errors.Wrapf(err, "GetZones")
16241624
}
16251625
var setZoneId = func(input string, output *string) {
1626+
*output = input
16261627
for _, zone := range zones {
16271628
if strings.HasSuffix(zone.ExternalId, input) {
16281629
*output = zone.Id
16291630
break
16301631
}
16311632
}
1632-
return
16331633
}
16341634
zone1 := extInstance.GetZone1Id()
16351635
if len(zone1) > 0 {
@@ -1705,26 +1705,13 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
17051705
self.CreatedAt = createdAt
17061706
}
17071707

1708-
if len(self.VpcId) == 0 {
1709-
if vpcId := ext.GetIVpcId(); len(vpcId) > 0 {
1710-
vpc, err := db.FetchByExternalIdAndManagerId(VpcManager, vpcId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
1711-
return q.Equals("manager_id", provider.Id)
1712-
})
1713-
if err != nil {
1714-
log.Errorf("FetchVpcId(%s) error: %v", vpcId, err)
1715-
} else {
1716-
self.VpcId = vpc.GetId()
1717-
}
1718-
}
1719-
}
1720-
if len(self.VpcId) == 0 {
1721-
region, err := self.GetRegion()
1722-
if err != nil {
1723-
return err
1724-
}
1725-
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(ctx, provider, region)
1708+
if vpcId := ext.GetIVpcId(); len(vpcId) > 0 {
1709+
self.VpcId = vpcId
1710+
vpc, err := db.FetchByExternalIdAndManagerId(VpcManager, vpcId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
1711+
return q.Equals("manager_id", provider.Id)
1712+
})
17261713
if err != nil {
1727-
log.Errorf("failed to create classic vpc for region %s error: %v", region.Name, err)
1714+
log.Errorf("FetchVpcId(%s) error: %v", vpcId, err)
17281715
} else {
17291716
self.VpcId = vpc.GetId()
17301717
}
@@ -1792,6 +1779,7 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
17921779
instance.SetZoneIds(extInstance)
17931780

17941781
if vpcId := extInstance.GetIVpcId(); len(vpcId) > 0 {
1782+
instance.VpcId = vpcId
17951783
vpc, err := db.FetchByExternalIdAndManagerId(VpcManager, vpcId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
17961784
return q.Equals("manager_id", provider.Id)
17971785
})
@@ -1801,14 +1789,6 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
18011789
instance.VpcId = vpc.GetId()
18021790
}
18031791
}
1804-
if len(instance.VpcId) == 0 {
1805-
vpc, err := VpcManager.GetOrCreateVpcForClassicNetwork(ctx, provider, region)
1806-
if err != nil {
1807-
log.Errorf("failed to create classic vpc for region %s error: %v", region.Name, err)
1808-
} else {
1809-
instance.VpcId = vpc.GetId()
1810-
}
1811-
}
18121792

18131793
if createdAt := extInstance.GetCreatedAt(); !createdAt.IsZero() {
18141794
instance.CreatedAt = createdAt
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2019 Yunion
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package regiondrivers
16+
17+
import (
18+
api "yunion.io/x/onecloud/pkg/apis/compute"
19+
"yunion.io/x/onecloud/pkg/compute/models"
20+
)
21+
22+
type SOceanbaseRegionDriver struct {
23+
SManagedVirtualizationRegionDriver
24+
}
25+
26+
func init() {
27+
driver := SOceanbaseRegionDriver{}
28+
models.RegisterRegionDriver(&driver)
29+
}
30+
31+
func (self *SOceanbaseRegionDriver) GetProvider() string {
32+
return api.CLOUD_PROVIDER_OCEANBASE
33+
}

pkg/mcclient/options/compute/cloudaccounts.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,3 +1599,33 @@ type SCNwareCloudAccountUpdateOptions struct {
15991599
func (opts *SCNwareCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
16001600
return jsonutils.Marshal(opts), nil
16011601
}
1602+
1603+
type SOceanbaseCloudAccountCreateOptions struct {
1604+
SCloudAccountCreateBaseOptions
1605+
SAccessKeyCredential
1606+
}
1607+
1608+
func (opts *SOceanbaseCloudAccountCreateOptions) Params() (jsonutils.JSONObject, error) {
1609+
params := jsonutils.Marshal(opts)
1610+
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("OceanBase"), "provider")
1611+
return params, nil
1612+
}
1613+
1614+
type SOceanbaseCloudAccountUpdateOptions struct {
1615+
SCloudAccountUpdateBaseOptions
1616+
}
1617+
1618+
func (opts *SOceanbaseCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
1619+
params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
1620+
1621+
return params, nil
1622+
}
1623+
1624+
type SOceanbaseCloudAccountUpdateCredentialOptions struct {
1625+
SCloudAccountIdOptions
1626+
SAccessKeyCredential
1627+
}
1628+
1629+
func (opts *SOceanbaseCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
1630+
return jsonutils.Marshal(opts), nil
1631+
}

vendor/github.com/icholy/digest/.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/icholy/digest/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)