|
|
@ -49,8 +49,10 @@ type MassCreateRequest struct {
|
|
|
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
|
|
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Slice of structs with net interface description.
|
|
|
|
// Slice of structs with net interface description.
|
|
|
|
|
|
|
|
// If not specified, compute will be created with default interface from RG.
|
|
|
|
|
|
|
|
// To create compute without interfaces, pass initialized empty slice .
|
|
|
|
// Required: false
|
|
|
|
// Required: false
|
|
|
|
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
|
|
|
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
|
|
|
|
|
|
|
|
|
|
|
// Input data for cloud-init facility
|
|
|
|
// Input data for cloud-init facility
|
|
|
|
// Required: false
|
|
|
|
// Required: false
|
|
|
@ -69,6 +71,11 @@ type MassCreateRequest struct {
|
|
|
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
|
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type wrapperMassCreateRequest struct {
|
|
|
|
|
|
|
|
MassCreateRequest
|
|
|
|
|
|
|
|
Interfaces []string `url:"interfaces,omitempty"`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MassCreate creates KVM x86 computes based on specified OS image
|
|
|
|
// MassCreate creates KVM x86 computes based on specified OS image
|
|
|
|
func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64, error) {
|
|
|
|
func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64, error) {
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
@ -78,9 +85,31 @@ func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var interfaces []string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
|
|
|
|
|
|
|
interfaces = make([]string, 0, len(req.Interfaces))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i := range req.Interfaces {
|
|
|
|
|
|
|
|
b, err := json.Marshal(req.Interfaces[i])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interfaces = append(interfaces, string(b))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
|
|
|
|
|
|
|
interfaces = []string{"[]"}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reqWrapped := wrapperMassCreateRequest{
|
|
|
|
|
|
|
|
MassCreateRequest: req,
|
|
|
|
|
|
|
|
Interfaces: interfaces,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/kvmx86/massCreate"
|
|
|
|
url := "/cloudbroker/kvmx86/massCreate"
|
|
|
|
|
|
|
|
|
|
|
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
|
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|