diff --git a/pkg/util/ucloud/shell/instance.go b/pkg/util/ucloud/shell/instance.go index 914d390c3c..573cb0ff69 100644 --- a/pkg/util/ucloud/shell/instance.go +++ b/pkg/util/ucloud/shell/instance.go @@ -46,22 +46,24 @@ func init() { }) type InstanceCrateOptions struct { - NAME string `help:"name of instance"` - IMAGE string `help:"image ID"` - HOSTTYPE string `help:"host type" choices:"N1|N2|N3|C1||I2|G1|G2|G3|I1"` - PASSWORD string `help:"password"` - VPC string `help:"VPC ID"` - NETWORK string `help:"Network ID"` - SECGROUP string `help:"secgroup ID"` - ZONE string `help:"zone ID"` - CPU int `help:"CPU count"` - MEMORYGB int `help:"MemoryGB"` - STORAGE string `help:"Storage type" choices:"CLOUD_NORMAL|CLOUD_SSD"` - DISKSIZE int `help:"root disk size GB"` + NAME string `help:"name of instance"` + IMAGE string `help:"image ID"` + INSTANCETYPE string `help:"intance type.eg. N2.c1.m1"` + PASSWORD string `help:"password"` + VPC string `help:"VPC ID"` + NETWORK string `help:"Network ID"` + SECGROUP string `help:"secgroup ID"` + ZONE string `help:"zone ID"` + STORAGE string `help:"Storage type" choices:"CLOUD_NORMAL|CLOUD_SSD|LOCAL_NORMAL|LOCAL_SSD"` + DISKSIZE int `help:"root disk size GB"` } shellutils.R(&InstanceCrateOptions{}, "instance-create", "Create a instance", func(cli *ucloud.SRegion, args *InstanceCrateOptions) error { disk := ucloud.SDisk{DiskType: args.STORAGE, SizeGB: args.DISKSIZE} - instance, e := cli.CreateInstance(args.NAME, args.IMAGE, args.HOSTTYPE, args.PASSWORD, args.VPC, args.NETWORK, args.SECGROUP, args.ZONE, "", "", args.CPU, args.MEMORYGB*1024, 0, []ucloud.SDisk{disk}, nil) + i, err := ucloud.ParseInstanceType(args.INSTANCETYPE) + if err != nil { + return err + } + instance, e := cli.CreateInstance(args.NAME, args.IMAGE, i.UHostType, args.PASSWORD, args.VPC, args.NETWORK, args.SECGROUP, args.ZONE, "", "", i.CPU, i.MemoryMB, i.GPU, []ucloud.SDisk{disk}, nil) if e != nil { return e } diff --git a/pkg/util/ucloud/ucloud.go b/pkg/util/ucloud/ucloud.go index 79ca65abd7..c0627ce2b0 100644 --- a/pkg/util/ucloud/ucloud.go +++ b/pkg/util/ucloud/ucloud.go @@ -19,8 +19,6 @@ import ( "net/http" "strings" - "yunion.io/x/log" - api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudprovider" ) @@ -113,8 +111,6 @@ func (self *SUcloudClient) UpdateAccount(accessKey, secret string) error { func (self *SUcloudClient) commonParams(params SParams, action string) (string, SParams) { resultKey, exists := UCLOUD_API_RESULT_KEYS[action] if !exists || len(resultKey) == 0 { - log.Debugf("Do %s no result key found or result key is empty", action) - // default key for describe actions if strings.HasPrefix(action, "Describe") { resultKey = "DataSet"