Merge pull request #772 from tb365/bugfix/tb-huawei-ucloud-0510-fix

add ucloud account create climc
This commit is contained in:
yunion-ci-robot
2019-05-11 17:32:34 +08:00
committed by GitHub
7 changed files with 31 additions and 4 deletions
+11
View File
@@ -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"`
+5
View File
@@ -119,6 +119,11 @@ type SHuaweiCloudAccountCreateOptions struct {
SAccessKeyCredentialWithEnvironment
}
type SUcloudCloudAccountCreateOptions struct {
SCloudAccountCreateBaseOptions
SAccessKeyCredential
}
// update credential options
type SCloudAccountUpdateCredentialBaseOptions struct {
+1
View File
@@ -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)
+2 -1
View File
@@ -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)
}
+4
View File
@@ -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
}
+7 -2
View File
@@ -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
}
+1 -1
View File
@@ -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