mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): not set default data when batch creating disks
This commit is contained in:
@@ -226,11 +226,16 @@ func init() {
|
||||
if args.TaskNotify {
|
||||
s.PrepareTask()
|
||||
}
|
||||
disk, err := modules.Disks.Create(s, params.JSON(params))
|
||||
if err != nil {
|
||||
return err
|
||||
if args.Count > 1 {
|
||||
results := modules.Disks.BatchCreate(s, params.JSON(params), args.Count)
|
||||
printBatchResults(results, modules.Disks.GetColumns(s))
|
||||
} else {
|
||||
disk, err := modules.Disks.Create(s, params.JSON(params))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(disk)
|
||||
}
|
||||
printObject(disk)
|
||||
if args.TaskNotify {
|
||||
s.WaitTaskNotify()
|
||||
}
|
||||
|
||||
@@ -459,6 +459,14 @@ func (self *SDisk) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (man *SDiskManager) BatchCreateValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input api.DiskCreateInput) (*jsonutils.JSONDict, error) {
|
||||
input, err := man.ValidateCreateData(ctx, userCred, ownerId, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return input.JSON(input), nil
|
||||
}
|
||||
|
||||
func diskCreateInput2ComputeQuotaKeys(input api.DiskCreateInput, ownerId mcclient.IIdentityProvider) SComputeResourceKeys {
|
||||
// input.Hypervisor must be set
|
||||
brand := guessBrandForHypervisor(input.Hypervisor)
|
||||
|
||||
@@ -25,6 +25,7 @@ type DiskCreateOptions struct {
|
||||
Zone string `help:"Preferred zone where virtual server should be created" json:"prefer_zone_id"`
|
||||
Wire string `help:"Preferred wire where virtual server should be created" json:"prefer_wire_id"`
|
||||
Host string `help:"Preferred host where virtual server should be created" json:"prefer_host_id"`
|
||||
Count int `help:"Count to create" json:"count"`
|
||||
|
||||
NAME string `help:"Name of the disk"`
|
||||
DISKDESC string `help:"Image size or size of virtual disk"`
|
||||
@@ -35,9 +36,9 @@ type DiskCreateOptions struct {
|
||||
Schedtag []string `help:"Schedule policy, key = aggregate name, value = require|exclude|prefer|avoid" metavar:"<KEY:VALUE>"`
|
||||
TaskNotify bool `help:"Setup task notify"`
|
||||
SnapshotId string `help:"snapshot id"`
|
||||
BackupId string `help:"backupid"`
|
||||
BackupId string `help:"Backup id"`
|
||||
|
||||
Project string `help:"owner project"`
|
||||
Project string `help:"Owner project"`
|
||||
}
|
||||
|
||||
func (o DiskCreateOptions) Params() (*api.DiskCreateInput, error) {
|
||||
|
||||
Reference in New Issue
Block a user