mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: 支持azure创建订阅
This commit is contained in:
@@ -1133,4 +1133,39 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type EnrollmentAccountListOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
R(&EnrollmentAccountListOptions{}, "cloud-account-enrollment-accounts", "Show enrollment accounts of cloudaccount", func(s *mcclient.ClientSession, opts *EnrollmentAccountListOptions) error {
|
||||
result, e := modules.Cloudaccounts.GetSpecific(s, opts.ID, "enrollment-accounts", nil)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
fmt.Println(result.PrettyString())
|
||||
return nil
|
||||
})
|
||||
|
||||
type SubscriptionCreateOptions struct {
|
||||
ID string `help:"Cloudaccount Id"`
|
||||
NAME string
|
||||
ENROLLMENTACCOUNT string
|
||||
OfferType string `choices:"MS-AZR-0148P|MS-AZR-0017P" default:"MS-AZR-0017P"`
|
||||
}
|
||||
|
||||
R(&SubscriptionCreateOptions{}, "cloud-account-create-subscription", "Create subscription for cloudaccount", func(s *mcclient.ClientSession, opts *SubscriptionCreateOptions) error {
|
||||
params := map[string]string{
|
||||
"name": opts.NAME,
|
||||
"offer_type": opts.OfferType,
|
||||
"enrollment_account_id": opts.ENROLLMENTACCOUNT,
|
||||
}
|
||||
ret, e := modules.Cloudaccounts.PerformAction(s, opts.ID, "create-subscription", jsonutils.Marshal(params))
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,9 @@ import (
|
||||
type SCloudaccount struct {
|
||||
apis.SStandaloneResourceBase
|
||||
apis.SDomainizedResourceBase
|
||||
Provider string `json:"provider"`
|
||||
Brand string `json:"brand"`
|
||||
IamLoginUrl string `json:"iam_login_url"`
|
||||
IsSupportCloudId *bool `json:"is_support_cloud_id,omitempty"`
|
||||
Provider string `json:"provider"`
|
||||
Brand string `json:"brand"`
|
||||
IamLoginUrl string `json:"iam_login_url"`
|
||||
}
|
||||
|
||||
// SCloudaccountResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudid/models.SCloudaccountResourceBase.
|
||||
@@ -103,7 +102,7 @@ type SCloudproviderResourceBase struct {
|
||||
|
||||
// SClouduser is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudid/models.SClouduser.
|
||||
type SClouduser struct {
|
||||
apis.SStatusUserResourceBase
|
||||
apis.SStatusDomainLevelUserResourceBase
|
||||
apis.SExternalizedResourceBase
|
||||
SCloudproviderResourceBase
|
||||
SCloudaccountResourceBase
|
||||
|
||||
@@ -384,3 +384,18 @@ type CANetConf struct {
|
||||
Description string `json:"description"`
|
||||
CASimpleNetConf
|
||||
}
|
||||
|
||||
type SubscriptonCreateInput struct {
|
||||
|
||||
// EA 账号id, 可通过 cloud-account-enrollment-accounts接口获取里面的name字段
|
||||
EnrollmentAccountId string
|
||||
|
||||
// 订阅名称
|
||||
Name string
|
||||
|
||||
// 可选值: MS-AZR-0017P(生产用途), MS-AZR-0148P(开发测试)
|
||||
OfferType string
|
||||
}
|
||||
|
||||
type EnrollmentAccountQuery struct {
|
||||
}
|
||||
|
||||
@@ -202,8 +202,6 @@ type SCloudaccount struct {
|
||||
ProxySettingId string `json:"proxy_setting_id"`
|
||||
// 公有云子账号登录地址
|
||||
IamLoginUrl string `json:"iam_login_url"`
|
||||
// 是否支持创建公有云子账号
|
||||
IsSupportCloudId *bool `json:"is_support_cloud_id,omitempty"`
|
||||
}
|
||||
|
||||
// SCloudprovider is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SCloudprovider.
|
||||
@@ -731,10 +729,11 @@ type SElasticip struct {
|
||||
|
||||
// SExternalProject is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SExternalProject.
|
||||
type SExternalProject struct {
|
||||
apis.SStandaloneResourceBase
|
||||
apis.SProjectizedResourceBase
|
||||
apis.SVirtualResourceBase
|
||||
apis.SExternalizedResourceBase
|
||||
SManagedResourceBase
|
||||
// 归属云账号ID
|
||||
CloudaccountId string `json:"cloudaccount_id"`
|
||||
}
|
||||
|
||||
// SGlobalVpc is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGlobalVpc.
|
||||
@@ -859,7 +858,8 @@ type SGuestTemplate struct {
|
||||
// 计费方式
|
||||
BillingType string `json:"billing_type"`
|
||||
// 其他配置信息
|
||||
Content interface{} `json:"content"`
|
||||
Content interface{} `json:"content"`
|
||||
LastCheckTime time.Time `json:"last_check_time"`
|
||||
}
|
||||
|
||||
// SGuestTemplateResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGuestTemplateResourceBase.
|
||||
@@ -868,20 +868,6 @@ type SGuestTemplateResourceBase struct {
|
||||
GuestTemplateId string `json:"guest_template_id"`
|
||||
}
|
||||
|
||||
// SGuestcdrom is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGuestcdrom.
|
||||
type SGuestcdrom struct {
|
||||
Id string `json:"id"`
|
||||
// = Column(VARCHAR(36, charset='ascii'), primary_key=True)
|
||||
ImageId string `json:"image_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=True)
|
||||
Name string `json:"name"`
|
||||
// Column(VARCHAR(64, charset='ascii'), nullable=True)
|
||||
Path string `json:"path"`
|
||||
// Column(VARCHAR(256, charset='ascii'), nullable=True)
|
||||
Size int `json:"size"`
|
||||
UpdateVersion int `json:"update_version"`
|
||||
}
|
||||
|
||||
// SGuestdisk is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGuestdisk.
|
||||
type SGuestdisk struct {
|
||||
SGuestJointsBase
|
||||
@@ -1001,10 +987,11 @@ type SHost struct {
|
||||
OvnVersion string `json:"ovn_version"`
|
||||
IsBaremetal bool `json:"is_baremetal"`
|
||||
// 是否处于维护状态
|
||||
IsMaintenance bool `json:"is_maintenance"`
|
||||
EnableHealthCheck bool `json:"enable_health_check"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
RealExternalId string `json:"real_external_id"`
|
||||
IsMaintenance bool `json:"is_maintenance"`
|
||||
LastPingAt time.Time `json:"last_ping_at"`
|
||||
EnableHealthCheck bool `json:"enable_health_check"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
RealExternalId string `json:"real_external_id"`
|
||||
// 是否为导入的宿主机
|
||||
IsImport bool `json:"is_import"`
|
||||
// 是否允许PXE启动
|
||||
@@ -1258,9 +1245,12 @@ type SLoadbalancerAgentDeployment struct {
|
||||
|
||||
// SLoadbalancerAgentParams is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SLoadbalancerAgentParams.
|
||||
type SLoadbalancerAgentParams struct {
|
||||
KeepalivedConfTmpl string `json:"keepalived_conf_tmpl"`
|
||||
HaproxyConfTmpl string `json:"haproxy_conf_tmpl"`
|
||||
TelegrafConfTmpl string `json:"telegraf_conf_tmpl"`
|
||||
KeepalivedConfTmpl string `json:"keepalived_conf_tmpl"`
|
||||
HaproxyConfTmpl string `json:"haproxy_conf_tmpl"`
|
||||
TelegrafConfTmpl string `json:"telegraf_conf_tmpl"`
|
||||
Vrrp SLoadbalancerAgentParamsVrrp `json:"vrrp"`
|
||||
Haproxy SLoadbalancerAgentParamsHaproxy `json:"haproxy"`
|
||||
Telegraf SLoadbalancerAgentParamsTelegraf `json:"telegraf"`
|
||||
}
|
||||
|
||||
// SLoadbalancerAgentParamsHaproxy is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SLoadbalancerAgentParamsHaproxy.
|
||||
@@ -1502,16 +1492,6 @@ type SManagedResourceBase struct {
|
||||
ManagerId string `json:"manager_id"`
|
||||
}
|
||||
|
||||
// SNatDEntry is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SNatDEntry.
|
||||
type SNatDEntry struct {
|
||||
SNatEntry
|
||||
ExternalIP string `json:"external_ip"`
|
||||
ExternalPort int `json:"external_port"`
|
||||
InternalIP string `json:"internal_ip"`
|
||||
InternalPort int `json:"internal_port"`
|
||||
IpProtocol string `json:"ip_protocol"`
|
||||
}
|
||||
|
||||
// SNatEntry is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SNatEntry.
|
||||
type SNatEntry struct {
|
||||
apis.SStatusInfrasResourceBase
|
||||
@@ -1542,25 +1522,6 @@ type SNatgatewayResourceBase struct {
|
||||
NatgatewayId string `json:"natgateway_id"`
|
||||
}
|
||||
|
||||
// SNetInterface is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SNetInterface.
|
||||
type SNetInterface struct {
|
||||
Mac string `json:"mac"`
|
||||
// Column(VARCHAR(36, charset='ascii'), primary_key=True)
|
||||
BaremetalId string `json:"baremetal_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=True)
|
||||
WireId string `json:"wire_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=True)
|
||||
Rate int `json:"rate"`
|
||||
// Column(Integer, nullable=True) # Mbps
|
||||
NicType string `json:"nic_type"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=True)
|
||||
Index byte `json:"index"`
|
||||
// Column(TINYINT, nullable=True)
|
||||
LinkUp bool `json:"link_up"`
|
||||
// Column(Boolean, nullable=True)
|
||||
Mtu int16 `json:"mtu"`
|
||||
}
|
||||
|
||||
// SNetwork is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SNetwork.
|
||||
type SNetwork struct {
|
||||
apis.SSharableVirtualResourceBase
|
||||
@@ -1735,6 +1696,8 @@ type SScalingAlarm struct {
|
||||
Value float64 `json:"value"`
|
||||
// Real-time cumulate number
|
||||
RealCumulate int `json:"real_cumulate"`
|
||||
// Last trigger time
|
||||
LastTriggerTime time.Time `json:"last_trigger_time"`
|
||||
}
|
||||
|
||||
// SScalingGroup is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SScalingGroup.
|
||||
@@ -1765,6 +1728,10 @@ type SScalingGroup struct {
|
||||
HealthCheckGov int `json:"health_check_gov"`
|
||||
LoadbalancerBackendPort int `json:"loadbalancer_backend_port"`
|
||||
LoadbalancerBackendWeight int `json:"loadbalancer_backend_weight"`
|
||||
// Time to allow scale
|
||||
AllowScaleTime time.Time `json:"allow_scale_time"`
|
||||
// NextCheckTime descripe the next time to check instance's health
|
||||
NextCheckTime time.Time `json:"next_check_time"`
|
||||
}
|
||||
|
||||
// SScalingGroupGuest is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SScalingGroupGuest.
|
||||
@@ -2102,7 +2069,13 @@ type STimer struct {
|
||||
WeekDays byte `json:"week_days"`
|
||||
// 0-31 0 is unlimited
|
||||
MonthDays uint32 `json:"month_days"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
// StartTime represent the start time of this timer
|
||||
StartTime time.Time `json:"start_time"`
|
||||
// EndTime represent deadline of this timer
|
||||
EndTime time.Time `json:"end_time"`
|
||||
// NextTime represent the time timer should bell
|
||||
NextTime time.Time `json:"next_time"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
}
|
||||
|
||||
// SVCenter is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SVCenter.
|
||||
|
||||
@@ -92,20 +92,6 @@ type SFederatedUser struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
}
|
||||
|
||||
// SFederationProtocol is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SFederationProtocol.
|
||||
type SFederationProtocol struct {
|
||||
Id string `json:"id"`
|
||||
IdpId string `json:"idp_id"`
|
||||
MappingId string `json:"mapping_id"`
|
||||
}
|
||||
|
||||
// SFernetKey is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SFernetKey.
|
||||
type SFernetKey struct {
|
||||
Type string `json:"type"`
|
||||
Index int `json:"index"`
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
// SGroup is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SGroup.
|
||||
type SGroup struct {
|
||||
SIdentityBaseResource
|
||||
@@ -144,45 +130,28 @@ type SIdmapping struct {
|
||||
EntityType string `json:"entity_type"`
|
||||
}
|
||||
|
||||
// SIdpRemoteIds is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SIdpRemoteIds.
|
||||
type SIdpRemoteIds struct {
|
||||
IdpId string `json:"idp_id"`
|
||||
RemoteId string `json:"remote_id"`
|
||||
}
|
||||
|
||||
// SImpliedRole is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SImpliedRole.
|
||||
type SImpliedRole struct {
|
||||
PriorRoleId string `json:"prior_role_id"`
|
||||
ImpliedRoleId string `json:"implied_role_id"`
|
||||
}
|
||||
|
||||
// SLocalUser is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SLocalUser.
|
||||
type SLocalUser struct {
|
||||
apis.SResourceBase
|
||||
Id int `json:"id"`
|
||||
UserId string `json:"user_id"`
|
||||
DomainId string `json:"domain_id"`
|
||||
Name string `json:"name"`
|
||||
FailedAuthCount int `json:"failed_auth_count"`
|
||||
}
|
||||
|
||||
// SNonlocalUser is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SNonlocalUser.
|
||||
type SNonlocalUser struct {
|
||||
DomainId string `json:"domain_id"`
|
||||
Name string `json:"name"`
|
||||
UserId string `json:"user_id"`
|
||||
Id int `json:"id"`
|
||||
UserId string `json:"user_id"`
|
||||
DomainId string `json:"domain_id"`
|
||||
Name string `json:"name"`
|
||||
FailedAuthCount int `json:"failed_auth_count"`
|
||||
FailedAuthAt time.Time `json:"failed_auth_at"`
|
||||
}
|
||||
|
||||
// SPassword is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SPassword.
|
||||
type SPassword struct {
|
||||
apis.SResourceBase
|
||||
Id int `json:"id"`
|
||||
LocalUserId int `json:"local_user_id"`
|
||||
Password string `json:"password"`
|
||||
SelfService bool `json:"self_service"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
CreatedAtInt int64 `json:"created_at_int"`
|
||||
ExpiresAtInt int64 `json:"expires_at_int"`
|
||||
Id int `json:"id"`
|
||||
LocalUserId int `json:"local_user_id"`
|
||||
Password string `json:"password"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
SelfService bool `json:"self_service"`
|
||||
PasswordHash string `json:"password_hash"`
|
||||
CreatedAtInt int64 `json:"created_at_int"`
|
||||
ExpiresAtInt int64 `json:"expires_at_int"`
|
||||
}
|
||||
|
||||
// SPolicy is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SPolicy.
|
||||
@@ -200,12 +169,6 @@ type SProject struct {
|
||||
IsDomain *bool `json:"is_domain,omitempty"`
|
||||
}
|
||||
|
||||
// SProjectExtended is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SProjectExtended.
|
||||
type SProjectExtended struct {
|
||||
SProject
|
||||
DomainName string `json:"domain_name"`
|
||||
}
|
||||
|
||||
// SRegion is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SRegion.
|
||||
type SRegion struct {
|
||||
apis.SStandaloneResourceBase
|
||||
@@ -219,17 +182,6 @@ type SRole struct {
|
||||
apis.SSharableBaseResource
|
||||
}
|
||||
|
||||
// SScopeResource is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SScopeResource.
|
||||
type SScopeResource struct {
|
||||
DomainId string `json:"domain_id"`
|
||||
ProjectId string `json:"project_id"`
|
||||
OwnerId string `json:"owner_id"`
|
||||
RegionId string `json:"region_id"`
|
||||
ServiceId string `json:"service_id"`
|
||||
Resource string `json:"resource"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
// SService is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SService.
|
||||
type SService struct {
|
||||
apis.SStandaloneResourceBase
|
||||
@@ -262,13 +214,6 @@ type SUser struct {
|
||||
EnableMfa *bool `json:"enable_mfa,omitempty"`
|
||||
}
|
||||
|
||||
// SUserOption is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SUserOption.
|
||||
type SUserOption struct {
|
||||
UserId string `json:"user_id"`
|
||||
OptionId string `json:"option_id"`
|
||||
OptionValue string `json:"option_value"`
|
||||
}
|
||||
|
||||
// SUsergroupMembership is an autogenerated struct via yunion.io/x/onecloud/pkg/keystone/models.SUsergroupMembership.
|
||||
type SUsergroupMembership struct {
|
||||
apis.SResourceBase
|
||||
|
||||
@@ -62,44 +62,9 @@ type SImage struct {
|
||||
OssChecksum string `json:"oss_checksum"`
|
||||
}
|
||||
|
||||
// SImageMember is an autogenerated struct via yunion.io/x/onecloud/pkg/image/models.SImageMember.
|
||||
type SImageMember struct {
|
||||
SImagePeripheral
|
||||
Member string `json:"member"`
|
||||
CanShare bool `json:"can_share"`
|
||||
}
|
||||
|
||||
// SImagePeripheral is an autogenerated struct via yunion.io/x/onecloud/pkg/image/models.SImagePeripheral.
|
||||
type SImagePeripheral struct {
|
||||
apis.SResourceBase
|
||||
Id int `json:"id"`
|
||||
ImageId string `json:"image_id"`
|
||||
}
|
||||
|
||||
// SImageProperty is an autogenerated struct via yunion.io/x/onecloud/pkg/image/models.SImageProperty.
|
||||
type SImageProperty struct {
|
||||
SImagePeripheral
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// SImageSubformat is an autogenerated struct via yunion.io/x/onecloud/pkg/image/models.SImageSubformat.
|
||||
type SImageSubformat struct {
|
||||
SImagePeripheral
|
||||
Format string `json:"format"`
|
||||
Size int64 `json:"size"`
|
||||
Location string `json:"location"`
|
||||
Checksum string `json:"checksum"`
|
||||
FastHash string `json:"fast_hash"`
|
||||
Status string `json:"status"`
|
||||
TorrentSize int64 `json:"torrent_size"`
|
||||
TorrentLocation string `json:"torrent_location"`
|
||||
TorrentChecksum string `json:"torrent_checksum"`
|
||||
TorrentStatus string `json:"torrent_status"`
|
||||
}
|
||||
|
||||
// SImageTag is an autogenerated struct via yunion.io/x/onecloud/pkg/image/models.SImageTag.
|
||||
type SImageTag struct {
|
||||
SImagePeripheral
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
@@ -63,11 +63,6 @@ type SAlertnotification struct {
|
||||
Params interface{} `json:"params"`
|
||||
}
|
||||
|
||||
// SCommonAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SCommonAlert.
|
||||
type SCommonAlert struct {
|
||||
SAlert
|
||||
}
|
||||
|
||||
// SDataSource is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SDataSource.
|
||||
type SDataSource struct {
|
||||
apis.SStandaloneResourceBase
|
||||
@@ -79,16 +74,6 @@ type SDataSource struct {
|
||||
IsDefault *bool `json:"is_default,omitempty"`
|
||||
}
|
||||
|
||||
// SMeterAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SMeterAlert.
|
||||
type SMeterAlert struct {
|
||||
SV1Alert
|
||||
}
|
||||
|
||||
// SNodeAlert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SNodeAlert.
|
||||
type SNodeAlert struct {
|
||||
SV1Alert
|
||||
}
|
||||
|
||||
// SNotification is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SNotification.
|
||||
type SNotification struct {
|
||||
apis.SVirtualResourceBase
|
||||
@@ -150,8 +135,3 @@ type SSuggestSysRuleConfig struct {
|
||||
// IgnoreAlert means whether or not show SSuggestSysAlert results for current scope
|
||||
IgnoreAlert bool `json:"ignore_alert"`
|
||||
}
|
||||
|
||||
// SV1Alert is an autogenerated struct via yunion.io/x/onecloud/pkg/monitor/models.SV1Alert.
|
||||
type SV1Alert struct {
|
||||
SAlert
|
||||
}
|
||||
|
||||
@@ -99,60 +99,9 @@ type SJointResourceBase struct {
|
||||
// SKeystoneCacheObject is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SKeystoneCacheObject.
|
||||
type SKeystoneCacheObject struct {
|
||||
SStandaloneResourceBase
|
||||
DomainId string `json:"domain_id"`
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
// SMetadata is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SMetadata.
|
||||
type SMetadata struct {
|
||||
// 资源类型
|
||||
// example: network
|
||||
ObjType string `json:"obj_type"`
|
||||
// 资源ID
|
||||
// example: 87321a70-1ecb-422a-8b0c-c9aa632a46a7
|
||||
ObjId string `json:"obj_id"`
|
||||
// 资源组合ID
|
||||
// example: network::87321a70-1ecb-422a-8b0c-c9aa632a46a7
|
||||
Id string `json:"id"`
|
||||
// 标签KEY
|
||||
// exmaple: 部门
|
||||
Key string `json:"key"`
|
||||
// 标签值
|
||||
// example: 技术部
|
||||
Value string `json:"value"`
|
||||
// 是否被删除
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
// SOpsLog is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SOpsLog.
|
||||
type SOpsLog struct {
|
||||
Id int64 `json:"id"`
|
||||
// = Column(BigInteger, primary_key=True)
|
||||
ObjType string `json:"obj_type"`
|
||||
// = Column(VARCHAR(40, charset='ascii'), nullable=False)
|
||||
ObjId string `json:"obj_id"`
|
||||
// = Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False)
|
||||
ObjName string `json:"obj_name"`
|
||||
// = Column(VARCHAR(128, charset='utf8'), nullable=False)
|
||||
Action string `json:"action"`
|
||||
// = Column(VARCHAR(32, charset='ascii'), nullable=False)
|
||||
Notes string `json:"notes"`
|
||||
ProjectId string `json:"tenant_id"`
|
||||
// = Column(VARCHAR(ID_LENGTH, charset='ascii'))
|
||||
Project string `json:"tenant"`
|
||||
ProjectDomainId string `json:"project_domain_id"`
|
||||
ProjectDomain string `json:"project_domain"`
|
||||
UserId string `json:"user_id"`
|
||||
// = Column(VARCHAR(ID_LENGTH, charset='ascii'))
|
||||
User string `json:"user"`
|
||||
// = Column(VARCHAR(128, charset='utf8'))
|
||||
DomainId string `json:"domain_id"`
|
||||
Domain string `json:"domain"`
|
||||
Roles string `json:"roles"`
|
||||
// BillingType string `width:"64" charset:"ascii" default:"postpaid" list:"user" create:"user"` // billing_type = Column(VARCHAR(64, charset='ascii'), nullable=True)
|
||||
OpsTime time.Time `json:"ops_time"`
|
||||
OwnerDomainId string `json:"owner_domain_id"`
|
||||
OwnerProjectId string `json:"owner_tenant_id"`
|
||||
DomainId string `json:"domain_id"`
|
||||
Domain string `json:"domain"`
|
||||
LastCheck time.Time `json:"last_check"`
|
||||
}
|
||||
|
||||
// SProjectizedResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SProjectizedResourceBase.
|
||||
@@ -229,6 +178,13 @@ type SStatusDomainLevelResourceBase struct {
|
||||
SStatusResourceBase
|
||||
}
|
||||
|
||||
// SStatusDomainLevelUserResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SStatusDomainLevelUserResourceBase.
|
||||
type SStatusDomainLevelUserResourceBase struct {
|
||||
SStatusDomainLevelResourceBase
|
||||
// 本地用户Id
|
||||
OwnerId string `json:"owner_id"`
|
||||
}
|
||||
|
||||
// SStatusInfrasResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SStatusInfrasResourceBase.
|
||||
type SStatusInfrasResourceBase struct {
|
||||
SInfrasResourceBase
|
||||
@@ -247,22 +203,6 @@ type SStatusStandaloneResourceBase struct {
|
||||
SStatusResourceBase
|
||||
}
|
||||
|
||||
// SStatusUserResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SStatusUserResourceBase.
|
||||
type SStatusUserResourceBase struct {
|
||||
SUserResourceBase
|
||||
SStatusResourceBase
|
||||
}
|
||||
|
||||
// STenant is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.STenant.
|
||||
type STenant struct {
|
||||
SKeystoneCacheObject
|
||||
}
|
||||
|
||||
// SUser is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SUser.
|
||||
type SUser struct {
|
||||
SKeystoneCacheObject
|
||||
}
|
||||
|
||||
// SUserResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SUserResourceBase.
|
||||
type SUserResourceBase struct {
|
||||
SStandaloneResourceBase
|
||||
|
||||
@@ -235,6 +235,9 @@ type ICloudProvider interface {
|
||||
CreateICloudgroup(name, desc string) (ICloudgroup, error)
|
||||
GetIClouduserByName(name string) (IClouduser, error)
|
||||
CreateIClouduser(conf *SClouduserCreateConfig) (IClouduser, error)
|
||||
|
||||
GetEnrollmentAccounts() ([]SEnrollmentAccount, error)
|
||||
CreateSubscription(SubscriptionCreateInput) error
|
||||
}
|
||||
|
||||
func IsSupportProject(prod ICloudProvider) bool {
|
||||
@@ -373,6 +376,14 @@ func (self *SBaseProvider) CreateIClouduser(conf *SClouduserCreateConfig) (IClou
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetEnrollmentAccounts() ([]SEnrollmentAccount, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) CreateSubscription(SubscriptionCreateInput) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SBaseProvider) GetCloudRegionExternalIdPrefix() string {
|
||||
return self.factory.GetId()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudprovider
|
||||
|
||||
type SubscriptionCreateInput struct {
|
||||
Name string
|
||||
EnrollmentAccountId string
|
||||
OfferType string
|
||||
}
|
||||
|
||||
type SEnrollmentAccountProperties struct {
|
||||
// Enrollment Account 主体名称
|
||||
PrincipalName string
|
||||
|
||||
// Enrollment Account 支持创建订阅类别
|
||||
OfferTypes []string
|
||||
}
|
||||
|
||||
type SEnrollmentAccount struct {
|
||||
// Enrollment Account 标识Id
|
||||
Id string
|
||||
|
||||
// Enrollment Account name
|
||||
Name string
|
||||
|
||||
// Enrollment Account 类型
|
||||
Type string
|
||||
|
||||
// Enrollment Account 属性
|
||||
Properties SEnrollmentAccountProperties
|
||||
}
|
||||
@@ -2956,3 +2956,58 @@ func (self *SCloudaccount) SyncProject(ctx context.Context, userCred mcclient.To
|
||||
|
||||
return extProj.ExternalId, nil
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) AllowGetDetailsEnrollmentAccounts(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsDomainAllowGetSpec(userCred, self, "enrollment-accounts")
|
||||
}
|
||||
|
||||
// 获取Azure Enrollment Accounts
|
||||
func (self *SCloudaccount) GetDetailsEnrollmentAccounts(ctx context.Context, userCred mcclient.TokenCredential, query api.EnrollmentAccountQuery) ([]cloudprovider.SEnrollmentAccount, error) {
|
||||
if self.Provider != api.CLOUD_PROVIDER_AZURE {
|
||||
return nil, httperrors.NewNotSupportedError("%s not support", self.Provider)
|
||||
}
|
||||
provider, err := self.GetProvider()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetProvider")
|
||||
}
|
||||
|
||||
result, err := provider.GetEnrollmentAccounts()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetEnrollmentAccounts")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) AllowPerformCreateSubscription(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsDomainAllowPerform(userCred, self, "create-subscription")
|
||||
}
|
||||
|
||||
// 创建Azure订阅
|
||||
func (self *SCloudaccount) PerformCreateSubscription(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.SubscriptonCreateInput) (jsonutils.JSONObject, error) {
|
||||
if self.Provider != api.CLOUD_PROVIDER_AZURE {
|
||||
return nil, httperrors.NewNotSupportedError("%s not support create subscription")
|
||||
}
|
||||
if len(input.Name) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("name")
|
||||
}
|
||||
if len(input.EnrollmentAccountId) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("enrollment_account_id")
|
||||
}
|
||||
if len(input.OfferType) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("offer_type")
|
||||
}
|
||||
|
||||
provider, err := self.GetProvider()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetProvider")
|
||||
}
|
||||
|
||||
conf := cloudprovider.SubscriptionCreateInput{
|
||||
Name: input.Name,
|
||||
EnrollmentAccountId: input.EnrollmentAccountId,
|
||||
OfferType: input.OfferType,
|
||||
}
|
||||
|
||||
return nil, provider.CreateSubscription(conf)
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ var DEFAULT_API_VERSION = map[string]string{
|
||||
"microsoft.insights/eventtypes/management/values": "2017-03-01-preview",
|
||||
"Microsoft.Authorization/policyDefinitions": "2019-09-01",
|
||||
"Microsoft.Authorization/policyAssignments": "2019-09-01",
|
||||
"Microsoft.Billing": "2018-03-01-preview",
|
||||
}
|
||||
|
||||
var GRAPH_API_VERSION = map[string]string{
|
||||
@@ -233,6 +234,21 @@ func (self *SAzureClient) Put(url string, body jsonutils.JSONObject) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAzureClient) POST(url string, body jsonutils.JSONObject) error {
|
||||
cli, err := self.getDefaultClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := jsonRequest(cli, "POST", self.domain, url, self.subscriptionId, body.String(), DefaultResource)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if self.debug {
|
||||
log.Debugf("%s", resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAzureClient) Patch(url string, body jsonutils.JSONObject) error {
|
||||
cli, err := self.getDefaultClient()
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package azure
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
func (cli *SAzureClient) GetEnrollmentAccounts() ([]cloudprovider.SEnrollmentAccount, error) {
|
||||
accounts := struct {
|
||||
Value []cloudprovider.SEnrollmentAccount
|
||||
}{}
|
||||
err := cli.Get("providers/Microsoft.Billing/enrollmentAccounts", nil, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return accounts.Value, nil
|
||||
}
|
||||
|
||||
func (cli *SAzureClient) CreateSubscription(name string, eaId string, offerType string) error {
|
||||
appId, err := cli.GetAppObjectId()
|
||||
if err != nil {
|
||||
log.Errorf("GetAppObjectId error: %v", err)
|
||||
}
|
||||
owners := []map[string]string{}
|
||||
if len(appId) > 0 {
|
||||
owners = append(owners, map[string]string{"objectId": appId})
|
||||
}
|
||||
body := map[string]interface{}{
|
||||
"displayName": name,
|
||||
"offerType": offerType,
|
||||
"owners": owners,
|
||||
}
|
||||
resource := fmt.Sprintf("providers/Microsoft.Billing/enrollmentAccounts/%s/providers/Microsoft.Subscription/createSubscription", eaId)
|
||||
return cli.POST(resource, jsonutils.Marshal(body))
|
||||
}
|
||||
|
||||
type SServicePrincipal struct {
|
||||
AppId string
|
||||
ObjectId string
|
||||
}
|
||||
|
||||
func (cli *SAzureClient) GetAppObjectId() (string, error) {
|
||||
result, err := cli.ListServicePrincipal(cli.clientId)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "ListServicePrincipal")
|
||||
}
|
||||
if len(result) == 1 {
|
||||
return result[0].ObjectId, nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (cli *SAzureClient) ListServicePrincipal(appId string) ([]SServicePrincipal, error) {
|
||||
params := url.Values{}
|
||||
if len(appId) > 0 {
|
||||
params.Set("$filter", fmt.Sprintf(`appId eq '%s'`, cli.clientId))
|
||||
}
|
||||
result := []SServicePrincipal{}
|
||||
err := cli.ListGraphResource("servicePrincipals", params, &result)
|
||||
if err != nil {
|
||||
return result, errors.Wrap(err, "ListGraphResource.servicePrincipals")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -241,3 +241,11 @@ func (self *SAzureProvider) CreateICloudgroup(name, desc string) (cloudprovider.
|
||||
func (self *SAzureProvider) GetICloudgroupByName(name string) (cloudprovider.ICloudgroup, error) {
|
||||
return self.client.GetICloudgroupByName(name)
|
||||
}
|
||||
|
||||
func (self *SAzureProvider) GetEnrollmentAccounts() ([]cloudprovider.SEnrollmentAccount, error) {
|
||||
return self.client.GetEnrollmentAccounts()
|
||||
}
|
||||
|
||||
func (self *SAzureProvider) CreateSubscription(input cloudprovider.SubscriptionCreateInput) error {
|
||||
return self.client.CreateSubscription(input.Name, input.EnrollmentAccountId, input.OfferType)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/multicloud/azure"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type EnrollmentAccountListOptions struct {
|
||||
}
|
||||
shellutils.R(&EnrollmentAccountListOptions{}, "enrollment-account-list", "List enrollment accounts", func(cli *azure.SRegion, args *EnrollmentAccountListOptions) error {
|
||||
accounts, err := cli.GetClient().GetEnrollmentAccounts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(accounts, 0, 0, 0, nil)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -30,4 +30,28 @@ func init() {
|
||||
printList(subscriptions, 0, 0, 0, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
type SubscriptionCreateOptions struct {
|
||||
NAME string
|
||||
OfferType string `choices:"MS-AZR-0017P|MS-AZR-0148P" default:"MS-AZR-0017P"`
|
||||
EAID string `help:"Enrollment accounts id"`
|
||||
}
|
||||
|
||||
shellutils.R(&SubscriptionCreateOptions{}, "subscription-create", "Create subscription", func(cli *azure.SRegion, args *SubscriptionCreateOptions) error {
|
||||
return cli.GetClient().CreateSubscription(args.NAME, args.EAID, args.OfferType)
|
||||
})
|
||||
|
||||
type ServicePrincipalListOptions struct {
|
||||
AppId string
|
||||
}
|
||||
|
||||
shellutils.R(&ServicePrincipalListOptions{}, "sp-list", "List service principal", func(cli *azure.SRegion, args *ServicePrincipalListOptions) error {
|
||||
sp, err := cli.GetClient().ListServicePrincipal(args.AppId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(sp, 0, 0, 0, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user