v1.5.0
This commit is contained in:
@@ -64,8 +64,10 @@ type CreateRequest struct {
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// 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
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Input data for cloud-init facility
|
||||
// Required: false
|
||||
@@ -102,15 +104,21 @@ func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
interfaces := make([]string, 0, len(req.Interfaces))
|
||||
var interfaces []string
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
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 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
|
||||
@@ -42,8 +42,10 @@ type CreateBlankRequest struct {
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// 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
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
@@ -64,15 +66,21 @@ func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
}
|
||||
}
|
||||
|
||||
interfaces := make([]string, 0, len(req.Interfaces))
|
||||
var interfaces []string
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
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 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
|
||||
@@ -49,8 +49,10 @@ type MassCreateRequest struct {
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// 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
|
||||
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
|
||||
// Required: false
|
||||
@@ -69,6 +71,11 @@ type MassCreateRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperMassCreateRequest struct {
|
||||
MassCreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
}
|
||||
|
||||
// MassCreate creates KVM PPC computes based on specified OS image
|
||||
func (k KVMPPC) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -78,9 +85,31 @@ func (k KVMPPC) 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/kvmppc/massCreate"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -64,8 +64,10 @@ type CreateRequest struct {
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// 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
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Input data for cloud-init facility
|
||||
// Required: false
|
||||
@@ -114,15 +116,21 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
interfaces := make([]string, 0, len(req.Interfaces))
|
||||
var interfaces []string
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
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 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
|
||||
@@ -42,8 +42,10 @@ type CreateBlankRequest struct {
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// 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
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
@@ -64,15 +66,21 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
}
|
||||
}
|
||||
|
||||
interfaces := make([]string, 0, len(req.Interfaces))
|
||||
var interfaces []string
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
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 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
|
||||
@@ -49,8 +49,10 @@ type MassCreateRequest struct {
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// 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
|
||||
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
|
||||
// Required: false
|
||||
@@ -69,6 +71,11 @@ type MassCreateRequest struct {
|
||||
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
|
||||
func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64, error) {
|
||||
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"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user