mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
fix: 优化azure订阅创建
This commit is contained in:
@@ -387,14 +387,14 @@ type CANetConf struct {
|
||||
|
||||
type SubscriptonCreateInput struct {
|
||||
|
||||
// EA 账号id, 可通过 cloud-account-enrollment-accounts接口获取里面的name字段
|
||||
EnrollmentAccountId string
|
||||
// EA 账号id, 可通过 cloud-account-enrollment-accounts接口获取里面的id字段
|
||||
EnrollmentAccountId string `json:"enrollment_account_id"`
|
||||
|
||||
// 订阅名称
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
|
||||
// 可选值: MS-AZR-0017P(生产用途), MS-AZR-0148P(开发测试)
|
||||
OfferType string
|
||||
OfferType string `json:"offer_type"`
|
||||
}
|
||||
|
||||
type EnrollmentAccountQuery struct {
|
||||
|
||||
@@ -20,24 +20,13 @@ type SubscriptionCreateInput struct {
|
||||
OfferType string
|
||||
}
|
||||
|
||||
type SEnrollmentAccountProperties struct {
|
||||
// Enrollment Account 主体名称
|
||||
PrincipalName string
|
||||
|
||||
// Enrollment Account 支持创建订阅类别
|
||||
OfferTypes []string
|
||||
}
|
||||
|
||||
type SEnrollmentAccount struct {
|
||||
// Enrollment Account 标识Id
|
||||
Id string
|
||||
// Enrollment Account Id
|
||||
Id string `json:"id"`
|
||||
|
||||
// Enrollment Account name
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
|
||||
// Enrollment Account 类型
|
||||
Type string
|
||||
|
||||
// Enrollment Account 属性
|
||||
Properties SEnrollmentAccountProperties
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
@@ -3009,5 +3009,11 @@ func (self *SCloudaccount) PerformCreateSubscription(ctx context.Context, userCr
|
||||
OfferType: input.OfferType,
|
||||
}
|
||||
|
||||
return nil, provider.CreateSubscription(conf)
|
||||
err = provider.CreateSubscription(conf)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "CreateSubscription")
|
||||
}
|
||||
|
||||
syncRange := SSyncRange{}
|
||||
return nil, self.StartSyncCloudProviderInfoTask(ctx, userCred, &syncRange, "")
|
||||
}
|
||||
|
||||
@@ -25,15 +25,36 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SEnrollmentAccountProperties struct {
|
||||
PrincipalName string
|
||||
OfferTypes []string
|
||||
}
|
||||
|
||||
type SEnrollmentAccount struct {
|
||||
Id string
|
||||
Name string
|
||||
Type string
|
||||
Properties SEnrollmentAccountProperties
|
||||
}
|
||||
|
||||
func (cli *SAzureClient) GetEnrollmentAccounts() ([]cloudprovider.SEnrollmentAccount, error) {
|
||||
accounts := struct {
|
||||
Value []cloudprovider.SEnrollmentAccount
|
||||
Value []SEnrollmentAccount
|
||||
}{}
|
||||
err := cli.Get("providers/Microsoft.Billing/enrollmentAccounts", nil, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return accounts.Value, nil
|
||||
eas := []cloudprovider.SEnrollmentAccount{}
|
||||
for i := range accounts.Value {
|
||||
ea := cloudprovider.SEnrollmentAccount{
|
||||
Id: accounts.Value[i].Name,
|
||||
Name: accounts.Value[i].Properties.PrincipalName,
|
||||
Type: accounts.Value[i].Type,
|
||||
}
|
||||
eas = append(eas, ea)
|
||||
}
|
||||
return eas, nil
|
||||
}
|
||||
|
||||
func (cli *SAzureClient) CreateSubscription(name string, eaId string, offerType string) error {
|
||||
|
||||
Reference in New Issue
Block a user