mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix: optimized for cloudid (#7604)
Co-authored-by: Qu Xuan <quxuan@yunionyun.com>
This commit is contained in:
@@ -15,154 +15,24 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudgroupListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudpolicyId string `json:"cloudpolicy_id"`
|
||||
Usable bool `json:"usable"`
|
||||
}
|
||||
R(&CloudgroupListOptions{}, "cloud-group-list", "List cloud groups", func(s *mcclient.ClientSession, opts *CloudgroupListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudgroups.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudgroups.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupCreateOptions struct {
|
||||
NAME string `json:"name"`
|
||||
PROVIDER string `json:"provider" choices:"Google|Aliyun|Aws|Huawei|Qcloud"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
Desc string `json:"description"`
|
||||
}
|
||||
|
||||
R(&CloudgroupCreateOptions{}, "cloud-group-create", "Create cloud group", func(s *mcclient.ClientSession, opts *CloudgroupCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudgroups.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupIdOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-delete", "Delete cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-show", "Show cloud group", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupIdOptions{}, "cloud-group-syncstatus", "Sync cloud group status", func(s *mcclient.ClientSession, opts *CloudgroupIdOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPolicyOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDPOLICY_ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-attach-policy", "Attach policy for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupPolicyOptions{}, "cloud-group-detach-policy", "Detach policy from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPolicyOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUserOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CLOUDUSER_ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-add-user", "Add user to cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "add-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudgroupUserOptions{}, "cloud-group-remove-user", "Remove user from cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUserOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "remove-user", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupPoliciesOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupPoliciesOptions{}, "cloud-group-set-policies", "Set cloudpolicies for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupPoliciesOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-policies", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudgroupUsersOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
ClouduserIds []string `json:"clouduser_ids"`
|
||||
}
|
||||
|
||||
R(&CloudgroupUsersOptions{}, "cloud-group-set-users", "Set users for cloud group", func(s *mcclient.ClientSession, opts *CloudgroupUsersOptions) error {
|
||||
result, err := modules.Cloudgroups.PerformAction(s, opts.ID, "set-users", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudgroups).WithKeyword("cloud-group")
|
||||
cmd.List(&options.CloudgroupListOptions{})
|
||||
cmd.Create(&options.CloudgroupCreateOptions{})
|
||||
cmd.Show(&options.CloudgroupIdOptions{})
|
||||
cmd.Delete(&options.CloudgroupIdOptions{})
|
||||
cmd.Perform("syncstatus", &options.CloudgroupIdOptions{})
|
||||
cmd.Perform("attach-policy", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("add-user", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("remove-user", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("set-policies", &options.CloudgroupPolicyOptions{})
|
||||
cmd.Perform("set-users", &options.CloudgroupUserOptions{})
|
||||
cmd.Perform("public", &options.CloudgroupPublicOptions{})
|
||||
cmd.Perform("private", &options.CloudgroupIdOptions{})
|
||||
}
|
||||
|
||||
@@ -15,122 +15,20 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type CloudpolicyListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
CloudproviderId string `json:"cloudprovider_id"`
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
PolicyType string `help:"Filter cloudpolicy by policy type" choices:"system|custom"`
|
||||
}
|
||||
R(&CloudpolicyListOptions{}, "cloud-policy-list", "List cloud policies", func(s *mcclient.ClientSession, opts *CloudpolicyListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudpolicies.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudpolicies.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyIdOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-show", "Show cloud policiy details", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-syncstatus", "Sync cloud policiy status", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-lock", "Lock cloud policiy", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "lock", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyIdOptions{}, "cloud-policy-unlock", "Unlock cloud policiy", func(s *mcclient.ClientSession, opts *CloudpolicyIdOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "unlock", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyGroupOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
CLOUDGROUP_ID string `help:"Cloudgroup Id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-assign-group", "Assign cloud policiy to group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "assign-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&CloudpolicyGroupOptions{}, "cloud-policy-revoke-group", "Revoke cloud policiy from group", func(s *mcclient.ClientSession, opts *CloudpolicyGroupOptions) error {
|
||||
result, err := modules.Cloudpolicies.PerformAction(s, opts.ID, "revoke-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudpolicyUpdateOption struct {
|
||||
ID string
|
||||
Name string
|
||||
Description string
|
||||
PolicyDocument string
|
||||
}
|
||||
|
||||
R(&CloudpolicyUpdateOption{}, "cloud-policy-update", "Revoke cloud policiy from group", func(s *mcclient.ClientSession, opts *CloudpolicyUpdateOption) error {
|
||||
params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
|
||||
if len(opts.PolicyDocument) > 0 {
|
||||
document, err := jsonutils.Parse([]byte(opts.PolicyDocument))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid policy document")
|
||||
}
|
||||
params.Remove("policy_document")
|
||||
params.Remove("id")
|
||||
params.Add(document, "document")
|
||||
}
|
||||
result, err := modules.Cloudpolicies.Update(s, opts.ID, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudpolicies).WithKeyword("cloud-policy")
|
||||
cmd.Create(&options.CloudpolicyListOptions{})
|
||||
cmd.List(&options.CloudpolicyListOptions{})
|
||||
cmd.Show(&options.CloudpolicyIdOptions{})
|
||||
cmd.Update(&options.CloudpolicyUpdateOption{})
|
||||
cmd.Perform("syncstauts", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("lock", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("unlock", &options.CloudpolicyIdOptions{})
|
||||
cmd.Perform("assign-group", &options.CloudpolicyGroupOptions{})
|
||||
cmd.Perform("revoke-group", &options.CloudpolicyGroupOptions{})
|
||||
}
|
||||
|
||||
@@ -15,184 +15,23 @@
|
||||
package cloudid
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ClouduserListOptions struct {
|
||||
options.BaseListOptions
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
CloudpolicyId string `help:"filter cloudusers by cloudpolicy"`
|
||||
CloudgroupId string `help:"filter cloudusers by cloudgroup"`
|
||||
}
|
||||
R(&ClouduserListOptions{}, "cloud-user-list", "List cloud users", func(s *mcclient.ClientSession, opts *ClouduserListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Cloudusers.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(result, modules.Cloudusers.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserCreateOptions struct {
|
||||
Name string
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
OwnerId string `help:"Owner Id"`
|
||||
CloudpolicyIds []string `help:"cloudpolicy ids"`
|
||||
CloudgroupIds []string `help:"cloudgroup ids"`
|
||||
Email string `help:"email address"`
|
||||
MobilePhone string `help:"phone number"`
|
||||
IsConsoleLogin *bool `help:"is console login"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserCreateOptions{}, "cloud-user-create", "Create cloud user", func(s *mcclient.ClientSession, opts *ClouduserCreateOptions) error {
|
||||
params := jsonutils.Marshal(opts)
|
||||
result, err := modules.Cloudusers.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserIdOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-delete", "Delete cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-logininfo", "Show cloud user login info", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.GetLoginInfo(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-show", "Show cloud user", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.Get(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserSyncOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
PolicyOnly bool `help:"Ony sync clouduser policies for cloud"`
|
||||
}
|
||||
|
||||
R(&ClouduserSyncOptions{}, "cloud-user-sync", "Sync cloud user policies", func(s *mcclient.ClientSession, opts *ClouduserSyncOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "sync", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserIdOptions{}, "cloud-user-syncstatus", "Sync cloud user status", func(s *mcclient.ClientSession, opts *ClouduserIdOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "syncstatus", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPolicyOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
CLOUDPOLICY_ID string `help:"cloudpolicy Id"`
|
||||
CloudproviderId string `help:"cloudprovider Id"`
|
||||
}
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-attach-policy", "Attach policy for cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "attach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserPolicyOptions{}, "cloud-user-detach-policy", "Detach policy from cloud user", func(s *mcclient.ClientSession, opts *ClouduserPolicyOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "detach-policy", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserPasswordOptions struct {
|
||||
ID string `help:"Clouduser Id"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
R(&ClouduserPasswordOptions{}, "cloud-user-reset-password", "Reset clouduser password", func(s *mcclient.ClientSession, opts *ClouduserPasswordOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "reset-password", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserChangeOwnerOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
USER_ID string `help:"local user id"`
|
||||
}
|
||||
|
||||
R(&ClouduserChangeOwnerOptions{}, "cloud-user-change-owner", "Change clouduser owner", func(s *mcclient.ClientSession, opts *ClouduserChangeOwnerOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "change-owner", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ClouduserGroupOptions struct {
|
||||
ID string `help:"clouduser id"`
|
||||
CLOUDGROUP_ID string `help:"cloudgroup id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-join-group", "Join user to cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "join-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&ClouduserGroupOptions{}, "cloud-user-leave-group", "Leave from cloudgroup", func(s *mcclient.ClientSession, opts *ClouduserGroupOptions) error {
|
||||
result, err := modules.Cloudusers.PerformAction(s, opts.ID, "leave-group", jsonutils.Marshal(opts))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudusers).WithKeyword("cloud-user")
|
||||
cmd.List(&options.ClouduserListOptions{})
|
||||
cmd.Create(&options.ClouduserCreateOptions{})
|
||||
cmd.Show(&options.ClouduserIdOption{})
|
||||
cmd.Custom(shell.CustomActionGet, "login-info", &options.ClouduserIdOption{})
|
||||
cmd.Delete(&options.ClouduserIdOption{})
|
||||
cmd.Perform("sync", &options.ClouduserSyncOptions{})
|
||||
cmd.Perform("syncstatus", &options.ClouduserIdOption{})
|
||||
cmd.Perform("attach-policy", &options.ClouduserPolicyOptions{})
|
||||
cmd.Perform("detach-policy", &options.ClouduserPolicyOptions{})
|
||||
cmd.Perform("change-owner", &options.ClouduserChangeOwnerOptions{})
|
||||
cmd.Perform("cloud-user-join-group", &options.ClouduserGroupOptions{})
|
||||
cmd.Perform("cloud-user-leave-group", &options.ClouduserGroupOptions{})
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
@@ -26,12 +28,14 @@ import (
|
||||
|
||||
type ResourceCmd struct {
|
||||
manager modulebase.IBaseManager
|
||||
keyword string
|
||||
prefix string
|
||||
}
|
||||
|
||||
func NewResourceCmd(manager modulebase.IBaseManager) *ResourceCmd {
|
||||
return &ResourceCmd{
|
||||
manager: manager,
|
||||
keyword: manager.GetKeyword(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +44,17 @@ func (cmd *ResourceCmd) SetPrefix(prefix string) *ResourceCmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) WithKeyword(keyword string) *ResourceCmd {
|
||||
return cmd.SetKeyword(keyword)
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) SetKeyword(keyword string) *ResourceCmd {
|
||||
if len(keyword) > 0 {
|
||||
cmd.keyword = keyword
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
type IOpt interface {
|
||||
Params() (jsonutils.JSONObject, error)
|
||||
}
|
||||
@@ -65,8 +80,7 @@ func (cmd ResourceCmd) runWithDesc(action, desc string, args interface{}, callba
|
||||
if prefix != "" {
|
||||
prefix = cmd.prefix + "-"
|
||||
}
|
||||
keyword := man.GetKeyword()
|
||||
descKeyword := keyword
|
||||
descKeyword := man.GetKeyword()
|
||||
if _, ok := args.(IListOpt); ok {
|
||||
descKeyword = man.KeyString()
|
||||
}
|
||||
@@ -77,7 +91,7 @@ func (cmd ResourceCmd) runWithDesc(action, desc string, args interface{}, callba
|
||||
if ok {
|
||||
desc = descArgs.Description()
|
||||
}
|
||||
R(args, fmt.Sprintf("%s%s-%s", prefix, keyword, action), desc, callback)
|
||||
R(args, fmt.Sprintf("%s%s-%s", prefix, cmd.keyword, action), desc, callback)
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) run(action string, args interface{}, callback interface{}) {
|
||||
@@ -158,6 +172,81 @@ func (cmd ResourceCmd) Show(args IShowOpt) {
|
||||
cmd.runWithDesc("show", fmt.Sprintf("Show details of a %s", man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IGetActionOpt interface {
|
||||
IOpt
|
||||
IIdOpt
|
||||
}
|
||||
|
||||
type TCustomAction string
|
||||
|
||||
const (
|
||||
CustomActionGet = TCustomAction("Get")
|
||||
CustomActionDo = TCustomAction("Do")
|
||||
)
|
||||
|
||||
func (cmd ResourceCmd) Custom(action TCustomAction, funcname string, args IGetActionOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IGetActionOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mod := man.(modulebase.Manager)
|
||||
modvalue := reflect.ValueOf(mod)
|
||||
funcvalue := modvalue.MethodByName(string(action) + utils.Kebab2Camel(funcname, "-"))
|
||||
if !funcvalue.IsValid() || funcvalue.IsNil() {
|
||||
return fmt.Errorf("funcname %s not found", funcname)
|
||||
}
|
||||
callParams := make([]reflect.Value, 0)
|
||||
callParams = append(callParams, reflect.ValueOf(s))
|
||||
if len(args.GetId()) > 0 {
|
||||
callParams = append(callParams, reflect.ValueOf(args.GetId()))
|
||||
}
|
||||
if params == nil {
|
||||
params = jsonutils.NewDict()
|
||||
}
|
||||
callParams = append(callParams, reflect.ValueOf(params))
|
||||
retValue := funcvalue.Call(callParams)
|
||||
retobj := retValue[0]
|
||||
reterr := retValue[1]
|
||||
if reterr.IsNil() {
|
||||
v, ok := retobj.Interface().(jsonutils.JSONObject)
|
||||
if ok {
|
||||
printObject(v)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
v, ok := reterr.Interface().(error)
|
||||
if ok {
|
||||
return v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc(funcname, fmt.Sprintf("Get %s of a %s", funcname, man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IDeleteOpt interface {
|
||||
IOpt
|
||||
IIdOpt
|
||||
}
|
||||
|
||||
func (cmd ResourceCmd) Delete(args IDeleteOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IDeleteOpt) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).Delete(s, args.GetId(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.runWithDesc("delete", fmt.Sprintf("Delete %s", man.GetKeyword()), args, callback)
|
||||
}
|
||||
|
||||
type IWithDescOpt interface {
|
||||
Description() string
|
||||
}
|
||||
|
||||
@@ -693,27 +693,43 @@ func (self *SCloudaccount) GetCloudaccountByProvider(provider string) ([]SClouda
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) SyncSystemCloudpoliciesFromCloud(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
accounts, err := self.GetCloudaccountByProvider(self.Provider)
|
||||
factory, err := self.GetProviderFactory()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetCloudaccountByProvider")
|
||||
return errors.Wrapf(err, "GetProviderFactory")
|
||||
}
|
||||
iPolicies := []cloudprovider.ICloudpolicy{}
|
||||
policyMaps := map[string]bool{}
|
||||
for i := range accounts {
|
||||
provider, err := accounts[i].GetProvider()
|
||||
if !factory.IsSystemCloudpolicyUnified() {
|
||||
accounts, err := self.GetCloudaccountByProvider(self.Provider)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetProvider for account %s(%s)", accounts[i].Name, accounts[i].Provider)
|
||||
return errors.Wrapf(err, "GetCloudaccountByProvider")
|
||||
}
|
||||
policies, err := provider.GetISystemCloudpolicies()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetISystemCloudpolicies for account %s(%s)", accounts[i].Name, accounts[i].Provider)
|
||||
}
|
||||
for i := range policies {
|
||||
_, ok := policyMaps[policies[i].GetGlobalId()]
|
||||
if !ok {
|
||||
policyMaps[policies[i].GetGlobalId()] = true
|
||||
iPolicies = append(iPolicies, policies[i])
|
||||
policyMaps := map[string]bool{}
|
||||
for i := range accounts {
|
||||
provider, err := accounts[i].GetProvider()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetProvider for account %s(%s)", accounts[i].Name, accounts[i].Provider)
|
||||
}
|
||||
policies, err := provider.GetISystemCloudpolicies()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetISystemCloudpolicies for account %s(%s)", accounts[i].Name, accounts[i].Provider)
|
||||
}
|
||||
log.Debugf("Get %d System cloudpolicy from account %s(%s)", len(policies), accounts[i].Name, accounts[i].Provider)
|
||||
for i := range policies {
|
||||
_, ok := policyMaps[policies[i].GetGlobalId()]
|
||||
if !ok {
|
||||
policyMaps[policies[i].GetGlobalId()] = true
|
||||
iPolicies = append(iPolicies, policies[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
provider, err := self.GetProvider()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetProvider for account %s(%s)", self.Name, self.Provider)
|
||||
}
|
||||
iPolicies, err = provider.GetISystemCloudpolicies()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetISystemCloudpolicies for account %s(%s)", self.Name, self.Provider)
|
||||
}
|
||||
}
|
||||
return self.syncSystemCloudpoliciesFromCloud(ctx, userCred, iPolicies)
|
||||
@@ -944,6 +960,11 @@ func (manager *SCloudaccountManager) SyncCloudidSystemPolicies(ctx context.Conte
|
||||
if utils.IsInStringArray(accounts[i].Provider, providers) {
|
||||
continue
|
||||
}
|
||||
_, err := accounts[i].GetProvider() // 检查账号是否可以正常连接
|
||||
if err != nil {
|
||||
log.Errorf("GetProvider for account %s(%s) error: %v", accounts[i].Name, accounts[i].Provider, err)
|
||||
continue
|
||||
}
|
||||
err = accounts[i].StartSystemCloudpolicySyncTask(ctx, userCred, "")
|
||||
if err != nil {
|
||||
log.Errorf("StartSystemCloudpolicySyncTask for account %s(%s) error: %v", accounts[i].Name, accounts[i].Provider, err)
|
||||
|
||||
@@ -201,6 +201,8 @@ type ICloudProviderFactory interface {
|
||||
GetClouduserMinPolicyCount() int
|
||||
IsClouduserNeedInitPolicy() bool
|
||||
IsSupportCreateCloudgroup() bool
|
||||
|
||||
IsSystemCloudpolicyUnified() bool // 国内国外权限是否一致
|
||||
}
|
||||
|
||||
type ICloudProvider interface {
|
||||
@@ -566,6 +568,10 @@ func (factory *baseProviderFactory) IsSupportCreateCloudgroup() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (factory *baseProviderFactory) IsSystemCloudpolicyUnified() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type SPremiseBaseProviderFactory struct {
|
||||
baseProviderFactory
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
// 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 options
|
||||
|
||||
import "yunion.io/x/jsonutils"
|
||||
|
||||
type CloudgroupListOptions struct {
|
||||
BaseListOptions
|
||||
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudpolicyId string `json:"cloudpolicy_id"`
|
||||
Usable bool `json:"usable"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
|
||||
type CloudgroupCreateOptions struct {
|
||||
NAME string `json:"name"`
|
||||
PROVIDER string `json:"provider" choices:"Google|Aliyun|Aws|Huawei|Qcloud"`
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
Desc string `json:"description"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(opts), nil
|
||||
}
|
||||
|
||||
type CloudgroupIdOptions struct {
|
||||
ID string `help:"Cloudgroup Id"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupIdOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *CloudgroupIdOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type CloudgroupPolicyOptions struct {
|
||||
CloudgroupIdOptions
|
||||
CLOUDPOLICY_ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupPolicyOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"cloudpolicy_id": opts.CLOUDPOLICY_ID}), nil
|
||||
}
|
||||
|
||||
type CloudgroupUserOptions struct {
|
||||
CloudgroupIdOptions
|
||||
CLOUDUSER_ID string `help:"Clouduser Id"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupUserOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"clouduser_id": opts.CLOUDUSER_ID}), nil
|
||||
}
|
||||
|
||||
type CloudgroupPoliciesOptions struct {
|
||||
CloudgroupIdOptions
|
||||
CloudpolicyIds []string `json:"cloudpolicy_ids"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupPoliciesOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string][]string{"cloudpolicy_ids": opts.CloudpolicyIds}), nil
|
||||
}
|
||||
|
||||
type CloudgroupUsersOptions struct {
|
||||
CloudgroupIdOptions
|
||||
ClouduserIds []string `json:"clouduser_ids"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupUsersOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string][]string{"clouduser_ids": opts.ClouduserIds}), nil
|
||||
}
|
||||
|
||||
type CloudgroupPublicOptions struct {
|
||||
CloudgroupIdOptions
|
||||
Scope string `help:"sharing scope" choices:"system|domain"`
|
||||
SharedDomains []string `help:"share to domains"`
|
||||
}
|
||||
|
||||
func (opts *CloudgroupPublicOptions) Params() (jsonutils.JSONObject, error) {
|
||||
params := jsonutils.NewDict()
|
||||
if len(opts.Scope) > 0 {
|
||||
params.Add(jsonutils.NewString(opts.Scope), "scope")
|
||||
}
|
||||
if len(opts.SharedDomains) > 0 {
|
||||
params.Add(jsonutils.Marshal(opts.SharedDomains), "shared_domains")
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// 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 options
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
)
|
||||
|
||||
type CloudpolicyListOptions struct {
|
||||
BaseListOptions
|
||||
|
||||
CloudproviderId string `json:"cloudprovider_id"`
|
||||
ClouduserId string `json:"clouduser_id"`
|
||||
CloudgroupId string `json:"cloudgroup_id"`
|
||||
PolicyType string `help:"Filter cloudpolicy by policy type" choices:"system|custom"`
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
|
||||
type CloudpolicyIdOptions struct {
|
||||
ID string `help:"Cloudpolicy Id"`
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyIdOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyIdOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type CloudpolicyGroupOptions struct {
|
||||
CloudpolicyIdOptions
|
||||
CLOUDGROUP_ID string `help:"Cloudgroup Id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyGroupOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"cloudgroup_id": opts.CLOUDGROUP_ID}), nil
|
||||
}
|
||||
|
||||
type CloudpolicyUpdateOption struct {
|
||||
CloudpolicyIdOptions
|
||||
Name string
|
||||
Description string
|
||||
PolicyDocument string
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyUpdateOption) Params() (jsonutils.JSONObject, error) {
|
||||
params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
|
||||
params.Remove("policy_document")
|
||||
if len(opts.PolicyDocument) > 0 {
|
||||
document, err := jsonutils.Parse([]byte(opts.PolicyDocument))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid policy document")
|
||||
}
|
||||
params.Add(document, "document")
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
type CloudpolicyCreateOption struct {
|
||||
NAME string
|
||||
PROVIDER string `choices:"Aliyun|Google|Aws|Azure|Huawei"`
|
||||
Descritpion string
|
||||
POLICY_DOCUMENT string
|
||||
}
|
||||
|
||||
func (opts *CloudpolicyCreateOption) Params() (jsonutils.JSONObject, error) {
|
||||
params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
|
||||
params.Remove("policy_document")
|
||||
document, err := jsonutils.Parse([]byte(opts.POLICY_DOCUMENT))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid policy document")
|
||||
}
|
||||
params.Add(document, "document")
|
||||
return params, nil
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// 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 options
|
||||
|
||||
import "yunion.io/x/jsonutils"
|
||||
|
||||
type ClouduserListOptions struct {
|
||||
BaseListOptions
|
||||
CloudaccountId string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
CloudpolicyId string `help:"filter cloudusers by cloudpolicy"`
|
||||
CloudgroupId string `help:"filter cloudusers by cloudgroup"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
|
||||
type ClouduserCreateOptions struct {
|
||||
NAME string `help:"Clouduser name"`
|
||||
CLOUDACCOUNT_ID string `help:"Cloudaccount Id"`
|
||||
CloudproviderId string `help:"Cloudprovider Id"`
|
||||
OwnerId string `help:"Owner Id"`
|
||||
CloudpolicyIds []string `help:"cloudpolicy ids"`
|
||||
CloudgroupIds []string `help:"cloudgroup ids"`
|
||||
Email string `help:"email address"`
|
||||
MobilePhone string `help:"phone number"`
|
||||
IsConsoleLogin *bool `help:"is console login"`
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(opts), nil
|
||||
}
|
||||
|
||||
type ClouduserIdOption struct {
|
||||
ID string `help:"Clouduser Id or name"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserIdOption) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *ClouduserIdOption) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type ClouduserSyncOptions struct {
|
||||
ClouduserIdOption
|
||||
PolicyOnly bool `help:"Ony sync clouduser policies for cloud"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserSyncOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]bool{"policy_only": opts.PolicyOnly}), nil
|
||||
}
|
||||
|
||||
type ClouduserPolicyOptions struct {
|
||||
ClouduserIdOption
|
||||
CLOUDPOLICY_ID string `help:"cloudpolicy Id"`
|
||||
CloudproviderId string `help:"cloudprovider Id"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserPolicyOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{
|
||||
"cloudpolicy_id": opts.CLOUDPOLICY_ID,
|
||||
"cloudprovider_id": opts.CloudproviderId,
|
||||
}), nil
|
||||
}
|
||||
|
||||
type ClouduserPasswordOptions struct {
|
||||
ClouduserIdOption
|
||||
Password string `help:"clouduser password"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserPasswordOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"password": opts.Password}), nil
|
||||
}
|
||||
|
||||
type ClouduserChangeOwnerOptions struct {
|
||||
ClouduserIdOption
|
||||
USER_ID string `help:"local user id"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserChangeOwnerOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"user_id": opts.USER_ID}), nil
|
||||
}
|
||||
|
||||
type ClouduserGroupOptions struct {
|
||||
ClouduserIdOption
|
||||
CLOUDGROUP_ID string `help:"cloudgroup id" json:"cloudgroup_id"`
|
||||
}
|
||||
|
||||
func (opts *ClouduserGroupOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return jsonutils.Marshal(map[string]string{"cloudgroup_id": opts.CLOUDGROUP_ID}), nil
|
||||
}
|
||||
@@ -51,6 +51,10 @@ func (self *SAliyunProviderFactory) IsSupportCreateCloudgroup() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (factory *SAliyunProviderFactory) IsSystemCloudpolicyUnified() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SAliyunProviderFactory) ValidateCreateCloudaccountData(ctx context.Context, userCred mcclient.TokenCredential, input cloudprovider.SCloudaccountCredential) (cloudprovider.SCloudaccount, error) {
|
||||
output := cloudprovider.SCloudaccount{}
|
||||
if len(input.AccessKeyId) == 0 {
|
||||
|
||||
@@ -51,6 +51,10 @@ func (self *SAwsProviderFactory) IsSupportCreateCloudgroup() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (factory *SAwsProviderFactory) IsSystemCloudpolicyUnified() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SAwsProviderFactory) ValidateCreateCloudaccountData(ctx context.Context, userCred mcclient.TokenCredential, input cloudprovider.SCloudaccountCredential) (cloudprovider.SCloudaccount, error) {
|
||||
output := cloudprovider.SCloudaccount{}
|
||||
if len(input.AccessKeyId) == 0 {
|
||||
|
||||
@@ -214,7 +214,7 @@ func (self *SGoogleProvider) GetAccountId() string {
|
||||
return self.client.GetAccountId()
|
||||
}
|
||||
|
||||
func (self *SGoogleProvider) GetIamLoginUlr() string {
|
||||
func (self *SGoogleProvider) GetIamLoginUrl() string {
|
||||
return "https://console.cloud.google.com"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user