mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix(region): create disk with tags (#22832)
This commit is contained in:
@@ -95,7 +95,7 @@ require (
|
||||
k8s.io/cri-api v0.22.17
|
||||
k8s.io/klog/v2 v2.20.0
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250703065545-99af7a58eb9e
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250704072708-d4757966c574
|
||||
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0
|
||||
yunion.io/x/jsonutils v1.0.1-0.20250507052344-1abcf4f443b1
|
||||
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
|
||||
|
||||
@@ -1406,8 +1406,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.20250703065545-99af7a58eb9e h1:JERk+MVavD5m9Bnk+gALIWpjkbegqKnb/pYP31fPm5I=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250703065545-99af7a58eb9e/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250704072708-d4757966c574 h1:kglRbPc1P9I7rt3DP7O4pc8ji2JqVvZ4GSD+j52fwSI=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250704072708-d4757966c574/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ=
|
||||
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 h1:msG4SiDSVU7CrXH06WuHlNEZXIooTcmNbfrIGHuIHBU=
|
||||
yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -259,7 +259,7 @@ func (self *SManagedVirtualizationHostDriver) RequestAllocateDiskOnStorage(ctx c
|
||||
logclient.AddSimpleActionLog(disk, logclient.ACT_SYNC_CLOUD_PROJECT, err, userCred, false)
|
||||
}
|
||||
}
|
||||
conf := cloudprovider.DiskCreateConfig{
|
||||
opts := cloudprovider.DiskCreateConfig{
|
||||
Name: disk.GetName(),
|
||||
SizeGb: input.DiskSizeMb >> 10,
|
||||
ProjectId: projectId,
|
||||
@@ -267,7 +267,9 @@ func (self *SManagedVirtualizationHostDriver) RequestAllocateDiskOnStorage(ctx c
|
||||
Throughput: disk.Throughput,
|
||||
Desc: disk.Description,
|
||||
}
|
||||
iDisk, err := iCloudStorage.CreateIDisk(&conf)
|
||||
opts.Tags, _ = disk.GetAllUserMetadata()
|
||||
|
||||
iDisk, err := iCloudStorage.CreateIDisk(&opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2028,7 +2028,7 @@ func (self *SGuest) PerformCreatedisk(ctx context.Context, userCred mcclient.Tok
|
||||
lockman.LockObject(ctx, host)
|
||||
defer lockman.ReleaseObject(ctx, host)
|
||||
|
||||
err = self.CreateDisksOnHost(ctx, userCred, host, disksConf, pendingUsage, false, false, nil, nil, false)
|
||||
err = self.CreateDisksOnHost(ctx, userCred, host, disksConf, pendingUsage, false, options.Options.UseServerTagsForDisk, nil, nil, false)
|
||||
if err != nil {
|
||||
quotas.CancelPendingUsage(ctx, userCred, pendingUsage, pendingUsage, false)
|
||||
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_CREATE, err.Error(), userCred, false)
|
||||
|
||||
@@ -202,6 +202,9 @@ type ComputeOptions struct {
|
||||
// 修改标签时不再同步至云上, 云账号同步资源时不会冲掉本地打的标签(key相同的会覆盖), 云账号开启只读同步和此参数效果相同,且仅影响开启只读同步的账号
|
||||
KeepTagLocalization bool `help:"keep tag localization, not synchronized to the cloud" default:"false"`
|
||||
|
||||
// 调整虚拟机配置时,新增磁盘使用虚拟机标签
|
||||
UseServerTagsForDisk bool `help:"use server tags for disk" default:"true"`
|
||||
|
||||
EnableMonitorAgent bool `help:"enable public cloud vm monitor agent" default:"false"`
|
||||
|
||||
EnableTlsMigration bool `help:"Enable TLS migration" default:"false"`
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
taskutils "yunion.io/x/onecloud/pkg/compute/tasks/utils"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
@@ -203,7 +204,7 @@ func (task *GuestChangeConfigTask) DoCreateDisksTask(ctx context.Context, guest
|
||||
|
||||
disks := confs.Create
|
||||
host, _ := guest.GetHost()
|
||||
err = guest.CreateDisksOnHost(ctx, task.UserCred, host, disks, nil, false, false, nil, nil, false)
|
||||
err = guest.CreateDisksOnHost(ctx, task.UserCred, host, disks, nil, false, options.Options.UseServerTagsForDisk, nil, nil, false)
|
||||
if err != nil {
|
||||
task.markStageFailed(ctx, guest, jsonutils.NewString(err.Error()))
|
||||
return
|
||||
|
||||
Vendored
+1
-1
@@ -1849,7 +1849,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.20250703065545-99af7a58eb9e
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250704072708-d4757966c574
|
||||
## explicit; go 1.21
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+32
-32
@@ -68,12 +68,12 @@ type CdnCreateOptions struct {
|
||||
// +onecloud:model-api-gen
|
||||
type SCdnOrigins []SCdnOrigin
|
||||
|
||||
func (self SCdnOrigins) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (origins SCdnOrigins) IsZero() bool {
|
||||
return len(origins) == 0
|
||||
}
|
||||
|
||||
func (self SCdnOrigins) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (origins SCdnOrigins) String() string {
|
||||
return jsonutils.Marshal(origins).String()
|
||||
}
|
||||
|
||||
// 是否忽略参数
|
||||
@@ -102,12 +102,12 @@ type CacheKeyRuleQueryString struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func (self SCDNCacheKeys) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNCacheKeys{})
|
||||
func (keys SCDNCacheKeys) IsZero() bool {
|
||||
return jsonutils.Marshal(keys) == jsonutils.Marshal(&SCDNCacheKeys{})
|
||||
}
|
||||
|
||||
func (self SCDNCacheKeys) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (keys SCDNCacheKeys) String() string {
|
||||
return jsonutils.Marshal(keys).String()
|
||||
}
|
||||
|
||||
// 是否分片回源
|
||||
@@ -123,12 +123,12 @@ type SRangeOriginPullRule struct {
|
||||
RulePaths []string
|
||||
}
|
||||
|
||||
func (self SCDNRangeOriginPull) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNRangeOriginPull{})
|
||||
func (pull SCDNRangeOriginPull) IsZero() bool {
|
||||
return jsonutils.Marshal(pull) == jsonutils.Marshal(&SCDNRangeOriginPull{})
|
||||
}
|
||||
|
||||
func (self SCDNRangeOriginPull) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (pull SCDNRangeOriginPull) String() string {
|
||||
return jsonutils.Marshal(pull).String()
|
||||
}
|
||||
|
||||
type CacheRule struct {
|
||||
@@ -181,12 +181,12 @@ type RuleCacheConfig struct {
|
||||
}
|
||||
}
|
||||
|
||||
func (self SCDNCache) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNCache{})
|
||||
func (cache SCDNCache) IsZero() bool {
|
||||
return jsonutils.Marshal(cache) == jsonutils.Marshal(&SCDNCache{})
|
||||
}
|
||||
|
||||
func (self SCDNCache) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (cache SCDNCache) String() string {
|
||||
return jsonutils.Marshal(cache).String()
|
||||
}
|
||||
|
||||
// +onecloud:model-api-gen
|
||||
@@ -197,12 +197,12 @@ type SCDNHttps struct {
|
||||
Http2 *bool
|
||||
}
|
||||
|
||||
func (self SCDNHttps) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNHttps{})
|
||||
func (https SCDNHttps) IsZero() bool {
|
||||
return jsonutils.Marshal(https) == jsonutils.Marshal(&SCDNHttps{})
|
||||
}
|
||||
|
||||
func (self SCDNHttps) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (https SCDNHttps) String() string {
|
||||
return jsonutils.Marshal(https).String()
|
||||
}
|
||||
|
||||
// +onecloud:model-api-gen
|
||||
@@ -214,12 +214,12 @@ type SCDNForceRedirect struct {
|
||||
RedirectType string
|
||||
}
|
||||
|
||||
func (self SCDNForceRedirect) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNForceRedirect{})
|
||||
func (redirect SCDNForceRedirect) IsZero() bool {
|
||||
return jsonutils.Marshal(redirect) == jsonutils.Marshal(&SCDNForceRedirect{})
|
||||
}
|
||||
|
||||
func (self SCDNForceRedirect) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (redirect SCDNForceRedirect) String() string {
|
||||
return jsonutils.Marshal(redirect).String()
|
||||
}
|
||||
|
||||
type RefererRule struct {
|
||||
@@ -243,12 +243,12 @@ type SCDNReferer struct {
|
||||
RefererRules []RefererRule
|
||||
}
|
||||
|
||||
func (self SCDNReferer) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNReferer{})
|
||||
func (referer SCDNReferer) IsZero() bool {
|
||||
return jsonutils.Marshal(referer) == jsonutils.Marshal(&SCDNReferer{})
|
||||
}
|
||||
|
||||
func (self SCDNReferer) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (referer SCDNReferer) String() string {
|
||||
return jsonutils.Marshal(referer).String()
|
||||
}
|
||||
|
||||
type SMaxAgeRule struct {
|
||||
@@ -265,12 +265,12 @@ type SCDNMaxAge struct {
|
||||
MaxAgeRules []SMaxAgeRule
|
||||
}
|
||||
|
||||
func (self SCDNMaxAge) IsZero() bool {
|
||||
return jsonutils.Marshal(self) == jsonutils.Marshal(&SCDNMaxAge{})
|
||||
func (maxAge SCDNMaxAge) IsZero() bool {
|
||||
return jsonutils.Marshal(maxAge) == jsonutils.Marshal(&SCDNMaxAge{})
|
||||
}
|
||||
|
||||
func (self SCDNMaxAge) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (maxAge SCDNMaxAge) String() string {
|
||||
return jsonutils.Marshal(maxAge).String()
|
||||
}
|
||||
|
||||
type CacheClearOptions struct {
|
||||
|
||||
+48
-48
@@ -427,7 +427,7 @@ func GetProviderFactory(provider string) (ICloudProviderFactory, error) {
|
||||
if ok {
|
||||
return factory, nil
|
||||
}
|
||||
return nil, fmt.Errorf("No such provider %s", provider)
|
||||
return nil, fmt.Errorf("no such provider %s", provider)
|
||||
}
|
||||
|
||||
func GetRegistedProviderIds() []string {
|
||||
@@ -475,183 +475,183 @@ type SBaseProvider struct {
|
||||
factory ICloudProviderFactory
|
||||
}
|
||||
|
||||
func (provider *SBaseProvider) GetFactory() ICloudProviderFactory {
|
||||
return provider.factory
|
||||
func (base *SBaseProvider) GetFactory() ICloudProviderFactory {
|
||||
return base.factory
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetOnPremiseIRegion() (ICloudRegion, error) {
|
||||
func (base *SBaseProvider) GetOnPremiseIRegion() (ICloudRegion, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIamLoginUrl() string {
|
||||
func (base *SBaseProvider) GetIamLoginUrl() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) IsClouduserSupportPassword() bool {
|
||||
func (base *SBaseProvider) IsClouduserSupportPassword() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudusers() ([]IClouduser, error) {
|
||||
func (base *SBaseProvider) GetICloudusers() ([]IClouduser, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudgroups() ([]ICloudgroup, error) {
|
||||
func (base *SBaseProvider) GetICloudgroups() ([]ICloudgroup, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudgroupByName(name string) (ICloudgroup, error) {
|
||||
func (base *SBaseProvider) GetICloudgroupByName(name string) (ICloudgroup, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudgroup(name, desc string) (ICloudgroup, error) {
|
||||
func (base *SBaseProvider) CreateICloudgroup(name, desc string) (ICloudgroup, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudpolicies() ([]ICloudpolicy, error) {
|
||||
func (base *SBaseProvider) GetICloudpolicies() ([]ICloudpolicy, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIClouduserByName(name string) (IClouduser, error) {
|
||||
func (base *SBaseProvider) GetIClouduserByName(name string) (IClouduser, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateIClouduser(conf *SClouduserCreateConfig) (IClouduser, error) {
|
||||
func (base *SBaseProvider) CreateIClouduser(conf *SClouduserCreateConfig) (IClouduser, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudSAMLProviders() ([]ICloudSAMLProvider, error) {
|
||||
func (base *SBaseProvider) GetICloudSAMLProviders() ([]ICloudSAMLProvider, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudSAMLProviders")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudroles() ([]ICloudrole, error) {
|
||||
func (base *SBaseProvider) GetICloudroles() ([]ICloudrole, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudroles")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudroleById(id string) (ICloudrole, error) {
|
||||
func (base *SBaseProvider) GetICloudroleById(id string) (ICloudrole, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudroleById")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudroleByName(name string) (ICloudrole, error) {
|
||||
func (base *SBaseProvider) GetICloudroleByName(name string) (ICloudrole, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudroleByName")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudrole(opts *SRoleCreateOptions) (ICloudrole, error) {
|
||||
func (base *SBaseProvider) CreateICloudrole(opts *SRoleCreateOptions) (ICloudrole, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateICloudrole")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudSAMLProvider(opts *SAMLProviderCreateOptions) (ICloudSAMLProvider, error) {
|
||||
func (base *SBaseProvider) CreateICloudSAMLProvider(opts *SAMLProviderCreateOptions) (ICloudSAMLProvider, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateICloudSAMLProvider")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudpolicy(opts *SCloudpolicyCreateOptions) (ICloudpolicy, error) {
|
||||
func (base *SBaseProvider) CreateICloudpolicy(opts *SCloudpolicyCreateOptions) (ICloudpolicy, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetEnrollmentAccounts() ([]SEnrollmentAccount, error) {
|
||||
func (base *SBaseProvider) GetEnrollmentAccounts() ([]SEnrollmentAccount, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateSubscription(SubscriptionCreateInput) error {
|
||||
func (base *SBaseProvider) CreateSubscription(SubscriptionCreateInput) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudDnsZones() ([]ICloudDnsZone, error) {
|
||||
func (base *SBaseProvider) GetICloudDnsZones() ([]ICloudDnsZone, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudDnsZoneById(id string) (ICloudDnsZone, error) {
|
||||
func (base *SBaseProvider) GetICloudDnsZoneById(id string) (ICloudDnsZone, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudDnsZone(opts *SDnsZoneCreateOptions) (ICloudDnsZone, error) {
|
||||
func (base *SBaseProvider) CreateICloudDnsZone(opts *SDnsZoneCreateOptions) (ICloudDnsZone, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return self.factory.GetId()
|
||||
func (base *SBaseProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return base.factory.GetId()
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateIProject(name string) (ICloudProject, error) {
|
||||
func (base *SBaseProvider) CreateIProject(name string) (ICloudProject, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetSamlEntityId() string {
|
||||
func (base *SBaseProvider) GetSamlEntityId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetSamlSpInitiatedLoginUrl(idpName string) string {
|
||||
func (base *SBaseProvider) GetSamlSpInitiatedLoginUrl(idpName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudInterVpcNetworks() ([]ICloudInterVpcNetwork, error) {
|
||||
func (base *SBaseProvider) GetICloudInterVpcNetworks() ([]ICloudInterVpcNetwork, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudInterVpcNetworkById(id string) (ICloudInterVpcNetwork, error) {
|
||||
func (base *SBaseProvider) GetICloudInterVpcNetworkById(id string) (ICloudInterVpcNetwork, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudInterVpcNetwork(opts *SInterVpcNetworkCreateOptions) (ICloudInterVpcNetwork, error) {
|
||||
func (base *SBaseProvider) CreateICloudInterVpcNetwork(opts *SInterVpcNetworkCreateOptions) (ICloudInterVpcNetwork, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudGlobalVpcs() ([]ICloudGlobalVpc, error) {
|
||||
func (base *SBaseProvider) GetICloudGlobalVpcs() ([]ICloudGlobalVpc, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudGlobalVpcs")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudGlobalVpcById(id string) (ICloudGlobalVpc, error) {
|
||||
func (base *SBaseProvider) GetICloudGlobalVpcById(id string) (ICloudGlobalVpc, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudGlobalVpcById")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudGlobalVpc(opts *GlobalVpcCreateOptions) (ICloudGlobalVpc, error) {
|
||||
func (base *SBaseProvider) CreateICloudGlobalVpc(opts *GlobalVpcCreateOptions) (ICloudGlobalVpc, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateICloudGlobalVpc")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudCDNDomains() ([]ICloudCDNDomain, error) {
|
||||
func (base *SBaseProvider) GetICloudCDNDomains() ([]ICloudCDNDomain, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudCDNDomains")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetICloudCDNDomainByName(name string) (ICloudCDNDomain, error) {
|
||||
func (base *SBaseProvider) GetICloudCDNDomainByName(name string) (ICloudCDNDomain, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetICloudCDNDomainByName")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateICloudCDNDomain(opts *CdnCreateOptions) (ICloudCDNDomain, error) {
|
||||
func (base *SBaseProvider) CreateICloudCDNDomain(opts *CdnCreateOptions) (ICloudCDNDomain, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateICloudCDNDomain")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetMetrics(opts *MetricListOptions) ([]MetricValues, error) {
|
||||
func (base *SBaseProvider) GetMetrics(opts *MetricListOptions) ([]MetricValues, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetMetric")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIModelartsPools() ([]ICloudModelartsPool, error) {
|
||||
func (base *SBaseProvider) GetIModelartsPools() ([]ICloudModelartsPool, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetIModelartsPools")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIModelartsPoolById(id string) (ICloudModelartsPool, error) {
|
||||
func (base *SBaseProvider) GetIModelartsPoolById(id string) (ICloudModelartsPool, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetIModelartsPoolDetail")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateIModelartsPool(pool *ModelartsPoolCreateOption, callback func(id string)) (ICloudModelartsPool, error) {
|
||||
func (base *SBaseProvider) CreateIModelartsPool(pool *ModelartsPoolCreateOption, callback func(id string)) (ICloudModelartsPool, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateIModelartsPool")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIModelartsPoolSku() ([]ICloudModelartsPoolSku, error) {
|
||||
func (base *SBaseProvider) GetIModelartsPoolSku() ([]ICloudModelartsPoolSku, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetIModelartsPoolSku")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetISSLCertificates() ([]ICloudSSLCertificate, error) {
|
||||
func (base *SBaseProvider) GetISSLCertificates() ([]ICloudSSLCertificate, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetISSLCertificates")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIAiGateways() ([]IAiGateway, error) {
|
||||
func (base *SBaseProvider) GetIAiGateways() ([]IAiGateway, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetIAiGateways")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetIAiGatewayById(id string) (IAiGateway, error) {
|
||||
func (base *SBaseProvider) GetIAiGatewayById(id string) (IAiGateway, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "GetIAiGateways")
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateIAiGateway(opts *AiGatewayCreateOptions) (IAiGateway, error) {
|
||||
func (base *SBaseProvider) CreateIAiGateway(opts *AiGatewayCreateOptions) (IAiGateway, error) {
|
||||
return nil, errors.Wrapf(ErrNotImplemented, "CreateIAiGateway")
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -21,4 +21,8 @@ type DiskCreateConfig struct {
|
||||
Iops int
|
||||
Throughput int
|
||||
ProjectId string
|
||||
SnapshotId string
|
||||
ImageId string
|
||||
|
||||
Tags map[string]string
|
||||
}
|
||||
|
||||
+7
-7
@@ -85,10 +85,10 @@ type SHCSOEndpoints struct {
|
||||
Modelarts string `default:"$HUAWEI_MODELARTS_ENDPOINT"`
|
||||
}
|
||||
|
||||
func (self *SHCSOEndpoints) GetEndpoint(defaultRegion, serviceName string, region string) string {
|
||||
func (endpoints *SHCSOEndpoints) GetEndpoint(defaultRegion, serviceName string, region string) string {
|
||||
sn := utils.Kebab2Camel(serviceName, "-")
|
||||
if self.caches == nil {
|
||||
self.caches = make(map[string]string, 0)
|
||||
if endpoints.caches == nil {
|
||||
endpoints.caches = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
key := defaultRegion + "." + sn
|
||||
@@ -96,12 +96,12 @@ func (self *SHCSOEndpoints) GetEndpoint(defaultRegion, serviceName string, regio
|
||||
key = region + "." + sn
|
||||
}
|
||||
|
||||
if endpoint, ok := self.caches[key]; ok && len(endpoint) > 0 {
|
||||
if endpoint, ok := endpoints.caches[key]; ok && len(endpoint) > 0 {
|
||||
return endpoint
|
||||
}
|
||||
|
||||
var endpoint string
|
||||
fileds := reflect.Indirect(reflect.ValueOf(self))
|
||||
fileds := reflect.Indirect(reflect.ValueOf(endpoints))
|
||||
f := fileds.FieldByNameFunc(func(c string) bool {
|
||||
return c == sn
|
||||
})
|
||||
@@ -111,13 +111,13 @@ func (self *SHCSOEndpoints) GetEndpoint(defaultRegion, serviceName string, regio
|
||||
}
|
||||
|
||||
if len(endpoint) == 0 {
|
||||
endpoint = strings.Join([]string{serviceName, defaultRegion, self.EndpointDomain}, ".")
|
||||
endpoint = strings.Join([]string{serviceName, defaultRegion, endpoints.EndpointDomain}, ".")
|
||||
}
|
||||
|
||||
if len(region) > 0 {
|
||||
endpoint = strings.Replace(endpoint, defaultRegion, region, 1)
|
||||
}
|
||||
|
||||
self.caches[key] = endpoint
|
||||
endpoints.caches[key] = endpoint
|
||||
return endpoint
|
||||
}
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ type SGeographicInfo struct {
|
||||
CountryCode string `list:"user" width:"4" update:"admin" create:"admin_optional"`
|
||||
}
|
||||
|
||||
func (self SGeographicInfo) IsEquals(geo SGeographicInfo) bool {
|
||||
return self.City == geo.City && self.CountryCode == geo.CountryCode &&
|
||||
self.Latitude-geo.Latitude < 0.01 && self.Longitude-geo.Longitude < 0.01
|
||||
func (geo SGeographicInfo) IsEquals(other SGeographicInfo) bool {
|
||||
return geo.City == other.City && geo.CountryCode == other.CountryCode &&
|
||||
geo.Latitude-other.Latitude < 0.01 && geo.Longitude-other.Longitude < 0.01
|
||||
}
|
||||
|
||||
+11
-12
@@ -28,26 +28,25 @@ func NewSModelI18nEntry(value string) *SModelI18nEntry {
|
||||
return &SModelI18nEntry{Value: value, valueI18n: vn}
|
||||
}
|
||||
|
||||
func (self *SModelI18nEntry) GetKeyValue() string {
|
||||
return self.Value
|
||||
func (entry *SModelI18nEntry) GetKeyValue() string {
|
||||
return entry.Value
|
||||
}
|
||||
|
||||
func (self *SModelI18nEntry) Lookup(tag language.Tag) string {
|
||||
if v, ok := self.valueI18n[tag]; ok {
|
||||
func (entry *SModelI18nEntry) Lookup(tag language.Tag) string {
|
||||
if v, ok := entry.valueI18n[tag]; ok {
|
||||
return v
|
||||
}
|
||||
|
||||
return self.Value
|
||||
return entry.Value
|
||||
}
|
||||
|
||||
func (self *SModelI18nEntry) CN(v string) *SModelI18nEntry {
|
||||
self.valueI18n[language.Chinese] = v
|
||||
return self
|
||||
func (entry *SModelI18nEntry) CN(v string) *SModelI18nEntry {
|
||||
entry.valueI18n[language.Chinese] = v
|
||||
return entry
|
||||
}
|
||||
|
||||
func (self *SModelI18nEntry) EN(v string) *SModelI18nEntry {
|
||||
self.valueI18n[language.English] = v
|
||||
return self
|
||||
func (entry *SModelI18nEntry) EN(v string) *SModelI18nEntry {
|
||||
entry.valueI18n[language.English] = v
|
||||
return entry
|
||||
}
|
||||
|
||||
type SModelI18nTable map[string]*SModelI18nEntry
|
||||
|
||||
+2
-2
@@ -214,7 +214,7 @@ func (vmConfig *SManagedVMCreateConfig) GetConfig(config *jsonutils.JSONDict) er
|
||||
vmConfig.PublicKey = publicKey
|
||||
}
|
||||
//目前所写的userData格式仅支持Linux
|
||||
if strings.ToLower(vmConfig.OsType) == strings.ToLower(osprofile.OS_TYPE_LINUX) {
|
||||
if strings.EqualFold(vmConfig.OsType, osprofile.OS_TYPE_LINUX) {
|
||||
adminPublicKey, _ := config.GetString("admin_public_key")
|
||||
projectPublicKey, _ := config.GetString("project_public_key")
|
||||
vmConfig.UserData = generateUserData(adminPublicKey, projectPublicKey, vmConfig.UserData)
|
||||
@@ -272,7 +272,7 @@ func (vmConfig *SManagedVMCreateConfig) GetUserData() (string, error) {
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
if strings.ToLower(vmConfig.OsType) == strings.ToLower(osprofile.OS_TYPE_LINUX) {
|
||||
if strings.EqualFold(vmConfig.OsType, osprofile.OS_TYPE_LINUX) {
|
||||
switch vmConfig.UserDataType {
|
||||
case CLOUD_SHELL:
|
||||
return oUserData.UserDataScriptBase64(), nil
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
func IsError(err error, errs []string) bool {
|
||||
for i := range errs {
|
||||
if strings.Index(err.Error(), errs[i]) >= 0 {
|
||||
if strings.Contains(err.Error(), errs[i]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ type RouteTableAssociation struct {
|
||||
AssociatedResourceId string
|
||||
}
|
||||
|
||||
func (self RouteTableAssociation) GetGlobalId() string {
|
||||
return self.AssociationId
|
||||
func (association RouteTableAssociation) GetGlobalId() string {
|
||||
return association.AssociationId
|
||||
}
|
||||
|
||||
type RouteSet struct {
|
||||
|
||||
+6
-6
@@ -54,13 +54,13 @@ type SecurityGroupRuleUpdateOptions struct {
|
||||
Priority int
|
||||
}
|
||||
|
||||
func (self *SecurityGroupRuleCreateOptions) String() string {
|
||||
ret := fmt.Sprintf("%s_%s_%s", self.Direction, self.Action, self.Protocol)
|
||||
if len(self.CIDR) > 0 {
|
||||
ret += "_" + self.CIDR
|
||||
func (rule *SecurityGroupRuleCreateOptions) String() string {
|
||||
ret := fmt.Sprintf("%s_%s_%s", rule.Direction, rule.Action, rule.Protocol)
|
||||
if len(rule.CIDR) > 0 {
|
||||
ret += "_" + rule.CIDR
|
||||
}
|
||||
if len(self.Ports) > 0 {
|
||||
ret += "_" + self.Ports
|
||||
if len(rule.Ports) > 0 {
|
||||
ret += "_" + rule.Ports
|
||||
}
|
||||
ret = strings.ReplaceAll(ret, ".", "_")
|
||||
ret = strings.ReplaceAll(ret, ",", "_")
|
||||
|
||||
+4
-4
@@ -46,12 +46,12 @@ type SubAccounts struct {
|
||||
}
|
||||
}
|
||||
|
||||
func (self SubAccounts) IsZero() bool {
|
||||
return len(self.Accounts) == 0
|
||||
func (accounts SubAccounts) IsZero() bool {
|
||||
return len(accounts.Accounts) == 0
|
||||
}
|
||||
|
||||
func (self SubAccounts) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (accounts SubAccounts) String() string {
|
||||
return jsonutils.Marshal(accounts).String()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
+4
-4
@@ -21,16 +21,16 @@ type transport struct {
|
||||
ts *http.Transport
|
||||
}
|
||||
|
||||
func (self *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
var respCheck func(resp *http.Response) error = nil
|
||||
var err error
|
||||
if self.check != nil {
|
||||
respCheck, err = self.check(req)
|
||||
if t.check != nil {
|
||||
respCheck, err = t.check(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
resp, err := self.ts.RoundTrip(req)
|
||||
resp, err := t.ts.RoundTrip(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+34
-34
@@ -106,22 +106,22 @@ var (
|
||||
|
||||
type TWafMatchFieldValues []string
|
||||
|
||||
func (self TWafMatchFieldValues) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (values TWafMatchFieldValues) IsZero() bool {
|
||||
return len(values) == 0
|
||||
}
|
||||
|
||||
func (self TWafMatchFieldValues) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (values TWafMatchFieldValues) String() string {
|
||||
return jsonutils.Marshal(values).String()
|
||||
}
|
||||
|
||||
type TextTransformations []TWafTextTransformation
|
||||
|
||||
func (self TextTransformations) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (transformations TextTransformations) IsZero() bool {
|
||||
return len(transformations) == 0
|
||||
}
|
||||
|
||||
func (self TextTransformations) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (transformations TextTransformations) String() string {
|
||||
return jsonutils.Marshal(transformations).String()
|
||||
}
|
||||
|
||||
type SExcludeRule struct {
|
||||
@@ -130,12 +130,12 @@ type SExcludeRule struct {
|
||||
|
||||
type SExcludeRules []SExcludeRule
|
||||
|
||||
func (self SExcludeRules) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (rules SExcludeRules) IsZero() bool {
|
||||
return len(rules) == 0
|
||||
}
|
||||
|
||||
func (self SExcludeRules) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (rules SExcludeRules) String() string {
|
||||
return jsonutils.Marshal(rules).String()
|
||||
}
|
||||
|
||||
type SWafRule struct {
|
||||
@@ -185,22 +185,22 @@ type SWafStatement struct {
|
||||
RuleGroupId string `width:"36" charset:"ascii" nullable:"false" list:"user"`
|
||||
}
|
||||
|
||||
func (self SWafStatement) GetGlobalId() string {
|
||||
func (statement SWafStatement) GetGlobalId() string {
|
||||
id := fmt.Sprintf("%s-%s-%s-%s-%s",
|
||||
self.Type,
|
||||
self.MatchField,
|
||||
self.MatchFieldKey,
|
||||
self.ManagedRuleGroupName,
|
||||
self.SearchString,
|
||||
statement.Type,
|
||||
statement.MatchField,
|
||||
statement.MatchFieldKey,
|
||||
statement.ManagedRuleGroupName,
|
||||
statement.SearchString,
|
||||
)
|
||||
if self.Type == WafStatementTypeGeoMatch || self.Type == WafStatementTypeRate || self.Type == WafStatementTypeLabelMatch {
|
||||
id = fmt.Sprintf("%s-%s", id, self.MatchFieldValues)
|
||||
if statement.Type == WafStatementTypeGeoMatch || statement.Type == WafStatementTypeRate || statement.Type == WafStatementTypeLabelMatch {
|
||||
id = fmt.Sprintf("%s-%s", id, statement.MatchFieldValues)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func (self SWafStatement) GetExternalId() string {
|
||||
return self.GetGlobalId()
|
||||
func (statement SWafStatement) GetExternalId() string {
|
||||
return statement.GetGlobalId()
|
||||
}
|
||||
|
||||
// +onecloud:model-api-gen
|
||||
@@ -223,31 +223,31 @@ type WafSourceIps []string
|
||||
// +onecloud:model-api-gen
|
||||
type WafRegexPatterns []string
|
||||
|
||||
func (self WafRegexPatterns) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (patterns WafRegexPatterns) IsZero() bool {
|
||||
return len(patterns) == 0
|
||||
}
|
||||
|
||||
func (self WafRegexPatterns) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (patterns WafRegexPatterns) String() string {
|
||||
return jsonutils.Marshal(patterns).String()
|
||||
}
|
||||
|
||||
// +onecloud:model-api-gen
|
||||
type WafAddresses []string
|
||||
|
||||
func (self WafAddresses) IsZero() bool {
|
||||
return len(self) == 0
|
||||
func (addresses WafAddresses) IsZero() bool {
|
||||
return len(addresses) == 0
|
||||
}
|
||||
|
||||
func (self WafAddresses) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (addresses WafAddresses) String() string {
|
||||
return jsonutils.Marshal(addresses).String()
|
||||
}
|
||||
|
||||
func (self DefaultAction) IsZero() bool {
|
||||
func (action DefaultAction) IsZero() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self DefaultAction) String() string {
|
||||
return jsonutils.Marshal(self).String()
|
||||
func (action DefaultAction) String() string {
|
||||
return jsonutils.Marshal(action).String()
|
||||
}
|
||||
|
||||
type SCloudResource struct {
|
||||
@@ -264,7 +264,7 @@ type SCloudResource struct {
|
||||
}
|
||||
|
||||
type SCloudResources struct {
|
||||
Data []SCloudResource `json:",allowempty"`
|
||||
Data []SCloudResource `json:"data,allowempty"`
|
||||
Total int
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
func WaitStatusWithSync(res ICloudResource, expect string, sync func(status string), interval time.Duration, timeout time.Duration) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
err := res.Refresh()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -46,7 +46,7 @@ func WaitStatus(res ICloudResource, expect string, interval time.Duration, timeo
|
||||
|
||||
func WaitMultiStatusWithSync(res ICloudResource, expects []string, sync func(string), interval time.Duration, timeout time.Duration) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
err := res.Refresh()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "resource.Refresh()")
|
||||
@@ -77,7 +77,7 @@ func WaitStatusWithDelay(res ICloudResource, expect string, delay time.Duration,
|
||||
|
||||
func WaitStatusWithInstanceErrorCheck(res ICloudResource, expect string, interval time.Duration, timeout time.Duration, errCheck func() error) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
err := res.Refresh()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -102,7 +102,7 @@ func WaitDeletedWithDelay(res ICloudResource, delay time.Duration, interval time
|
||||
|
||||
func WaitDeleted(res ICloudResource, interval time.Duration, timeout time.Duration) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
err := res.Refresh()
|
||||
if err != nil {
|
||||
if errors.Cause(err) == ErrNotFound {
|
||||
@@ -118,7 +118,7 @@ func WaitDeleted(res ICloudResource, interval time.Duration, timeout time.Durati
|
||||
|
||||
func Wait(interval time.Duration, timeout time.Duration, callback func() (bool, error)) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
ok, err := callback()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -133,7 +133,7 @@ func Wait(interval time.Duration, timeout time.Duration, callback func() (bool,
|
||||
|
||||
func WaitCreated(interval time.Duration, timeout time.Duration, callback func() bool) error {
|
||||
startTime := time.Now()
|
||||
for time.Now().Sub(startTime) < timeout {
|
||||
for time.Since(startTime) < timeout {
|
||||
ok := callback()
|
||||
if ok {
|
||||
return nil
|
||||
|
||||
+15
-7
@@ -271,12 +271,12 @@ func (self *SDisk) GetMountpoint() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, desc string, projectId string) (string, error) {
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, opts *cloudprovider.DiskCreateConfig) (string, error) {
|
||||
params := make(map[string]string)
|
||||
params["ZoneId"] = zoneId
|
||||
params["DiskName"] = name
|
||||
if len(desc) > 0 {
|
||||
params["Description"] = desc
|
||||
params["DiskName"] = opts.Name
|
||||
if len(opts.Desc) > 0 {
|
||||
params["Description"] = opts.Desc
|
||||
}
|
||||
params["Encrypted"] = "false"
|
||||
params["DiskCategory"] = category
|
||||
@@ -296,10 +296,18 @@ func (self *SRegion) CreateDisk(zoneId string, category string, name string, siz
|
||||
params["BurstingEnabled"] = "true"
|
||||
}
|
||||
|
||||
if len(projectId) > 0 {
|
||||
params["ResourceGroupId"] = projectId
|
||||
if len(opts.ProjectId) > 0 {
|
||||
params["ResourceGroupId"] = opts.ProjectId
|
||||
}
|
||||
params["Size"] = fmt.Sprintf("%d", sizeGb)
|
||||
|
||||
tagIdx := 1
|
||||
for k, v := range opts.Tags {
|
||||
params[fmt.Sprintf("Tag.%d.Key", tagIdx)] = k
|
||||
params[fmt.Sprintf("Tag.%d.Value", tagIdx)] = v
|
||||
tagIdx += 1
|
||||
}
|
||||
|
||||
params["Size"] = fmt.Sprintf("%d", opts.SizeGb)
|
||||
params["ClientToken"] = utils.GenRequestId(20)
|
||||
|
||||
body, err := self.ecsRequest("CreateDisk", params)
|
||||
|
||||
+2
-2
@@ -142,8 +142,8 @@ func (self *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.zone.region.getStoragecache()
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.ZoneId, self.storageType, conf.Name, conf.SizeGb, conf.Desc, conf.ProjectId)
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.ZoneId, self.storageType, opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "CreateDisk")
|
||||
}
|
||||
|
||||
+30
-17
@@ -240,7 +240,14 @@ func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error)
|
||||
if self.State != "available" {
|
||||
return "", errors.Wrapf(cloudprovider.ErrInvalidStatus, "invalid status %s", self.State)
|
||||
}
|
||||
disk, err := self.storage.zone.region.CreateDisk(self.AvailabilityZone, self.VolumeType, self.GetName(), self.GetDiskSizeMB()/1024, self.Iops, self.Throughput, snapshotId, self.GetDescription())
|
||||
opts := &cloudprovider.DiskCreateConfig{
|
||||
Name: self.GetName(),
|
||||
SizeGb: self.GetDiskSizeMB() / 1024,
|
||||
Iops: self.Iops,
|
||||
Throughput: self.Throughput,
|
||||
SnapshotId: snapshotId,
|
||||
}
|
||||
disk, err := self.storage.zone.region.CreateDisk(self.AvailabilityZone, self.VolumeType, opts)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "CreateDisk")
|
||||
}
|
||||
@@ -353,33 +360,39 @@ func GenDiskIops(diskType string, sizeGB int) int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateDisk(zoneId string, volumeType string, name string, sizeGb, iops, throughput int, snapshotId string, desc string) (*SDisk, error) {
|
||||
func (self *SRegion) CreateDisk(zoneId string, volumeType string, opts *cloudprovider.DiskCreateConfig) (*SDisk, error) {
|
||||
params := map[string]string{
|
||||
"AvailabilityZone": zoneId,
|
||||
"ClientToken": utils.GenRequestId(20),
|
||||
"Size": fmt.Sprintf("%d", sizeGb),
|
||||
"Size": fmt.Sprintf("%d", opts.SizeGb),
|
||||
"VolumeType": volumeType,
|
||||
}
|
||||
tagIdx := 1
|
||||
if len(name) > 0 {
|
||||
params[fmt.Sprintf("TagSpecification.%d.ResourceType", tagIdx)] = "volume"
|
||||
params[fmt.Sprintf("TagSpecification.%d.Tag.1.Key", tagIdx)] = "Name"
|
||||
params[fmt.Sprintf("TagSpecification.%d.Tag.1.Value", tagIdx)] = name
|
||||
if len(desc) > 0 {
|
||||
params[fmt.Sprintf("TagSpecification.%d.Tag.2.Key", tagIdx)] = "Description"
|
||||
params[fmt.Sprintf("TagSpecification.%d.Tag.2.Value", tagIdx)] = desc
|
||||
if len(opts.Name) > 0 {
|
||||
params["TagSpecification.1.ResourceType"] = "volume"
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Key", tagIdx)] = "Name"
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Value", tagIdx)] = opts.Name
|
||||
tagIdx++
|
||||
if len(opts.Desc) > 0 {
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Key", tagIdx)] = "Description"
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Value", tagIdx)] = opts.Desc
|
||||
}
|
||||
}
|
||||
for k, v := range opts.Tags {
|
||||
params["TagSpecification.1.ResourceType"] = "volume"
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Key", tagIdx)] = k
|
||||
params[fmt.Sprintf("TagSpecification.1.Tag.%d.Value", tagIdx)] = v
|
||||
tagIdx++
|
||||
}
|
||||
if len(snapshotId) > 0 {
|
||||
params["SnapshotId"] = snapshotId
|
||||
if len(opts.SnapshotId) > 0 {
|
||||
params["SnapshotId"] = opts.SnapshotId
|
||||
}
|
||||
if throughput >= 125 && throughput <= 1000 && volumeType == api.STORAGE_GP3_SSD {
|
||||
params["Throughput"] = fmt.Sprintf("%d", throughput)
|
||||
if opts.Throughput >= 125 && opts.Throughput <= 1000 && volumeType == api.STORAGE_GP3_SSD {
|
||||
params["Throughput"] = fmt.Sprintf("%d", opts.Throughput)
|
||||
}
|
||||
|
||||
if iops == 0 {
|
||||
iops = int(GenDiskIops(volumeType, sizeGb))
|
||||
if opts.Iops == 0 {
|
||||
opts.Iops = int(GenDiskIops(volumeType, opts.SizeGb))
|
||||
}
|
||||
|
||||
if utils.IsInStringArray(volumeType, []string{
|
||||
@@ -387,7 +400,7 @@ func (self *SRegion) CreateDisk(zoneId string, volumeType string, name string, s
|
||||
api.STORAGE_IO2_SSD,
|
||||
api.STORAGE_GP3_SSD,
|
||||
}) {
|
||||
params["Iops"] = fmt.Sprintf("%d", iops)
|
||||
params["Iops"] = fmt.Sprintf("%d", opts.Iops)
|
||||
}
|
||||
ret := &SDisk{}
|
||||
return ret, self.ec2Request("CreateVolume", params, ret)
|
||||
|
||||
+2
-2
@@ -119,8 +119,8 @@ func (self *SStorage) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := self.zone.region.CreateDisk(self.zone.ZoneName, self.storageType, conf.Name, conf.SizeGb, conf.Iops, conf.Throughput, "", conf.Desc)
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := self.zone.region.CreateDisk(self.zone.ZoneName, self.storageType, opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "CreateDisk")
|
||||
}
|
||||
|
||||
+16
-10
@@ -82,9 +82,9 @@ type SDisk struct {
|
||||
Properties DiskProperties `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateDisk(storageType string, name string, sizeGb int32, imageId, snapshotId, resourceGroup string) (*SDisk, error) {
|
||||
func (self *SRegion) CreateDisk(storageType string, opts *cloudprovider.DiskCreateConfig) (*SDisk, error) {
|
||||
params := jsonutils.Marshal(map[string]interface{}{
|
||||
"Name": name,
|
||||
"Name": opts.Name,
|
||||
"Location": self.Name,
|
||||
"Sku": map[string]string{
|
||||
"Name": storageType,
|
||||
@@ -95,12 +95,12 @@ func (self *SRegion) CreateDisk(storageType string, name string, sizeGb int32, i
|
||||
"CreationData": map[string]string{
|
||||
"CreateOption": "Empty",
|
||||
},
|
||||
"DiskSizeGB": sizeGb,
|
||||
"DiskSizeGB": opts.SizeGb,
|
||||
}
|
||||
if len(imageId) > 0 {
|
||||
image, err := self.GetImageById(imageId)
|
||||
if len(opts.ImageId) > 0 {
|
||||
image, err := self.GetImageById(opts.ImageId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetImageById(%s)", imageId)
|
||||
return nil, errors.Wrapf(err, "GetImageById(%s)", opts.ImageId)
|
||||
}
|
||||
// 通过镜像创建的磁盘只能传ID参数,不能通过sku,offer等参数创建.
|
||||
imageId, err := self.getOfferedImageId(&image)
|
||||
@@ -115,17 +115,17 @@ func (self *SRegion) CreateDisk(storageType string, name string, sizeGb int32, i
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if len(snapshotId) > 0 {
|
||||
} else if len(opts.SnapshotId) > 0 {
|
||||
properties = map[string]interface{}{
|
||||
"CreationData": map[string]interface{}{
|
||||
"CreateOption": "Copy",
|
||||
"sourceResourceId": snapshotId,
|
||||
"sourceResourceId": opts.SnapshotId,
|
||||
},
|
||||
}
|
||||
}
|
||||
params.Add(jsonutils.Marshal(properties), "Properties")
|
||||
disk := &SDisk{}
|
||||
return disk, self.create(resourceGroup, params, disk)
|
||||
return disk, self.create(opts.ProjectId, params, disk)
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteDisk(diskId string) error {
|
||||
@@ -312,7 +312,13 @@ func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error)
|
||||
if self.Properties.DiskState != "Unattached" {
|
||||
return "", fmt.Errorf("Azure reset disk needs to be done in the Unattached state, current status: %s", self.Properties.DiskState)
|
||||
}
|
||||
disk, err := self.storage.zone.region.CreateDisk(self.Sku.Name, self.Name, 0, "", snapshotId, self.GetProjectId())
|
||||
opts := &cloudprovider.DiskCreateConfig{
|
||||
Name: self.Name,
|
||||
SizeGb: 0,
|
||||
SnapshotId: snapshotId,
|
||||
ProjectId: self.GetProjectId(),
|
||||
}
|
||||
disk, err := self.storage.zone.region.CreateDisk(self.Sku.Name, opts)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "CreateDisk")
|
||||
}
|
||||
|
||||
+2
-2
@@ -83,8 +83,8 @@ func (self *SStorage) GetCapacityUsedMB() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := self.zone.region.CreateDisk(self.storageType, conf.Name, int32(conf.SizeGb), "", "", conf.ProjectId)
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := self.zone.region.CreateDisk(self.storageType, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+13
-7
@@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/encode"
|
||||
|
||||
billing "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
api "yunion.io/x/cloudmux/pkg/apis/compute"
|
||||
@@ -219,20 +220,25 @@ func (disk *SDisk) GetProjectId() string {
|
||||
return disk.storage.zone.region.GetProjectId()
|
||||
}
|
||||
|
||||
func (region *SRegion) CreateDisk(name string, sizeGb int, zone string, storageType string, image string, desc string) (*SDisk, error) {
|
||||
func (region *SRegion) CreateDisk(zone string, storageType string, opts *cloudprovider.DiskCreateConfig) (*SDisk, error) {
|
||||
if !strings.HasPrefix(storageType, GOOGLE_COMPUTE_DOMAIN) {
|
||||
storageType = fmt.Sprintf("projects/%s/zones/%s/diskTypes/%s", region.GetProjectId(), zone, storageType)
|
||||
}
|
||||
labels := map[string]string{}
|
||||
for k, v := range opts.Tags {
|
||||
labels[encode.EncodeGoogleLabel(k)] = encode.EncodeGoogleLabel(v)
|
||||
}
|
||||
body := map[string]interface{}{
|
||||
"name": name,
|
||||
"description": desc,
|
||||
"name": opts.Name,
|
||||
"description": opts.Desc,
|
||||
// https://www.googleapis.com/compute/v1/projects/my-project-15390453537169/zones/us-west2-c/diskTypes/pd-standard
|
||||
// projects/my-project-15390453537169/zones/us-west2-c/diskTypes/pd-standard
|
||||
"type": storageType,
|
||||
"type": storageType,
|
||||
"labels": labels,
|
||||
}
|
||||
body["sizeGb"] = sizeGb
|
||||
if len(image) > 0 {
|
||||
body["sourceImage"] = image
|
||||
body["sizeGb"] = opts.SizeGb
|
||||
if len(opts.ImageId) > 0 {
|
||||
body["sourceImage"] = opts.ImageId
|
||||
}
|
||||
disk := &SDisk{}
|
||||
resource := fmt.Sprintf("zones/%s/disks", zone)
|
||||
|
||||
+6
-1
@@ -812,7 +812,12 @@ func (region *SRegion) RebuildRoot(instanceId string, imageId string, sysDiskSiz
|
||||
}
|
||||
|
||||
diskName := fmt.Sprintf("vdisk-%s-%d", instance.Name, time.Now().UnixNano())
|
||||
disk, err := region.CreateDisk(diskName, sysDiskSizeGb, zone.Name, diskType, imageId, "create for replace instance system disk")
|
||||
disk, err := region.CreateDisk(zone.Name, diskType, &cloudprovider.DiskCreateConfig{
|
||||
Name: diskName,
|
||||
SizeGb: sysDiskSizeGb,
|
||||
ImageId: imageId,
|
||||
Desc: "create for replace instance system disk",
|
||||
})
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "region.CreateDisk.systemDisk")
|
||||
}
|
||||
|
||||
+2
-2
@@ -138,8 +138,8 @@ func (storage *SStorage) GetIDiskById(id string) (cloudprovider.ICloudDisk, erro
|
||||
return disk, nil
|
||||
}
|
||||
|
||||
func (storage *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := storage.zone.region.CreateDisk(conf.Name, conf.SizeGb, storage.zone.Name, storage.Name, "", conf.Desc)
|
||||
func (storage *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
disk, err := storage.zone.region.CreateDisk(storage.zone.Name, storage.Name, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+8
-8
@@ -441,19 +441,19 @@ func (self *SRegion) GetDisks(zoneId, storageTypeId string) ([]SDisk, error) {
|
||||
}
|
||||
|
||||
// https://console.huaweicloud.com/apiexplorer/#/openapi/EVS/doc?api=CreateVolume
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, snapshotId string, desc string, projectId string) (string, error) {
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, opts *cloudprovider.DiskCreateConfig) (string, error) {
|
||||
params := map[string]interface{}{
|
||||
"name": name,
|
||||
"name": opts.Name,
|
||||
"availability_zone": zoneId,
|
||||
"description": desc,
|
||||
"description": opts.Desc,
|
||||
"volume_type": category,
|
||||
"size": sizeGb,
|
||||
"size": opts.SizeGb,
|
||||
}
|
||||
if len(snapshotId) > 0 {
|
||||
params["snapshot_id"] = snapshotId
|
||||
if len(opts.SnapshotId) > 0 {
|
||||
params["snapshot_id"] = opts.SnapshotId
|
||||
}
|
||||
if len(projectId) > 0 {
|
||||
params["enterprise_project_id"] = projectId
|
||||
if len(opts.ProjectId) > 0 {
|
||||
params["enterprise_project_id"] = opts.ProjectId
|
||||
}
|
||||
|
||||
resp, err := self.post(SERVICE_EVS_V2_1, "cloudvolumes", map[string]interface{}{"volume": params})
|
||||
|
||||
+2
-2
@@ -111,8 +111,8 @@ func (self *SStorage) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), self.storageType, conf.Name, conf.SizeGb, "", conf.Desc, conf.ProjectId)
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), self.storageType, opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "CreateDisk")
|
||||
}
|
||||
|
||||
+14
-7
@@ -366,24 +366,31 @@ func (self *SDisk) Reset(ctx context.Context, snapshotId string) (string, error)
|
||||
return "", self.storage.zone.region.ResetDisk(self.DiskId, snapshotId)
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, desc string, projectId string) (string, error) {
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, opts *cloudprovider.DiskCreateConfig) (string, error) {
|
||||
params := make(map[string]string)
|
||||
params["Region"] = self.Region
|
||||
params["DiskType"] = category
|
||||
params["DiskChargeType"] = "POSTPAID_BY_HOUR"
|
||||
// [TencentCloudSDKError] Code=InvalidParameter, Message=DiskName: vdisk_stress-testvm-qcloud-1_1560117118026502729, length is 48, out of range [0,20] (e11d6c4007e4), RequestId=a8409994-0357-42e9-b028-e11d6c4007e4
|
||||
if len(name) > 20 {
|
||||
name = name[:20]
|
||||
if len(opts.Name) > 20 {
|
||||
opts.Name = opts.Name[:20]
|
||||
}
|
||||
params["DiskName"] = name
|
||||
params["DiskName"] = opts.Name
|
||||
params["Placement.Zone"] = zoneId
|
||||
if len(projectId) > 0 {
|
||||
params["Placement.ProjectId"] = projectId
|
||||
if len(opts.ProjectId) > 0 {
|
||||
params["Placement.ProjectId"] = opts.ProjectId
|
||||
}
|
||||
//params["Encrypted"] = "false"
|
||||
params["DiskSize"] = fmt.Sprintf("%d", sizeGb)
|
||||
params["DiskSize"] = fmt.Sprintf("%d", opts.SizeGb)
|
||||
params["ClientToken"] = utils.GenRequestId(20)
|
||||
|
||||
tagIdx := 0
|
||||
for k, v := range opts.Tags {
|
||||
params[fmt.Sprintf("Tags.%d.Key", tagIdx)] = k
|
||||
params[fmt.Sprintf("Tags.%d.Value", tagIdx)] = v
|
||||
tagIdx += 1
|
||||
}
|
||||
|
||||
body, err := self.cbsRequest("CreateDisks", params)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
+2
-2
@@ -119,8 +119,8 @@ func (self *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.zone.region.getStoragecache()
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.Zone, self.storageType, conf.Name, conf.SizeGb, conf.Desc, conf.ProjectId)
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.Zone, self.storageType, opts)
|
||||
if err != nil {
|
||||
log.Errorf("createDisk fail %s", err)
|
||||
return nil, err
|
||||
|
||||
+3
-3
@@ -363,11 +363,11 @@ func (self *SRegion) DeleteDisk(zoneId string, diskId string) error {
|
||||
}
|
||||
|
||||
// https://docs.ucloud.cn/api/udisk-api/create_udisk
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int) (string, error) {
|
||||
func (self *SRegion) CreateDisk(zoneId string, category string, opts *cloudprovider.DiskCreateConfig) (string, error) {
|
||||
params := NewUcloudParams()
|
||||
params.Set("Zone", zoneId)
|
||||
params.Set("Size", sizeGb)
|
||||
params.Set("Name", name)
|
||||
params.Set("Size", opts.SizeGb)
|
||||
params.Set("Name", opts.Name)
|
||||
params.Set("DiskType", category)
|
||||
|
||||
diskIds := make([]string, 0)
|
||||
|
||||
+2
-2
@@ -119,13 +119,13 @@ func (self *SStorage) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
func (self *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskType := "DataDisk"
|
||||
switch self.storageType {
|
||||
case api.STORAGE_UCLOUD_CLOUD_SSD:
|
||||
diskType = "SSDDataDisk"
|
||||
}
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), diskType, conf.Name, conf.SizeGb)
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), diskType, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+5
-5
@@ -243,18 +243,18 @@ func (region *SRegion) GetDisks(instanceId string, zoneId string, category strin
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (region *SRegion) CreateDisk(zoneId string, category string, name string, sizeGb int, desc string, projectId string) (string, error) {
|
||||
func (region *SRegion) CreateDisk(zoneId string, category string, opts *cloudprovider.DiskCreateConfig) (string, error) {
|
||||
params := make(map[string]string)
|
||||
params["ZoneId"] = zoneId
|
||||
params["VolumeName"] = name
|
||||
if len(desc) > 0 {
|
||||
params["Description"] = desc
|
||||
params["VolumeName"] = opts.Name
|
||||
if len(opts.Desc) > 0 {
|
||||
params["Description"] = opts.Desc
|
||||
}
|
||||
params["VolumeType"] = category
|
||||
// only data disk is supported
|
||||
params["Kind"] = "data"
|
||||
|
||||
params["Size"] = fmt.Sprintf("%d", sizeGb)
|
||||
params["Size"] = fmt.Sprintf("%d", opts.SizeGb)
|
||||
params["ClientToken"] = utils.GenRequestId(20)
|
||||
|
||||
body, err := region.storageRequest("CreateVolume", params)
|
||||
|
||||
+2
-2
@@ -102,8 +102,8 @@ func (storage *SStorage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return storage.zone.region.getStoragecache()
|
||||
}
|
||||
|
||||
func (storage *SStorage) CreateIDisk(conf *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := storage.zone.region.CreateDisk(storage.zone.ZoneId, storage.storageType, conf.Name, conf.SizeGb, conf.Desc, conf.ProjectId)
|
||||
func (storage *SStorage) CreateIDisk(opts *cloudprovider.DiskCreateConfig) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := storage.zone.region.CreateDisk(storage.zone.ZoneId, storage.storageType, opts)
|
||||
if err != nil {
|
||||
log.Errorf("createDisk fail %s", err)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user