From 4c05d945526f85880f968d5807f86c68cb374bd6 Mon Sep 17 00:00:00 2001 From: dayterr Date: Tue, 15 Sep 2026 17:42:23 +0300 Subject: [PATCH] v16.3.0 v16.3.0 --- CHANGELOG.md | 42 ++++------ pkg/cloudapi/kvmx86/create.go | 2 +- pkg/cloudapi/locations/models.go | 3 + pkg/cloudapi/vins/create_in_account.go | 42 +++++++++- pkg/cloudapi/vins/create_in_rg.go | 42 +++++++++- pkg/cloudapi/vins/disable.go | 39 ++++++++++ pkg/cloudapi/vins/disable_enable.go | 62 --------------- pkg/cloudapi/vins/enable.go | 78 +++++++++++++++++++ pkg/cloudapi/vins/vnfdev_redeploy.go | 42 +++++++++- pkg/cloudapi/vins/vnfdev_restart.go | 42 +++++++++- pkg/cloudbroker/extnet/create.go | 63 ++++++++++++++- pkg/cloudbroker/extnet/device_deploy.go | 42 +++++++++- .../extnet/set_highly_available.go | 42 +++++++++- pkg/cloudbroker/kvmx86/create.go | 2 +- pkg/cloudbroker/vins/create_in_account.go | 42 +++++++++- pkg/cloudbroker/vins/create_in_rg.go | 42 +++++++++- pkg/cloudbroker/vins/enable.go | 42 +++++++++- pkg/cloudbroker/vins/vnfdev_redeploy.go | 42 +++++++++- pkg/cloudbroker/vins/vnfdev_restart.go | 42 +++++++++- pkg/cloudbroker/vins/vnfdev_start.go | 42 +++++++++- 20 files changed, 691 insertions(+), 104 deletions(-) create mode 100644 pkg/cloudapi/vins/disable.go delete mode 100644 pkg/cloudapi/vins/disable_enable.go create mode 100644 pkg/cloudapi/vins/enable.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 0227fd2c..6fa9bc34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ -## Version 16.2.0 +## Version 16.3.0 ### Deprecated -Перечисленные методы будут удалены в `v17` +Перечисленные методы будут удалены в `v1.17` | Метод | CloudAPI | CloudBroker | | --- | --- | --- | @@ -21,40 +21,28 @@ ### Добавлено -#### audit +#### extnet | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1025 | Вычисляемое поле `PublicSessionID` в структуры ответа `ItemAudit` и `RecordAudit` в cloudbroker/audit и cloudapi/audit | -| BGOS-1025 | Опциональное поле `PublicSessionID` в структуру запроса `ListRequest` в cloudbroker/audit и cloudapi/audit | +| BGOS-1034 | Методы `AsyncCreate`, `AsyncDeviceDeploy` и `AsyncSetHAMode` в cloudbroker/extnet | -#### grid + +#### locations | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1028 | Вычисляемое поле `Budget` в структуры ответа `ItemGridList` и `RecordGrid` в cloudbroker/grid | +| BGOS-1032 | Вычисляемое поле `VMFoldersEnabled` в структуру ответа `ItemLocation` в cloudapi/locations | #### vins | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1027 | Вычисляемое поле `QoSPolicies` в структуру ответа `ItemVNFInterface` в cloudbroker/vins и cloudapi/vins | +| BGOS-1033 | Методы `AsyncCreateInAccount`, `AsyncCreateInRG`, `AsyncEnable`, `AsyncVNFDevRedeploy` и `AsyncVNFDevRestart` в cloudapi/vins | +| BGOS-1033 | Методы `AsyncCreateInAccount`, `AsyncCreateInRG`, `AsyncEnable`, `AsyncVNFDevRedeploy`, `AsyncVNFDevRestart` и `AsyncVNFDevStart` в cloudbroker/vins | +| BGOS-1033 | Структура запроса `DisableRequest` и метод `Disable` в cloudapi/vins | +| BGOS-1033 | Структура запроса `EnableRequest` и метод `Enable` в cloudapi/vins | -#### session +### Исправлено + +#### kvmx86 | Идентификатор задачи | Описание | | --- | --- | -| BGOS-1026 | Группа ручек cloudbroker/session | - - -### Изменено - -#### network qos policy -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1030 | Тип вычисляемых полей `PCPTag` и `DSCPValue` с `uint64` на `*uint64` в структуре ответа `Rule` в cloudapi/qospolicy и cloudbroker/qospolicy | -| BGOS-1030 | Тип опциональных полей `Name` и `Description` с `string` на `*string` в структуре запроса `UpdateRequest` в cloudapi/qospolicy и cloudbroker/qospolicy | - - -### Удалено - -#### compute -| Идентификатор задачи | Описание | -| --- | --- | -| BGOS-1029 | Опциональное поле `Type` из структуры запроса `ListVGPURequest` в cloudbroker/compute и cloudapi/compute | +| BGOS-1040 | JSON-тэг опционального поля `AsyncMode` с `asyncMode` на `async_mode` в структуре запроса `CreateRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 | diff --git a/pkg/cloudapi/kvmx86/create.go b/pkg/cloudapi/kvmx86/create.go index 9dc671d5..d3c2bb13 100644 --- a/pkg/cloudapi/kvmx86/create.go +++ b/pkg/cloudapi/kvmx86/create.go @@ -265,7 +265,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 { type wrapperCreateRequest struct { CreateRequest - AsyncMode bool `json:"asyncMode"` + AsyncMode bool `json:"async_mode"` } // Create creates KVM x86 VM based on specified OS image diff --git a/pkg/cloudapi/locations/models.go b/pkg/cloudapi/locations/models.go index a83b5b2c..623bee28 100644 --- a/pkg/cloudapi/locations/models.go +++ b/pkg/cloudapi/locations/models.go @@ -43,6 +43,9 @@ type ItemLocation struct { // Is BRO enabled BROEnabled bool `json:"bro_enabled"` + + // Are VM Folders enabled + VMFoldersEnabled bool `json:"vm_folders_enabled"` } // List of locations diff --git a/pkg/cloudapi/vins/create_in_account.go b/pkg/cloudapi/vins/create_in_account.go index 7e4d1f47..84cfc7cd 100644 --- a/pkg/cloudapi/vins/create_in_account.go +++ b/pkg/cloudapi/vins/create_in_account.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -69,6 +70,11 @@ type CreateInAccountRequest struct { EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } +type asyncWrapperCreateInAccountRequest struct { + CreateInAccountRequest + AsyncMode bool `url:"asyncMode" json:"asyncMode"` +} + // CreateInAccount creates VINS in account level func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( url := "/cloudapi/vins/createInAccount" - res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + syncReq := asyncWrapperCreateInAccountRequest{ + CreateInAccountRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) if err != nil { return 0, err } @@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( return result, nil } + +// CreateInAccount creates VINS in account level in async mode +func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + asyncReq := asyncWrapperCreateInAccountRequest{ + CreateInAccountRequest: req, + AsyncMode: true, + } + + url := "/cloudapi/vins/createInAccount" + + result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudapi/vins/create_in_rg.go b/pkg/cloudapi/vins/create_in_rg.go index 31236fb1..a380b86b 100644 --- a/pkg/cloudapi/vins/create_in_rg.go +++ b/pkg/cloudapi/vins/create_in_rg.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -63,6 +64,11 @@ type CreateInRGRequest struct { EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } +type asyncWrapperCreateInRgRequest struct { + CreateInRGRequest + AsyncMode bool `url:"asyncMode" json:"asyncMode"` +} + // CreateInRG creates VINS in resource group level func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er url := "/cloudapi/vins/createInRG" - res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + syncReq := asyncWrapperCreateInRgRequest{ + CreateInRGRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) if err != nil { return 0, err } @@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er return result, nil } + +// CreateInRG creates VINS in resource group level in async mode +func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/createInRG" + + syncReq := asyncWrapperCreateInRgRequest{ + CreateInRGRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudapi/vins/disable.go b/pkg/cloudapi/vins/disable.go new file mode 100644 index 00000000..f8b4423f --- /dev/null +++ b/pkg/cloudapi/vins/disable.go @@ -0,0 +1,39 @@ +package vins + +import ( + "context" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// DisableRequest struct to disable VINS +type DisableRequest struct { + // VINS ID + // Required: true + VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` +} + +// Disable disables VINS +func (v VINS) Disable(ctx context.Context, req DisableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/disable" + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil + +} diff --git a/pkg/cloudapi/vins/disable_enable.go b/pkg/cloudapi/vins/disable_enable.go deleted file mode 100644 index 31b15868..00000000 --- a/pkg/cloudapi/vins/disable_enable.go +++ /dev/null @@ -1,62 +0,0 @@ -package vins - -import ( - "context" - "net/http" - "strconv" - - "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" -) - -// DisableEnableRequest struct to disable/enable VINS -type DisableEnableRequest struct { - // VINS ID - // Required: true - VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` -} - -// Disable disables VINS -func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/vins/disable" - - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil - -} - -// Enable enables VINS -func (v VINS) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) { - err := validators.ValidateRequest(req) - if err != nil { - return false, validators.ValidationErrors(validators.GetErrors(err)) - } - - url := "/cloudapi/vins/enable" - - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) - if err != nil { - return false, err - } - - result, err := strconv.ParseBool(string(res)) - if err != nil { - return false, err - } - - return result, nil - -} diff --git a/pkg/cloudapi/vins/enable.go b/pkg/cloudapi/vins/enable.go new file mode 100644 index 00000000..9a0c8a1f --- /dev/null +++ b/pkg/cloudapi/vins/enable.go @@ -0,0 +1,78 @@ +package vins + +import ( + "context" + "encoding/json" + "net/http" + "strconv" + + "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" +) + +// EnableRequest struct to enable VINS +type EnableRequest struct { + // VINS ID + // Required: true + VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` +} + +type asyncWrapperEnableRequest struct { + EnableRequest + AsyncMode bool `url:"asyncMode"` +} + +// Enable enables VINS +func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) { + err := validators.ValidateRequest(req) + if err != nil { + return false, validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/enable" + + syncReq := asyncWrapperEnableRequest{ + EnableRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) + if err != nil { + return false, err + } + + result, err := strconv.ParseBool(string(res)) + if err != nil { + return false, err + } + + return result, nil +} + +// Enable enables VINS by ID in async mode +func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/enable" + + asyncReq := asyncWrapperEnableRequest{ + EnableRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudapi/vins/vnfdev_redeploy.go b/pkg/cloudapi/vins/vnfdev_redeploy.go index 01ab0a51..73df504f 100644 --- a/pkg/cloudapi/vins/vnfdev_redeploy.go +++ b/pkg/cloudapi/vins/vnfdev_redeploy.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type VNFDevRedeployRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperVNFDevRedeployRequest struct { + VNFDevRedeployRequest + AsyncMode bool `url:"asyncMode"` +} + // VNFDevRedeploy redeploys VINS VNFDevs func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo url := "/cloudapi/vins/vnfdevRedeploy" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperVNFDevRedeployRequest{ + VNFDevRedeployRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo return result, nil } + +// VNFDevRedeploy redeploys VINS VNFDevs in async mode +func (v VINS) AsyncVNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/vnfdevRedeploy" + + asyncReq := asyncWrapperVNFDevRedeployRequest{ + VNFDevRedeployRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudapi/vins/vnfdev_restart.go b/pkg/cloudapi/vins/vnfdev_restart.go index 6ab46f1b..2e465ace 100644 --- a/pkg/cloudapi/vins/vnfdev_restart.go +++ b/pkg/cloudapi/vins/vnfdev_restart.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type VNFDevRestartRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperVNFDevRestartRequest struct { + VNFDevRestartRequest + AsyncMode bool `url:"asyncMode"` +} + // VNFDevRestart reboots VINSes primary VNF device func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool url := "/cloudapi/vins/vnfdevRestart" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperVNFDevRestartRequest{ + VNFDevRestartRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool return result, nil } + +// VNFDevRestart reboots VINSes primary VNF device in async mode +func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudapi/vins/vnfdevRestart" + + asyncReq := asyncWrapperVNFDevRestartRequest{ + VNFDevRestartRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/extnet/create.go b/pkg/cloudbroker/extnet/create.go index cbac34b1..784f2412 100644 --- a/pkg/cloudbroker/extnet/create.go +++ b/pkg/cloudbroker/extnet/create.go @@ -116,6 +116,11 @@ type wrapperCreateRequest struct { Routes []string `url:"routes,omitempty"` } +type asyncWrapperCreateRequest struct { + wrapperCreateRequest + AsyncMode bool `url:"async_mode"` +} + // Create creates new external network into platform func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -145,9 +150,14 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) { Routes: routes, } + reqWrappedAsync := asyncWrapperCreateRequest{ + wrapperCreateRequest: reqWrapped, + AsyncMode: true, + } + url := "/cloudbroker/extnet/create" - res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync) if err != nil { return 0, err } @@ -159,3 +169,54 @@ func (e ExtNet) Create(ctx context.Context, req CreateRequest) (uint64, error) { return result, nil } + +// AsyncCreate creates new external network into platform in async mode +func (e ExtNet) AsyncCreate(ctx context.Context, req CreateRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + var routes []string + + if len(req.Routes) != 0 { + routes = make([]string, 0, len(req.Routes)) + + for r := range req.Routes { + b, err := json.Marshal(req.Routes[r]) + if err != nil { + return "", err + } + + routes = append(routes, string(b)) + } + } else { + routes = []string{} + } + + reqWrapped := wrapperCreateRequest{ + CreateRequest: req, + Routes: routes, + } + + reqWrappedAsync := asyncWrapperCreateRequest{ + wrapperCreateRequest: reqWrapped, + AsyncMode: true, + } + + url := "/cloudbroker/extnet/create" + + result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, reqWrappedAsync) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/extnet/device_deploy.go b/pkg/cloudbroker/extnet/device_deploy.go index 0ede4d3d..bb317f29 100644 --- a/pkg/cloudbroker/extnet/device_deploy.go +++ b/pkg/cloudbroker/extnet/device_deploy.go @@ -2,6 +2,7 @@ package extnet import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type DeviceDeployRequest struct { NetID uint64 `url:"net_id" json:"net_id" validate:"required"` } +type asyncWrapperDeviceDeployRequest struct { + DeviceDeployRequest + AsyncMode bool `url:"async_mode"` +} + // DeviceDeploy deploys network device for external network (make not virtual, "physical") func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool url := "/cloudbroker/extnet/deviceDeploy" - res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperDeviceDeployRequest{ + DeviceDeployRequest: req, + AsyncMode: false, + } + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (e ExtNet) DeviceDeploy(ctx context.Context, req DeviceDeployRequest) (bool return result, nil } + +// AsyncDeviceDeploy deploys network device for external network (make not virtual, "physical") in async mode +func (e ExtNet) AsyncDeviceDeploy(ctx context.Context, req DeviceDeployRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/extnet/deviceDeploy" + + syncReq := asyncWrapperDeviceDeployRequest{ + DeviceDeployRequest: req, + AsyncMode: true, + } + + result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/extnet/set_highly_available.go b/pkg/cloudbroker/extnet/set_highly_available.go index 3e899762..e6b6ff42 100644 --- a/pkg/cloudbroker/extnet/set_highly_available.go +++ b/pkg/cloudbroker/extnet/set_highly_available.go @@ -2,6 +2,7 @@ package extnet import ( "context" + "encoding/json" "net/http" "strconv" @@ -19,6 +20,11 @@ type SetHAModeRequest struct { HAMode bool `url:"highly_available" json:"highly_available" validate:"required"` } +type asyncWrapperSetHAModeRequest struct { + SetHAModeRequest + AsyncMode bool `url:"async_mode"` +} + // SetHAMode set HA mode for external network func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -28,7 +34,12 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro url := "/cloudbroker/extnet/set_highly_available" - res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperSetHAModeRequest{ + SetHAModeRequest: req, + AsyncMode: true, + } + + res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -40,3 +51,32 @@ func (e ExtNet) SetHAMode(ctx context.Context, req SetHAModeRequest) (bool, erro return result, nil } + +// AsyncSetHAMode set HA mode for external network in async mode +func (e ExtNet) AsyncSetHAMode(ctx context.Context, req SetHAModeRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/extnet/set_highly_available" + + syncReq := asyncWrapperSetHAModeRequest{ + SetHAModeRequest: req, + AsyncMode: true, + } + + result, err := e.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/kvmx86/create.go b/pkg/cloudbroker/kvmx86/create.go index 7eba8184..a5d09f9b 100644 --- a/pkg/cloudbroker/kvmx86/create.go +++ b/pkg/cloudbroker/kvmx86/create.go @@ -288,7 +288,7 @@ func (r CreateRequest) GetRAM() map[string]uint64 { type wrapperCreateRequest struct { CreateRequest - AsyncMode bool `json:"asyncMode"` + AsyncMode bool `json:"async_mode"` } // Create creates KVM PowerPC VM based on specified OS image diff --git a/pkg/cloudbroker/vins/create_in_account.go b/pkg/cloudbroker/vins/create_in_account.go index 9a1083b1..b9e2b5b9 100644 --- a/pkg/cloudbroker/vins/create_in_account.go +++ b/pkg/cloudbroker/vins/create_in_account.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -69,6 +70,11 @@ type CreateInAccountRequest struct { EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } +type asyncWrapperCreateInAccountRequest struct { + CreateInAccountRequest + AsyncMode bool `url:"asyncMode" json:"asyncMode"` +} + // CreateInAccount creates VINS in account level func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -78,7 +84,12 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( url := "/cloudbroker/vins/createInAccount" - res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + syncReq := asyncWrapperCreateInAccountRequest{ + CreateInAccountRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) if err != nil { return 0, err } @@ -90,3 +101,32 @@ func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) ( return result, nil } + +// CreateInAccount creates VINS in account level in async mode +func (v VINS) AsyncCreateInAccount(ctx context.Context, req CreateInAccountRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + asyncReq := asyncWrapperCreateInAccountRequest{ + CreateInAccountRequest: req, + AsyncMode: true, + } + + url := "/cloudbroker/vins/createInAccount" + + result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/vins/create_in_rg.go b/pkg/cloudbroker/vins/create_in_rg.go index 9b12deb8..ad2ac5a9 100644 --- a/pkg/cloudbroker/vins/create_in_rg.go +++ b/pkg/cloudbroker/vins/create_in_rg.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -63,6 +64,11 @@ type CreateInRGRequest struct { EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"` } +type asyncWrapperCreateInRgRequest struct { + CreateInRGRequest + AsyncMode bool `url:"asyncMode" json:"asyncMode"` +} + // CreateInRG creates VINS in resource group level func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) { err := validators.ValidateRequest(req) @@ -72,7 +78,12 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er url := "/cloudbroker/vins/createInRG" - res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) + syncReq := asyncWrapperCreateInRgRequest{ + CreateInRGRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) if err != nil { return 0, err } @@ -84,3 +95,32 @@ func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, er return result, nil } + +// CreateInRG creates VINS in resource group level in async mode +func (v VINS) AsyncCreateInRG(ctx context.Context, req CreateInRGRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/createInRG" + + syncReq := asyncWrapperCreateInRgRequest{ + CreateInRGRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, syncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/vins/enable.go b/pkg/cloudbroker/vins/enable.go index 7354a184..b8d0a942 100644 --- a/pkg/cloudbroker/vins/enable.go +++ b/pkg/cloudbroker/vins/enable.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type EnableRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperEnableRequest struct { + EnableRequest + AsyncMode bool `url:"asyncMode"` +} + // Enable enables VINS by ID func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) { url := "/cloudbroker/vins/enable" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperEnableRequest{ + EnableRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) Enable(ctx context.Context, req EnableRequest) (bool, error) { return result, nil } + +// Enable enables VINS by ID in async mode +func (v VINS) AsyncEnable(ctx context.Context, req EnableRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/enable" + + asyncReq := asyncWrapperEnableRequest{ + EnableRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/vins/vnfdev_redeploy.go b/pkg/cloudbroker/vins/vnfdev_redeploy.go index 856798a5..4095fa7b 100644 --- a/pkg/cloudbroker/vins/vnfdev_redeploy.go +++ b/pkg/cloudbroker/vins/vnfdev_redeploy.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type VNFDevRedeployRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperVNFDevRedeployRequest struct { + VNFDevRedeployRequest + AsyncMode bool `url:"asyncMode"` +} + // VNFDevRedeploy redeploys VINS VNFDevs func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo url := "/cloudbroker/vins/vnfdevRedeploy" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperVNFDevRedeployRequest{ + VNFDevRedeployRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (bo return result, nil } + +// VNFDevRedeploy redeploys VINS VNFDevs in async mode +func (v VINS) AsyncVNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/vnfdevRedeploy" + + asyncReq := asyncWrapperVNFDevRedeployRequest{ + VNFDevRedeployRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/vins/vnfdev_restart.go b/pkg/cloudbroker/vins/vnfdev_restart.go index 1e93d715..fb49963c 100644 --- a/pkg/cloudbroker/vins/vnfdev_restart.go +++ b/pkg/cloudbroker/vins/vnfdev_restart.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type VNFDevRestartRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperVNFDevRestartRequest struct { + VNFDevRestartRequest + AsyncMode bool `url:"asyncMode"` +} + // VNFDevRestart reboots VINSes primary VNF device func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool url := "/cloudbroker/vins/vnfdevRestart" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperVNFDevRestartRequest{ + VNFDevRestartRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool return result, nil } + +// VNFDevRestart reboots VINSes primary VNF device in async mode +func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/vnfdevRestart" + + asyncReq := asyncWrapperVNFDevRestartRequest{ + VNFDevRestartRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +} diff --git a/pkg/cloudbroker/vins/vnfdev_start.go b/pkg/cloudbroker/vins/vnfdev_start.go index 0b2bfdbf..efcf1b7d 100644 --- a/pkg/cloudbroker/vins/vnfdev_start.go +++ b/pkg/cloudbroker/vins/vnfdev_start.go @@ -2,6 +2,7 @@ package vins import ( "context" + "encoding/json" "net/http" "strconv" @@ -15,6 +16,11 @@ type VNFDevStartRequest struct { VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"` } +type asyncWrapperVNFDevStartRequest struct { + VNFDevStartRequest + AsyncMode bool `url:"asyncMode"` +} + // VNFDevStart starts VINSes primary VNF device func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, error) { err := validators.ValidateRequest(req) @@ -24,7 +30,12 @@ func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er url := "/cloudbroker/vins/vnfdevStart" - res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req) + syncReq := asyncWrapperVNFDevStartRequest{ + VNFDevStartRequest: req, + AsyncMode: false, + } + + res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq) if err != nil { return false, err } @@ -36,3 +47,32 @@ func (v VINS) VNFDevStart(ctx context.Context, req VNFDevStartRequest) (bool, er return result, nil } + +// VNFDevStart starts VINSes primary VNF device +func (v VINS) AsyncVNFDevStart(ctx context.Context, req VNFDevStartRequest) (string, error) { + err := validators.ValidateRequest(req) + if err != nil { + return "", validators.ValidationErrors(validators.GetErrors(err)) + } + + url := "/cloudbroker/vins/vnfdevStart" + + asyncReq := asyncWrapperVNFDevStartRequest{ + VNFDevStartRequest: req, + AsyncMode: true, + } + + result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq) + if err != nil { + return "", err + } + + var resp string + + err = json.Unmarshal(result, &resp) + if err != nil { + return "", err + } + + return resp, nil +}