mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #772 from tb365/bugfix/tb-huawei-ucloud-0510-fix
add ucloud account create climc
This commit is contained in:
@@ -156,6 +156,17 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.SUcloudCloudAccountCreateOptions{}, "cloud-account-create-ucloud", "Create a Ucloud cloud account", func(s *mcclient.ClientSession, args *options.SUcloudCloudAccountCreateOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
params.(*jsonutils.JSONDict).Add(jsonutils.NewString("Ucloud"), "provider")
|
||||
result, err := modules.Cloudaccounts.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudaccountUpdateOptions struct {
|
||||
ID string `help:"ID or Name of cloud account"`
|
||||
Name string `help:"New name to update"`
|
||||
|
||||
@@ -119,6 +119,11 @@ type SHuaweiCloudAccountCreateOptions struct {
|
||||
SAccessKeyCredentialWithEnvironment
|
||||
}
|
||||
|
||||
type SUcloudCloudAccountCreateOptions struct {
|
||||
SCloudAccountCreateBaseOptions
|
||||
SAccessKeyCredential
|
||||
}
|
||||
|
||||
// update credential options
|
||||
|
||||
type SCloudAccountUpdateCredentialBaseOptions struct {
|
||||
|
||||
@@ -228,6 +228,7 @@ func (self *SRegion) CreateEIP(name string, bwMbps int, chargeType string, bgpTy
|
||||
payMode = "Bandwidth"
|
||||
}
|
||||
params.Set("PayMode", payMode)
|
||||
params.Set("ChargeType", "Dynamic") // 按需付费
|
||||
|
||||
eips := make([]SEip, 0)
|
||||
err := self.DoAction("AllocateEIP", params, &eips)
|
||||
|
||||
@@ -110,7 +110,8 @@ func (self *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) {
|
||||
}
|
||||
|
||||
ieips := []cloudprovider.ICloudEIP{}
|
||||
for _, eip := range eips {
|
||||
for i, _ := range eips {
|
||||
eip := eips[i]
|
||||
eip.region = self
|
||||
ieips = append(ieips, &eip)
|
||||
}
|
||||
|
||||
@@ -150,6 +150,10 @@ func (self *SRegion) GetSnapshots(diskId string, snapshotId string) ([]SSnapshot
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range snapshots {
|
||||
snapshots[i].region = self
|
||||
}
|
||||
|
||||
return snapshots, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func (self *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
}
|
||||
|
||||
// 普通盘
|
||||
if self.storageType == api.STORAGE_UCLOUD_CLOUD_NORMAL && strings.Contains(disk.DiskType, "SSD") {
|
||||
if self.storageType == api.STORAGE_UCLOUD_CLOUD_NORMAL && !strings.Contains(disk.DiskType, "SSD") {
|
||||
filtedDisks = append(filtedDisks, disk)
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,12 @@ func (self *SStorage) GetEnabled() bool {
|
||||
}
|
||||
|
||||
func (self *SStorage) CreateIDisk(name string, sizeGb int, desc string) (cloudprovider.ICloudDisk, error) {
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), self.storageType, name, sizeGb)
|
||||
diskType := "DataDisk"
|
||||
switch self.storageType {
|
||||
case api.STORAGE_UCLOUD_CLOUD_SSD:
|
||||
diskType = "SSDDataDisk"
|
||||
}
|
||||
diskId, err := self.zone.region.CreateDisk(self.zone.GetId(), diskType, name, sizeGb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func (self *SUcloudClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error)
|
||||
subAccounts := make([]cloudprovider.SSubAccount, 0)
|
||||
for _, project := range projects {
|
||||
subAccount := cloudprovider.SSubAccount{}
|
||||
subAccount.Name = self.providerName
|
||||
subAccount.Name = fmt.Sprintf("%s-%s", self.providerName, project.ProjectName)
|
||||
// ucloud账号ID中可能包含/。因此使用::作为分割符号
|
||||
subAccount.Account = fmt.Sprintf("%s::%s", self.accessKeyId, project.ProjectID)
|
||||
subAccount.HealthStatus = api.CLOUD_PROVIDER_HEALTH_NORMAL
|
||||
|
||||
Reference in New Issue
Block a user