Merge pull request #549 in YUNIONIO/onecloud from ~ZHOUYOUSONG/onecloud:bugfix/yousong-cloudprovider-no-creation to release/2.3.0

* commit 'cf2b42f78b5abbff4c4b1a91e7c3bcc4a54ce6ef':
  climc: cloudprovider: drop cloud-provider-create command
  cloudproviders: reword error message in create data validation
This commit is contained in:
邱剑
2018-11-20 18:47:23 +08:00
2 changed files with 1 additions and 33 deletions
-32
View File
@@ -31,38 +31,6 @@ func init() {
return nil
})
type CloudproviderCreateOptions struct {
NAME string `help:"Name of cloud provider"`
ACCOUNT string `help:"Account to access the cloud provider, tenantId/subscriptionId for Azure"`
SECRET string `help:"Secret to access the cloud provider, clientId/clientScret for Azure"`
PROVIDER string `help:"Driver for cloud provider" choices:"VMware|Aliyun|Azure"`
AccessURL string `helo:"hello" metavar:"Azure choices: <AzureGermanCloud、AzureChinaCloud、AzureUSGovernmentCloud、AzurePublicCloud>"`
Desc string `help:"Description"`
Enabled bool `help:"Enabled the provider automatically"`
}
R(&CloudproviderCreateOptions{}, "cloud-provider-create", "Create a cloud provider", func(s *mcclient.ClientSession, args *CloudproviderCreateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.NAME), "name")
params.Add(jsonutils.NewString(args.ACCOUNT), "account")
params.Add(jsonutils.NewString(args.SECRET), "secret")
params.Add(jsonutils.NewString(args.PROVIDER), "provider")
if args.Enabled {
params.Add(jsonutils.JSONTrue, "enabled")
}
if len(args.AccessURL) > 0 {
params.Add(jsonutils.NewString(args.AccessURL), "access_url")
}
if len(args.Desc) > 0 {
params.Add(jsonutils.NewString(args.Desc), "description")
}
result, err := modules.Cloudproviders.Create(s, params)
if err != nil {
return err
}
printObject(result)
return nil
})
type CloudproviderUpdateOptions struct {
ID string `help:"ID or Name of cloud provider"`
Name string `help:"New name to update"`
+1 -1
View File
@@ -130,7 +130,7 @@ func (self *SCloudprovider) ValidateUpdateData(ctx context.Context, userCred mcc
}
func (self *SCloudproviderManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
return nil, httperrors.NewUnsupportOperationError("Not support create cloudprovider, please considir create cloudaccount")
return nil, httperrors.NewUnsupportOperationError("Directly creating cloudprovider is not supported, create cloudaccount instead")
}
func (self *SCloudprovider) getPassword() (string, error) {