v1.5.0-epsilon

1.5.8-k8s-extnet-branch v1.5.0-epsilon
Nikita Sorokin 2 years ago
parent 5025a17ea4
commit 0be4d8fb0c

@ -2,6 +2,7 @@ package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -64,7 +65,7 @@ type CreateRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Input data for cloud-init facility
// Required: false
@ -87,6 +88,11 @@ type CreateRequest struct {
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
}
type wrapperCreateRequest struct {
CreateRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// Create creates KVM PowerPC VM based on specified OS image
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -96,9 +102,25 @@ func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
}
}
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))
}
reqWrapped := wrapperCreateRequest{
CreateRequest: req,
Interfaces: interfaces,
}
url := "/cloudapi/kvmppc/create"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -42,13 +43,18 @@ type CreateBlankRequest struct {
// Slice of structs with net interface description
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
type wrapperCreateBlankRequest struct {
CreateBlankRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// CreateBlank creates KVM PowerPC VM from scratch
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -58,9 +64,25 @@ func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
}
}
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))
}
reqWrapped := wrapperCreateBlankRequest{
CreateBlankRequest: req,
Interfaces: interfaces,
}
url := "/cloudapi/kvmppc/createBlank"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmx86
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -64,7 +65,7 @@ type CreateRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Input data for cloud-init facility
// Required: false
@ -87,6 +88,11 @@ type CreateRequest struct {
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
}
type wrapperCreateRequest struct {
CreateRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// Create creates KVM x86 VM based on specified OS image
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -96,9 +102,25 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
}
}
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))
}
reqWrapped := wrapperCreateRequest{
CreateRequest: req,
Interfaces: interfaces,
}
url := "/cloudapi/kvmx86/create"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmx86
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -42,13 +43,18 @@ type CreateBlankRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
type wrapperCreateBlankRequest struct {
CreateBlankRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// CreateBlank creates KVM x86 VM from scratch
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -58,9 +64,25 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
}
}
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))
}
reqWrapped := wrapperCreateBlankRequest{
CreateBlankRequest: req,
Interfaces: interfaces,
}
url := "/cloudapi/kvmx86/createBlank"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -64,7 +65,7 @@ type CreateRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Input data for cloud-init facility
// Required: false
@ -87,6 +88,11 @@ type CreateRequest struct {
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
}
type wrapperCreateRequest struct {
CreateRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// Create creates KVM PowerPC VM based on specified OS image
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -96,9 +102,25 @@ func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
}
}
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))
}
reqWrapped := wrapperCreateRequest{
CreateRequest: req,
Interfaces: interfaces,
}
url := "/cloudbroker/kvmppc/create"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmppc
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -42,13 +43,18 @@ type CreateBlankRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
type wrapperCreateBlankRequest struct {
CreateBlankRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// CreateBlank creates KVM PowerPC VM from scratch
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -58,9 +64,25 @@ func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
}
}
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))
}
reqWrapped := wrapperCreateBlankRequest{
CreateBlankRequest: req,
Interfaces: interfaces,
}
url := "/cloudbroker/kvmppc/createBlank"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmx86
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -64,7 +65,7 @@ type CreateRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Input data for cloud-init facility
// Required: false
@ -99,6 +100,11 @@ type CreateRequest struct {
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
type wrapperCreateRequest struct {
CreateRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// Create creates KVM PowerPC VM based on specified OS image
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -108,9 +114,25 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
}
}
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))
}
reqWrapped := wrapperCreateRequest{
CreateRequest: req,
Interfaces: interfaces,
}
url := "/cloudbroker/kvmx86/create"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

@ -2,6 +2,7 @@ package kvmx86
import (
"context"
"encoding/json"
"net/http"
"strconv"
@ -42,13 +43,18 @@ type CreateBlankRequest struct {
// Slice of structs with net interface description.
// Required: false
Interfaces []Interface `url:"interfaces,omitempty" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,min=1,dive"`
// Text description of this VM
// Required: false
Description string `url:"desc,omitempty" json:"desc,omitempty"`
}
type wrapperCreateBlankRequest struct {
CreateBlankRequest
Interfaces []string `url:"interfaces,omitempty"`
}
// CreateBlank creates KVM x86 VM from scratch
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
err := validators.ValidateRequest(req)
@ -58,9 +64,25 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
}
}
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))
}
reqWrapped := wrapperCreateBlankRequest{
CreateBlankRequest: req,
Interfaces: interfaces,
}
url := "/cloudbroker/kvmx86/createBlank"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return 0, err
}

Loading…
Cancel
Save