Compare commits
2 Commits
4.5.3-with
...
4.4.4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a5825ade0 | |||
| ce4b847596 |
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,31 +1,20 @@
|
|||||||
## Version 4.5.3
|
## Version 4.4.4
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Change field Value in schema resource kvmvm in blocks affinity_rules and anti_affinity_rules from required to optional in cloudapi and cloudbroker
|
- Changed field Value in schema resource kvmvm in blocks affinity_rules and anti_affinity_rules from required to optional in cloudapi
|
||||||
- Change the format ID in resource k8s_wg from wg_id to k8s_id#wg_id
|
- Changed the format ID in resource k8s_wg from wg_id to k8s_id#wg_id
|
||||||
- Fix scripts intall.bat and intall.sh
|
- Fixed scripts intall.bat and intall.sh
|
||||||
- Increased timeouts for resources account, disk, cdrom_image, image, virtual_image, k8s_wg, vins, rg in cloudbroker so that they match the same from cloudapi
|
- Change logic from disk delete and disk add to disk rename when disk.disk_name field is changed in resource cloudapi/kvmvm
|
||||||
- Increased timeouts for resources pcidevice, sep, sep_config in cloudbroker
|
|
||||||
- Fix bug in affinity_rules in cloudbroker/kvmvm
|
|
||||||
- Add field NeedReboot in cloudapi/kvmvm in data_source, data_source_list and resource schemas
|
|
||||||
- Fix bug with field ExtNetID in CreateInRGRequest in cloudapi/vins and cloudbroker/vins
|
|
||||||
- Add boolean field Safe in Restart func in resource cloudapi/lb
|
|
||||||
- Add field force_resize in Resize func in resource cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Fix bug in cloudBroker/kvmvm with disk and extra_disks
|
|
||||||
- Change logic from disk delete and disk add to disk rename when disk.disk_name field is changed in resource cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Fix allowed network plugin value from "weawenet" to "weavenet" for k8ci, k8s resources in cloudbroker and for k8s resource in cloudapi
|
- Fix allowed network plugin value from "weawenet" to "weavenet" for k8ci, k8s resources in cloudbroker and for k8s resource in cloudapi
|
||||||
- Fix bug with deleting decort_bservice resource when setting enable=false in cloudapi/bservice
|
- Fix bug with deleting decort_bservice resource when setting enable=false in cloudapi/bservice
|
||||||
- Fix panic in data source decort_bservice_snapshot_list in cloudapi/bservice
|
- Fix panic in data source decort_bservice_snapshot_list in cloudapi/bservice
|
||||||
- Fix panic in data source decort_rg_affinity_groups_list in cloudapi/rg
|
- Fix panic in data source decort_rg_affinity_groups_list in cloudapi/rg
|
||||||
- Fix change description in resource decort_cb_kvmvm in cloudbroker
|
- Fix duplicate enabling of bservice after create in cloudapi/bservice
|
||||||
- Computed field bootdisk_size has been renamed to boot_disk_size in data sources decort_kvmvm, decort_kvmvm_list, decort_cb_kvmvm_list in cloudapi and cloudbroker
|
- Fix start of bservice after create in cloudapi/b
|
||||||
- Change request logic for delete resource decort_cb_k8s_cp in cloudbroker
|
- Fix permanently field for disks delete, change default value from true to false in decort_kvmvm in cloudapi/kvmvm
|
||||||
- Fix schema in datasource decort_cb_kvmvm in cloudbroker, fields boot_disk_id, sep_id, pool, extra_disks, network, net_id, net_type, ip_address, mac have been removes
|
|
||||||
- Fix panic with RG in cloudapi
|
|
||||||
- Fix permanently field for disks delete in decort_kvmvm in cloudapi/kvmvm and decort_cb_kvmvm in cloudbroker/kvmvm
|
|
||||||
- Fix bug with enable request duplication
|
|
||||||
|
|
||||||
### Feature
|
### Feature
|
||||||
|
|
||||||
- Add RAM divisibility validation in compute, k8s, k8s_cp and k8s_wg resources in cloudapi and cloudbroker
|
|
||||||
- Add "permanently" flag in k8s, k8s_cp in cloudapi
|
- Add "permanently" flag in k8s, k8s_cp in cloudapi
|
||||||
|
- Add RAM validation in cloudapi/[k8s, k8s_cp, k8s_wg, kvmvm, bservice]
|
||||||
|
- Add RAM validation in cloudbroker/[k8s, k8s_wg, kvmvm]
|
||||||
|
- Add field restore in cloudapi/disk resource
|
||||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
|||||||
BINARY=${NAME}
|
BINARY=${NAME}
|
||||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=4.5.3
|
VERSION=4.4.4
|
||||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||||
|
|
||||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -6,7 +6,6 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
| Версия DECORT API | Версия провайдера Terraform |
|
| Версия DECORT API | Версия провайдера Terraform |
|
||||||
| ------ | ------ |
|
| ------ | ------ |
|
||||||
| 3.8.9 | 4.5.x |
|
|
||||||
| 3.8.8 | 4.4.x |
|
| 3.8.8 | 4.4.x |
|
||||||
| 3.8.7 | 4.3.x |
|
| 3.8.7 | 4.3.x |
|
||||||
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
||||||
@@ -27,42 +26,23 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
## Возможности провайдера
|
## Возможности провайдера
|
||||||
|
|
||||||
- Режим пользователя:
|
- Работа с Compute instances,
|
||||||
- Работа с accounts,
|
- Работа с disks,
|
||||||
- Работа с bservice,
|
- Работа с k8s,
|
||||||
- Работа с disks,
|
- Работа с image,
|
||||||
- Работа с extnets,
|
- Работа с flipgroups,
|
||||||
- Работа с flipgroups,
|
- Работа с stacks,
|
||||||
- Работа с image,
|
- Работа с reource groups,
|
||||||
- Работа с k8s,
|
- Работа с VINS,
|
||||||
- Работа с Compute instances,
|
- Работа с pfw,
|
||||||
- Работа с load balancer,
|
- Работа с accounts,
|
||||||
- Работа с locations,
|
- Работа с snapshots,
|
||||||
- Работа с pfw,
|
- Работа с bservice,
|
||||||
- Работа с resource groups,
|
- Работа с extnets,
|
||||||
- Работа с snapshots,
|
- Работа с locations,
|
||||||
- Работа с stacks,
|
- Работа с load balancer.
|
||||||
- Работа с VINS.
|
|
||||||
|
|
||||||
- Режим администратора:
|
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
- Работа с accounts,
|
|
||||||
- Работа с audits,
|
|
||||||
- Работа с disks,
|
|
||||||
- Работа с extnets,
|
|
||||||
- Работа с flipgroups,
|
|
||||||
- Работа с grids,
|
|
||||||
- Работа с images,
|
|
||||||
- Работа с k8ci,
|
|
||||||
- Работа с k8s,
|
|
||||||
- Работа с Compute instances,
|
|
||||||
- Работа с load balancer,
|
|
||||||
- Работа с pci device,
|
|
||||||
- Работа с resource groups,
|
|
||||||
- Работа с seps,
|
|
||||||
- Работа с stacks,
|
|
||||||
- Работа с VINS.
|
|
||||||
|
|
||||||
Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
|
|
||||||
## Установка
|
## Установка
|
||||||
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
||||||
@@ -109,7 +89,7 @@ terraform {
|
|||||||
9. Добавьте в файл блок с инициализацией провайдера.
|
9. Добавьте в файл блок с инициализацией провайдера.
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
controller_url = "https://mr4.digitalenergy.online"
|
controller_url = "https://mr4.digitalenergy.online"
|
||||||
oauth2_url = "https://sso.digitalenergy.online"
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
@@ -195,7 +175,7 @@ ${host_name}/${namespace}/${type}
|
|||||||
8. Добавьте в файл блок с инициализацией провайдера.
|
8. Добавьте в файл блок с инициализацией провайдера.
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
controller_url = "https://mr4.digitalenergy.online"
|
controller_url = "https://mr4.digitalenergy.online"
|
||||||
oauth2_url = "https://sso.digitalenergy.online"
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Two ways for starting:
|
|||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
#controller_url = <DECORT_CONTROLLER_URL>
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
controller_url = "https://ds1.digitalenergy.online"
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
#oauth2_url = <DECORT_SSO_URL>
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -8,7 +8,7 @@ require (
|
|||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
golang.org/x/net v0.17.0
|
golang.org/x/net v0.17.0
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.7
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -285,5 +285,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.7 h1:VIF+NXXfYec8DtlTcPae+CjB0fhH8ovBQxKMwEnLgE8=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14 h1:FSu4kPKHsrmZpYIUKlX0s4v53CGmmT2Ne2uWuiRh6pM=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.7/go.mod h1:7fj8sgGZFiiExewQeqckCS4WxwOmU0oP6BO6mi1Lpkw=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||||
|
|||||||
@@ -28,6 +28,5 @@ var Timeout60s = time.Second * 60
|
|||||||
var Timeout180s = time.Second * 180
|
var Timeout180s = time.Second * 180
|
||||||
var Timeout300s = time.Second * 300
|
var Timeout300s = time.Second * 300
|
||||||
var Timeout600s = time.Second * 600
|
var Timeout600s = time.Second * 600
|
||||||
var Timeout900s = time.Second * 900
|
|
||||||
var Timeout20m = time.Minute * 20
|
var Timeout20m = time.Minute * 20
|
||||||
var Timeout30m = time.Minute * 30
|
var Timeout30m = time.Minute * 30
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
@@ -23,13 +23,14 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io/ioutil"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
// "time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
@@ -42,32 +43,24 @@ import (
|
|||||||
|
|
||||||
// enumerated constants that define authentication modes
|
// enumerated constants that define authentication modes
|
||||||
const (
|
const (
|
||||||
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
||||||
MODE_LEGACY
|
MODE_LEGACY = iota
|
||||||
MODE_DECS3O
|
MODE_OAUTH2 = iota
|
||||||
MODE_JWT
|
MODE_JWT = iota
|
||||||
MODE_BVS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControllerCfg struct {
|
type ControllerCfg struct {
|
||||||
controller_url string // always required
|
controller_url string // always required
|
||||||
auth_mode_code int // always required
|
auth_mode_code int // always required
|
||||||
auth_mode_txt string // always required, it is a text representation of auth mode
|
auth_mode_txt string // always required, it is a text representation of auth mode
|
||||||
bvs_user string // required for bvs mode
|
|
||||||
bvs_password string // required for bvs mode
|
|
||||||
domain string // required for bvs mode
|
|
||||||
token config.Token // obtained from BVS provider on successful login in bvs mode
|
|
||||||
path_cfg string // the path of the configuration file entry
|
|
||||||
path_token string // the path of the token file entry
|
|
||||||
time_to_refresh int64 // the number of minutes before the expiration of the token, a refresh will be made
|
|
||||||
legacy_user string // required for legacy mode
|
legacy_user string // required for legacy mode
|
||||||
legacy_password string // required for legacy mode
|
legacy_password string // required for legacy mode
|
||||||
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
||||||
jwt string // obtained from Outh2 provider on successful login in decs3o mode, required in jwt mode
|
jwt string // obtained from Outh2 provider on successful login in oauth2 mode, required in jwt mode
|
||||||
app_id string // required for decs3o and bvs mode
|
app_id string // required for oauth2 mode
|
||||||
app_secret string // required for decs3o and bvs mode
|
app_secret string // required for oauth2 mode
|
||||||
oauth2_url string // required for decs3o and bvs mode
|
oauth2_url string // always required
|
||||||
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (decs3o mode) upon successful verification
|
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (oauth2 mode) upon successful verification
|
||||||
cc_client *http.Client // assigned when all initial checks successfully passed
|
cc_client *http.Client // assigned when all initial checks successfully passed
|
||||||
caller interfaces.Caller
|
caller interfaces.Caller
|
||||||
}
|
}
|
||||||
@@ -90,24 +83,17 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
legacy_user: d.Get("user").(string),
|
legacy_user: d.Get("user").(string),
|
||||||
legacy_password: d.Get("password").(string),
|
legacy_password: d.Get("password").(string),
|
||||||
legacy_sid: "",
|
legacy_sid: "",
|
||||||
bvs_user: d.Get("bvs_user").(string),
|
|
||||||
bvs_password: d.Get("bvs_password").(string),
|
|
||||||
domain: d.Get("domain").(string),
|
|
||||||
jwt: d.Get("jwt").(string),
|
jwt: d.Get("jwt").(string),
|
||||||
app_id: d.Get("app_id").(string),
|
app_id: d.Get("app_id").(string),
|
||||||
app_secret: d.Get("app_secret").(string),
|
app_secret: d.Get("app_secret").(string),
|
||||||
oauth2_url: d.Get("oauth2_url").(string),
|
oauth2_url: d.Get("oauth2_url").(string),
|
||||||
decort_username: "",
|
decort_username: "",
|
||||||
token: config.Token{},
|
|
||||||
path_cfg: d.Get("path_cfg").(string),
|
|
||||||
path_token: d.Get("path_token").(string),
|
|
||||||
time_to_refresh: int64(d.Get("time_to_refresh").(int)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
||||||
|
|
||||||
if ret_config.controller_url == "" {
|
if ret_config.controller_url == "" {
|
||||||
return nil, fmt.Errorf("empty DECORT cloud controller URL provided")
|
return nil, fmt.Errorf("Empty DECORT cloud controller URL provided.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
||||||
@@ -116,53 +102,33 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
switch ret_config.auth_mode_txt {
|
switch ret_config.auth_mode_txt {
|
||||||
case "jwt":
|
case "jwt":
|
||||||
if ret_config.jwt == "" {
|
if ret_config.jwt == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'jwt' specified but no JWT provided")
|
return nil, fmt.Errorf("Authenticator mode 'jwt' specified but no JWT provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_JWT
|
ret_config.auth_mode_code = MODE_JWT
|
||||||
case "decs3o":
|
case "oauth2":
|
||||||
if ret_config.oauth2_url == "" {
|
if ret_config.oauth2_url == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no OAuth2 URL provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no OAuth2 URL provided.")
|
||||||
}
|
}
|
||||||
if ret_config.app_id == "" {
|
if ret_config.app_id == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Application ID provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Application ID provided.")
|
||||||
}
|
}
|
||||||
if ret_config.app_secret == "" {
|
if ret_config.app_secret == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Secret ID provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Secret ID provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_DECS3O
|
ret_config.auth_mode_code = MODE_OAUTH2
|
||||||
case "legacy":
|
case "legacy":
|
||||||
//
|
//
|
||||||
ret_config.legacy_user = d.Get("user").(string)
|
ret_config.legacy_user = d.Get("user").(string)
|
||||||
if ret_config.legacy_user == "" {
|
if ret_config.legacy_user == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no user provided")
|
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no user provided.")
|
||||||
}
|
}
|
||||||
ret_config.legacy_password = d.Get("password").(string)
|
ret_config.legacy_password = d.Get("password").(string)
|
||||||
if ret_config.legacy_password == "" {
|
if ret_config.legacy_password == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no password provided")
|
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no password provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_LEGACY
|
ret_config.auth_mode_code = MODE_LEGACY
|
||||||
case "bvs":
|
|
||||||
if ret_config.bvs_user == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no user provided")
|
|
||||||
}
|
|
||||||
if ret_config.bvs_password == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no password provided")
|
|
||||||
}
|
|
||||||
if ret_config.oauth2_url == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no bvs URL provided")
|
|
||||||
}
|
|
||||||
if ret_config.app_id == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Application ID provided")
|
|
||||||
}
|
|
||||||
if ret_config.app_secret == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Secret ID provided")
|
|
||||||
}
|
|
||||||
if ret_config.domain == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Domain provided")
|
|
||||||
}
|
|
||||||
ret_config.auth_mode_code = MODE_BVS
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown authenticator mode %q provided", ret_config.auth_mode_txt)
|
return nil, fmt.Errorf("Unknown authenticator mode %q provided.", ret_config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if allow_unverified_ssl {
|
if allow_unverified_ssl {
|
||||||
@@ -198,16 +164,16 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case MODE_DECS3O:
|
case MODE_OAUTH2:
|
||||||
// on success getDECS3OJWT will set config.jwt to the obtained JWT, so there is no
|
// on success getOAuth2JWT will set config.jwt to the obtained JWT, so there is no
|
||||||
// need to set it once again here
|
// need to set it once again here
|
||||||
// _, err := ret_config.getDECS3OJWT()
|
// _, err := ret_config.getOAuth2JWT()
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// we are not verifying the JWT when parsing because actual verification is done on the
|
// // we are not verifying the JWT when parsing because actual verification is done on the
|
||||||
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
// // OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
||||||
// and JWT issuer name (claim "iss")
|
// // and JWT issuer name (claim "iss")
|
||||||
// parser := jwt.Parser{}
|
// parser := jwt.Parser{}
|
||||||
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@@ -220,7 +186,7 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// tbuf.WriteString(claims["iss"].(string))
|
// tbuf.WriteString(claims["iss"].(string))
|
||||||
// ret_config.decort_username = tbuf.String()
|
// ret_config.decort_username = tbuf.String()
|
||||||
// } else {
|
// } else {
|
||||||
// return nil, fmt.Errorf("failed to extract user and iss fields from JWT token in oauth2 mode")
|
// return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
sdkConf := config.Config{
|
sdkConf := config.Config{
|
||||||
@@ -232,27 +198,10 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_config.caller = decort.New(sdkConf)
|
ret_config.caller = decort.New(sdkConf)
|
||||||
case MODE_BVS:
|
|
||||||
|
|
||||||
sdkConf := config.BVSConfig{
|
|
||||||
AppID: ret_config.app_id,
|
|
||||||
AppSecret: ret_config.app_secret,
|
|
||||||
SSOURL: ret_config.oauth2_url,
|
|
||||||
DecortURL: ret_config.controller_url,
|
|
||||||
SSLSkipVerify: allow_unverified_ssl,
|
|
||||||
Username: ret_config.bvs_user,
|
|
||||||
Password: ret_config.bvs_password,
|
|
||||||
Domain: ret_config.domain,
|
|
||||||
Token: ret_config.token,
|
|
||||||
PathCfg: ret_config.path_cfg,
|
|
||||||
PathToken: ret_config.path_token,
|
|
||||||
TimeToRefresh: ret_config.time_to_refresh,
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_config.caller = decort.NewBVS(sdkConf)
|
|
||||||
default:
|
default:
|
||||||
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
||||||
return nil, fmt.Errorf("unknown authenticator mode code %d provided", ret_config.auth_mode_code)
|
return nil, fmt.Errorf("Unknown authenticator mode code %d provided.", ret_config.auth_mode_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
||||||
@@ -264,13 +213,13 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// return config.decort_username
|
// return config.decort_username
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func (config *ControllerCfg) getDECS3OJWT() (string, error) {
|
// func (config *ControllerCfg) getOAuth2JWT() (string, error) {
|
||||||
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
||||||
// if config.auth_mode_code == MODE_UNDEF {
|
// if config.auth_mode_code == MODE_UNDEF {
|
||||||
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode")
|
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.")
|
||||||
// }
|
// }
|
||||||
// if config.auth_mode_code != MODE_DECS3O {
|
// if config.auth_mode_code != MODE_OAUTH2 {
|
||||||
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q", config.auth_mode_txt)
|
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// params := url.Values{}
|
// params := url.Values{}
|
||||||
@@ -301,7 +250,7 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// }
|
// }
|
||||||
// defer resp.Body.Close()
|
// defer resp.Body.Close()
|
||||||
|
|
||||||
// responseData, err := io.ReadAll(resp.Body)
|
// responseData, err := ioutil.ReadAll(resp.Body)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return "", err
|
// return "", err
|
||||||
// }
|
// }
|
||||||
@@ -321,13 +270,13 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
*/
|
*/
|
||||||
if jwt == "" {
|
if jwt == "" {
|
||||||
if config.jwt == "" {
|
if config.jwt == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided")
|
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided.")
|
||||||
}
|
}
|
||||||
jwt = config.jwt
|
jwt = config.jwt
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.oauth2_url == "" {
|
if config.oauth2_url == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided")
|
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided.")
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
||||||
@@ -344,7 +293,7 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q",
|
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q.",
|
||||||
resp.StatusCode, req.URL)
|
resp.StatusCode, req.URL)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@@ -360,10 +309,10 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
reason, the method will return false and error.
|
reason, the method will return false and error.
|
||||||
*/
|
*/
|
||||||
if config.auth_mode_code == MODE_UNDEF {
|
if config.auth_mode_code == MODE_UNDEF {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode")
|
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode.")
|
||||||
}
|
}
|
||||||
if config.auth_mode_code != MODE_LEGACY {
|
if config.auth_mode_code != MODE_LEGACY {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q", config.auth_mode_txt)
|
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
@@ -384,12 +333,12 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q",
|
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q.",
|
||||||
resp.StatusCode, config.legacy_user, config.controller_url)
|
resp.StatusCode, config.legacy_user, config.controller_url)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
responseData, err := io.ReadAll(req.Body)
|
responseData, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -401,32 +350,21 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
||||||
switch config.auth_mode_code {
|
if config.auth_mode_code == MODE_LEGACY {
|
||||||
case MODE_LEGACY:
|
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudAPI()
|
return client.CloudAPI()
|
||||||
case MODE_DECS3O:
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudAPI()
|
|
||||||
case MODE_BVS:
|
|
||||||
client, _ := config.caller.(*decort.BVSDecortClient)
|
|
||||||
return client.CloudAPI()
|
|
||||||
default:
|
|
||||||
return &cloudapi.CloudAPI{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudAPI()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
||||||
switch config.auth_mode_code {
|
if config.auth_mode_code == MODE_LEGACY {
|
||||||
case MODE_LEGACY:
|
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudBroker()
|
return client.CloudBroker()
|
||||||
case MODE_DECS3O:
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudBroker()
|
|
||||||
case MODE_BVS:
|
|
||||||
client, _ := config.caller.(*decort.BVSDecortClient)
|
|
||||||
return client.CloudBroker()
|
|
||||||
default:
|
|
||||||
return &cloudbroker.CloudBroker{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudBroker()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,31 +38,25 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit"
|
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
|
||||||
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
|
||||||
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
|
cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
||||||
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
|
||||||
|
|
||||||
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
|
||||||
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDataSourcesMap() map[string]*schema.Resource {
|
func newDataSourcesMap() map[string]*schema.Resource {
|
||||||
return map[string]*schema.Resource{
|
return map[string]*schema.Resource{
|
||||||
"decort_account": account.DataSourceAccount(),
|
"decort_account": account.DataSourceAccount(),
|
||||||
|
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||||
|
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||||
"decort_resgroup": rg.DataSourceResgroup(),
|
"decort_resgroup": rg.DataSourceResgroup(),
|
||||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||||
|
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
@@ -70,12 +64,15 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
|
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||||
|
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
"decort_k8s": k8s.DataSourceK8s(),
|
"decort_k8s": k8s.DataSourceK8s(),
|
||||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||||
|
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
@@ -99,6 +96,8 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||||
|
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||||
|
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||||
@@ -138,117 +137,36 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||||
"decort_stack": stack.DataSourceStack(),
|
"decort_stack": stack.DataSourceStack(),
|
||||||
"decort_stack_list": stack.DataSourceStackList(),
|
"decort_stack_list": stack.DataSourceStackList(),
|
||||||
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
|
||||||
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
|
||||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
|
||||||
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
|
||||||
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
|
||||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
|
||||||
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
|
||||||
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
|
||||||
|
|
||||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||||
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
||||||
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
|
"decort_cb_account_deleted_list": cb_account.DataSourceAccountDeletedList(),
|
||||||
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
||||||
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||||
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
|
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
||||||
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
|
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
||||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
||||||
"decort_cb_audit": cb_audit.DataSourceAudit(),
|
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
||||||
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
|
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
||||||
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
|
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||||
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
"decort_cb_image": cb_image.DataSourceImage(),
|
||||||
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
||||||
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
||||||
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
|
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
||||||
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
|
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
||||||
"decort_cb_image": cb_image.DataSourceImage(),
|
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
||||||
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
||||||
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
|
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
||||||
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
|
"decort_cb_sep": cb_sep.DataSourceSep(),
|
||||||
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
|
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
||||||
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
|
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
||||||
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
||||||
"decort_cb_grid_list_emails": cb_grid.DataSourceGridListEmails(),
|
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
||||||
"decort_cb_grid_list_consumption": cb_grid.DataSourceGridListConsumption(),
|
"decort_cb_vgpu": cb_vgpu.DataSourceVGPU(),
|
||||||
"decort_cb_grid_get_consumption": cb_grid.DataSourceGridGetConsumption(),
|
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
||||||
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
|
||||||
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
|
||||||
"decort_cb_kvmvm": cb_kvmvm.DataSourceCompute(),
|
|
||||||
"decort_cb_kvmvm_affinity_relations": cb_kvmvm.DataSourceComputeAffinityRelations(),
|
|
||||||
"decort_cb_kvmvm_audits": cb_kvmvm.DataSourceComputeAudits(),
|
|
||||||
"decort_cb_kvmvm_boot_order_get": cb_kvmvm.DataSourceComputeBootOrderGet(),
|
|
||||||
"decort_cb_kvmvm_get_audits": cb_kvmvm.DataSourceComputeGetAudits(),
|
|
||||||
"decort_cb_kvmvm_get_console_url": cb_kvmvm.DataSourceComputeGetConsoleUrl(),
|
|
||||||
"decort_cb_kvmvm_get_log": cb_kvmvm.DataSourceComputeGetLog(),
|
|
||||||
"decort_cb_kvmvm_list": cb_kvmvm.DataSourceComputeList(),
|
|
||||||
"decort_cb_kvmvm_list_deleted": cb_kvmvm.DataSourceComputeListDeleted(),
|
|
||||||
"decort_cb_kvmvm_migrate_storage_info": cb_kvmvm.DataSourceComputeMigrateStorageInfo(),
|
|
||||||
"decort_cb_kvmvm_pci_device_list": cb_kvmvm.DataSourceComputePCIDeviceList(),
|
|
||||||
"decort_cb_kvmvm_pfw_list": cb_kvmvm.DataSourceComputePfwList(),
|
|
||||||
"decort_cb_kvmvm_snapshot_list": cb_kvmvm.DataSourceComputeSnapshotList(),
|
|
||||||
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
|
|
||||||
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
|
|
||||||
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
|
|
||||||
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
|
||||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
|
||||||
"decort_cb_disk_list_deleted": cb_disks.DataSourceDiskListDeleted(),
|
|
||||||
"decort_cb_disk_list_types": cb_disks.DataSourceDiskListTypes(),
|
|
||||||
"decort_cb_disk_list_types_detailed": cb_disks.DataSourceDiskListTypesDetailed(),
|
|
||||||
"decort_cb_disk_list_unattached": cb_disks.DataSourceDiskListUnattached(),
|
|
||||||
"decort_cb_disk_snapshot": cb_disks.DataSourceDiskSnapshot(),
|
|
||||||
"decort_cb_disk_snapshot_list": cb_disks.DataSourceDiskSnapshotList(),
|
|
||||||
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
|
||||||
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
|
||||||
"decort_cb_rg": cb_rg.DataSourceResgroup(),
|
|
||||||
"decort_cb_rg_affinity_group_computes": cb_rg.DataSourceRgAffinityGroupComputes(),
|
|
||||||
"decort_cb_rg_affinity_groups_get": cb_rg.DataSourceRgAffinityGroupsGet(),
|
|
||||||
"decort_cb_rg_affinity_groups_list": cb_rg.DataSourceRgAffinityGroupsList(),
|
|
||||||
"decort_cb_rg_resource_consumption_get": cb_rg.DataSourceRGResourceConsumptionGet(),
|
|
||||||
"decort_cb_rg_resource_consumption_list": cb_rg.DataSourceRGResourceConsumptionList(),
|
|
||||||
"decort_cb_rg_audits": cb_rg.DataSourceRgAudits(),
|
|
||||||
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
|
||||||
"decort_cb_rg_list_deleted": cb_rg.DataSourceRgListDeleted(),
|
|
||||||
"decort_cb_rg_list_computes": cb_rg.DataSourceRgListComputes(),
|
|
||||||
"decort_cb_rg_list_lb": cb_rg.DataSourceRgListLb(),
|
|
||||||
"decort_cb_rg_list_pfw": cb_rg.DataSourceRgListPfw(),
|
|
||||||
"decort_cb_rg_list_vins": cb_rg.DataSourceRgListVins(),
|
|
||||||
"decort_cb_rg_usage": cb_rg.DataSourceRgUsage(),
|
|
||||||
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
|
||||||
"decort_cb_sep": cb_sep.DataSourceSep(),
|
|
||||||
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
|
||||||
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
|
||||||
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
|
||||||
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
|
||||||
"decort_cb_lb": cb_lb.DataSourceLB(),
|
|
||||||
"decort_cb_lb_list": cb_lb.DataSourceLBList(),
|
|
||||||
"decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(),
|
|
||||||
"decort_cb_flipgroup_list": cb_flipgroup.DataSourceFlipgroupList(),
|
|
||||||
"decort_cb_flipgroup": cb_flipgroup.DataSourceFlipgroup(),
|
|
||||||
"decort_cb_stack_list": cb_stack.DataSourceStacksList(),
|
|
||||||
"decort_cb_stack": cb_stack.DataSourceStack(),
|
|
||||||
"decort_cb_vins": cb_vins.DataSourceVins(),
|
|
||||||
"decort_cb_vins_list": cb_vins.DataSourceVinsList(),
|
|
||||||
"decort_cb_vins_audits": cb_vins.DataSourceVinsAudits(),
|
|
||||||
"decort_cb_vins_ip_list": cb_vins.DataSourceVinsIpList(),
|
|
||||||
"decort_cb_vins_list_deleted": cb_vins.DataSourceVinsListDeleted(),
|
|
||||||
"decort_cb_vins_ext_net_list": cb_vins.DataSourceVinsExtNetList(),
|
|
||||||
"decort_cb_vins_nat_rule_list": cb_vins.DataSourceVinsNatRuleList(),
|
|
||||||
"decort_cb_vins_static_route": cb_vins.DataSourceStaticRoute(),
|
|
||||||
"decort_cb_vins_static_route_list": cb_vins.DataSourceStaticRouteList(),
|
|
||||||
"decort_cb_k8ci": cb_k8ci.DataSourceK8CI(),
|
|
||||||
"decort_cb_k8ci_list": cb_k8ci.DataSourceK8CIList(),
|
|
||||||
"decort_cb_k8ci_list_deleted": cb_k8ci.DataSourceK8CIListDeleted(),
|
|
||||||
"decort_cb_k8s": cb_k8s.DataSourceK8s(),
|
|
||||||
"decort_cb_k8s_list": cb_k8s.DataSourceK8sList(),
|
|
||||||
"decort_cb_k8s_list_deleted": cb_k8s.DataSourceK8sListDeleted(),
|
|
||||||
"decort_cb_k8s_wg": cb_k8s.DataSourceK8sWg(),
|
|
||||||
"decort_cb_k8s_wg_cloud_init": cb_k8s.DataSourceK8sWgCloudInit(),
|
|
||||||
"decort_cb_k8s_wg_list": cb_k8s.DataSourceK8sWgList(),
|
|
||||||
"decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func Provider() *schema.Provider {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating
|
||||||
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"oauth2_url": {
|
"oauth2_url": {
|
||||||
@@ -49,7 +49,7 @@ func Provider() *schema.Provider {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
||||||
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"controller_url": {
|
"controller_url": {
|
||||||
@@ -74,39 +74,18 @@ func Provider() *schema.Provider {
|
|||||||
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_user": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
|
||||||
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"bvs_password": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"domain": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"app_id": {
|
"app_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
||||||
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_secret": {
|
"app_secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
||||||
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"jwt": {
|
"jwt": {
|
||||||
@@ -122,25 +101,6 @@ func Provider() *schema.Provider {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
||||||
},
|
},
|
||||||
|
|
||||||
"path_cfg": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The path of the configuration file entry",
|
|
||||||
},
|
|
||||||
|
|
||||||
"path_token": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The path of the token file entry",
|
|
||||||
},
|
|
||||||
|
|
||||||
"time_to_refresh": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: newResourcesMap(),
|
ResourcesMap: newResourcesMap(),
|
||||||
|
|||||||
@@ -38,15 +38,14 @@ import (
|
|||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
|
cb_pfw "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pfw"
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
cb_snapshot "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/snapshot"
|
||||||
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -75,29 +74,22 @@ func newResourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||||
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
||||||
|
|
||||||
"decort_cb_account": cb_account.ResourceAccount(),
|
"decort_cb_account": cb_account.ResourceAccount(),
|
||||||
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
||||||
"decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
|
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
"decort_cb_image": cb_image.ResourceImage(),
|
||||||
"decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
|
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||||
"decort_cb_image": cb_image.ResourceImage(),
|
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||||
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
"decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
||||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
||||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||||
"decort_cb_vins": cb_vins.ResourceVins(),
|
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||||
"decort_cb_k8ci": cb_k8ci.ResourceK8CI(),
|
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
||||||
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
|
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
||||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||||
"decort_cb_vins_static_route": cb_vins.ResourceStaticRoute(),
|
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
||||||
"decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
|
|
||||||
"decort_cb_lb": cb_lb.ResourceLB(),
|
|
||||||
"decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
|
|
||||||
"decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
|
|
||||||
"decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
|
|
||||||
"decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
|
|
||||||
"decort_cb_rg": cb_rg.ResourceResgroup(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +99,6 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ func flattenAccountAuditsList(aal account.ListAudits) []map[string]interface{} {
|
|||||||
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ func flattenAccountComputesList(acl *account.ListComputes) []map[string]interfac
|
|||||||
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceD
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("cu_c", accountConsumedUnits.CUC)
|
d.Set("cu_c", accountConsumedUnits.CUC)
|
||||||
d.Set("cu_d", accountConsumedUnits.CUD)
|
d.Set("cu_d", accountConsumedUnits.CUD)
|
||||||
d.Set("cu_dm", accountConsumedUnits.CUDM)
|
|
||||||
d.Set("cu_i", accountConsumedUnits.CUI)
|
d.Set("cu_i", accountConsumedUnits.CUI)
|
||||||
d.Set("cu_m", accountConsumedUnits.CUM)
|
d.Set("cu_m", accountConsumedUnits.CUM)
|
||||||
d.Set("cu_np", accountConsumedUnits.CUNP)
|
d.Set("cu_np", accountConsumedUnits.CUNP)
|
||||||
@@ -76,10 +74,6 @@ func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ func flattenAccountDisksList(adl *account.ListDisks) []map[string]interface{} {
|
|||||||
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ func flattenAccountFlipGroupsList(afgl *account.ListFLIPGroups) []map[string]int
|
|||||||
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
|
|||||||
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceD
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("cu_c", accountReservedUnits.CUC)
|
d.Set("cu_c", accountReservedUnits.CUC)
|
||||||
d.Set("cu_d", accountReservedUnits.CUD)
|
d.Set("cu_d", accountReservedUnits.CUD)
|
||||||
d.Set("cu_dm", accountReservedUnits.CUDM)
|
|
||||||
d.Set("cu_i", accountReservedUnits.CUI)
|
d.Set("cu_i", accountReservedUnits.CUI)
|
||||||
d.Set("cu_m", accountReservedUnits.CUM)
|
d.Set("cu_m", accountReservedUnits.CUM)
|
||||||
d.Set("cu_np", accountReservedUnits.CUNP)
|
d.Set("cu_np", accountReservedUnits.CUNP)
|
||||||
@@ -76,10 +74,6 @@ func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ func flattenAccRGResources(argr account.RGResources) []map[string]interface{} {
|
|||||||
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interf
|
|||||||
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
|
|||||||
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,18 +148,17 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
if d.Get("restore").(bool) {
|
|
||||||
req := account.RestoreRequest{
|
|
||||||
AccountID: accountId,
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
req := account.RestoreRequest{
|
||||||
if err != nil {
|
AccountID: accountId,
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hasChanged = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChanged = true
|
||||||
case status.Disabled:
|
case status.Disabled:
|
||||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||||
case status.Confirmed:
|
case status.Confirmed:
|
||||||
@@ -185,14 +184,14 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
|
|
||||||
}
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Account().Disable(ctx, reqSwitch)
|
_, err := c.CloudAPI().Account().Disable(ctx, reqSwitch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,13 +280,15 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
if d.HasChange("restore") {
|
if d.HasChange("restore") {
|
||||||
restore := d.Get("restore").(bool)
|
restore := d.Get("restore").(bool)
|
||||||
if restore && acc.Status == "DELETED" {
|
if restore {
|
||||||
req := account.RestoreRequest{
|
if acc.Status == "DELETED" {
|
||||||
AccountID: accountId,
|
req := account.RestoreRequest{
|
||||||
}
|
AccountID: accountId,
|
||||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
}
|
||||||
if err != nil {
|
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ func flattenBasicServiceList(bsl *bservice.ListBasicServices) []map[string]inter
|
|||||||
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,13 @@ import (
|
|||||||
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenBasicServiceSnapshotsList(basicServiceSnapshotList))
|
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList.Data))
|
||||||
d.Set("entry_count", basicServiceSnapshotList.EntryCount)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +85,6 @@ func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func flattenBasicServiceComputes(bscs bservice.ListComputes) []map[string]interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(bsrvss))
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, bsrvs := range bsrvss {
|
for _, bsrvs := range bsrvss {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"guid": bsrvs.GUID,
|
"guid": bsrvs.GUID,
|
||||||
@@ -123,17 +123,3 @@ func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]in
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenBasicServiceSnapshotsList(bsrvss *bservice.ListInfoSnapshots) []map[string]interface{} {
|
|
||||||
res := make([]map[string]interface{}, 0, len(bsrvss.Data))
|
|
||||||
for _, bsrvs := range bsrvss.Data {
|
|
||||||
temp := map[string]interface{}{
|
|
||||||
"guid": bsrvs.GUID,
|
|
||||||
"label": bsrvs.Label,
|
|
||||||
"timestamp": bsrvs.Timestamp,
|
|
||||||
"valid": bsrvs.Valid,
|
|
||||||
}
|
|
||||||
res = append(res, temp)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ package bservice
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
@@ -85,12 +86,7 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
warn := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
if !d.Get("enable").(bool) && d.Get("start").(bool) {
|
|
||||||
|
|
||||||
warn.Add(fmt.Errorf("the basic service is in tech_status %s, troubles can occur with the usage. Please, enable bservice first", service.TechStatus))
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
|
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
|
||||||
log.Debugf("trying to enable bservice %v", serviceId)
|
log.Debugf("trying to enable bservice %v", serviceId)
|
||||||
@@ -99,23 +95,29 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if d.Get("start").(bool) && d.Get("enable").(bool) {
|
|
||||||
|
|
||||||
|
if d.Get("start").(bool) {
|
||||||
log.Debugf("trying to start bservice %v", serviceId)
|
log.Debugf("trying to start bservice %v", serviceId)
|
||||||
_, err = c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
|
|
||||||
ServiceID: serviceId,
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
if !d.Get("enable").(bool) {
|
||||||
return diag.FromErr(err)
|
warnings.Add(errors.New("can not start bservice that is not enabled. Set enable = true and start = true to enable and start bservice"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Get("enable").(bool) {
|
||||||
|
_, err := c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
|
||||||
|
ServiceID: serviceId,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return append(warn.Get(), resourceBasicServiceRead(ctx, d, m)...)
|
return append(warnings.Get(), resourceBasicServiceRead(ctx, d, m)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -241,44 +243,37 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
case status.Disabling:
|
case status.Disabling:
|
||||||
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
if d.Get("restore").(bool) {
|
||||||
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
if restore, ok := d.GetOk("restore"); ok {
|
restoreReq := bservice.RestoreRequest{
|
||||||
if restore.(bool) {
|
ServiceID: id,
|
||||||
restoreReq := bservice.RestoreRequest{
|
|
||||||
ServiceID: id,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
hasChanged = true
|
hasChanged = true
|
||||||
}
|
|
||||||
|
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
if d.Get("enable").(bool) {
|
||||||
if enable.(bool) {
|
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||||
enableReq := bservice.EnableRequest{
|
|
||||||
ServiceID: id,
|
ServiceID: id,
|
||||||
}
|
})
|
||||||
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
hasChanged = true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok {
|
if d.Get("start").(bool) {
|
||||||
if start.(bool) {
|
_, err := c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
|
||||||
startReq := bservice.StartRequest{
|
|
||||||
ServiceID: id,
|
ServiceID: id,
|
||||||
}
|
})
|
||||||
_, err = c.CloudAPI().BService().Start(ctx, startReq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
hasChanged = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
@@ -413,9 +408,10 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceBasicServiceRead(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainsSnapshot(els []interface{}, el interface{}) bool {
|
func isContainsSnapshot(els []interface{}, el interface{}) bool {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -143,7 +144,6 @@ func resourceBasicServiceGroupDelete(ctx context.Context, d *schema.ResourceData
|
|||||||
|
|
||||||
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ func resourceBasicServiceGroupUpdate(ctx context.Context, d *schema.ResourceData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceBasicServiceGroupRead(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainsParent(els []interface{}, el interface{}) bool {
|
func isContainsParent(els []interface{}, el interface{}) bool {
|
||||||
@@ -372,8 +372,12 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "compute CPU number. All computes in the group have the same CPU count",
|
Description: "compute CPU number. All computes in the group have the same CPU count",
|
||||||
},
|
},
|
||||||
"ram": {
|
"ram": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
ValidateFunc: validation.All(
|
||||||
|
validation.IntAtLeast(constants.MinRamPerCompute),
|
||||||
|
validators.DivisibleBy(constants.RAMDivisibility),
|
||||||
|
),
|
||||||
Description: "compute RAM volume in MB. All computes in the group have the same RAM volume",
|
Description: "compute RAM volume in MB. All computes in the group have the same RAM volume",
|
||||||
},
|
},
|
||||||
"disk": {
|
"disk": {
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import (
|
|||||||
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{}
|
|||||||
for _, typeListDetailed := range tld.Data {
|
for _, typeListDetailed := range tld.Data {
|
||||||
toMap := typeListDetailed.(map[string]interface{})
|
toMap := typeListDetailed.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
||||||
"sep_id": toMap["sepId"].(float64),
|
"sep_id": toMap["sepId"].(float64),
|
||||||
"sep_name": toMap["sepName"].(string),
|
"sep_name": toMap["sepName"].(string),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
@@ -61,9 +61,9 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
for _, pool := range pools {
|
for _, pool := range pools {
|
||||||
toMap := pool.(map[string]interface{})
|
toMap := pool.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"name": toMap["name"].(string),
|
"name": toMap["name"].(string),
|
||||||
"system": toMap["system"].(string),
|
"system": toMap["system"].(string),
|
||||||
"types": toMap["types"].([]interface{}),
|
"types": toMap["types"].([]interface{}),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,6 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,8 +112,8 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Pool name",
|
Description: "Pool name",
|
||||||
},
|
},
|
||||||
"system": {
|
"system": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"types": {
|
"types": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
@@ -133,8 +132,8 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
"sep_name": {
|
"sep_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,11 +375,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
Description: "shareable",
|
|
||||||
},
|
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
|
diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
|
|||||||
"res_name": unattachedDisk.ResName,
|
"res_name": unattachedDisk.ResName,
|
||||||
"role": unattachedDisk.Role,
|
"role": unattachedDisk.Role,
|
||||||
"sep_id": unattachedDisk.SEPID,
|
"sep_id": unattachedDisk.SEPID,
|
||||||
"shareable": unattachedDisk.Shareable,
|
|
||||||
"size_max": unattachedDisk.SizeMax,
|
"size_max": unattachedDisk.SizeMax,
|
||||||
"size_used": unattachedDisk.SizeUsed,
|
"size_used": unattachedDisk.SizeUsed,
|
||||||
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +219,6 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,20 +231,23 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
// return resourceDiskCreate(ctx, d, m)
|
// return resourceDiskCreate(ctx, d, m)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
hasChangeState = true
|
if restore, ok:= d.GetOk("restore"); ok && restore.(bool) {
|
||||||
req := disks.RestoreRequest{
|
hasChangeState = true
|
||||||
DiskID: disk.ID,
|
req := disks.RestoreRequest{
|
||||||
}
|
DiskID: disk.ID,
|
||||||
|
}
|
||||||
|
|
||||||
if reason, ok := d.GetOk("reason"); ok {
|
if reason, ok := d.GetOk("reason"); ok {
|
||||||
req.Reason = reason.(string)
|
req.Reason = reason.(string)
|
||||||
} else {
|
} else {
|
||||||
req.Reason = "Terraform automatic restore"
|
req.Reason = "Terraform automatic restore"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Disks().Restore(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().Disks().Restore(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
}
|
||||||
case status.Assigned:
|
case status.Assigned:
|
||||||
case status.Modeled:
|
case status.Modeled:
|
||||||
@@ -359,10 +360,18 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
req := disks.DeleteRequest{
|
req := disks.DeleteRequest{
|
||||||
DiskID: disk.ID,
|
DiskID: disk.ID,
|
||||||
Detach: d.Get("detach").(bool),
|
}
|
||||||
Permanently: d.Get("permanently").(bool),
|
|
||||||
Reason: d.Get("reason").(string),
|
if detach, ok := d.GetOk("detach"); ok {
|
||||||
|
req.Detach = detach.(bool)
|
||||||
|
}
|
||||||
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
|
req.Permanently = permanently.(bool)
|
||||||
|
}
|
||||||
|
if reason, ok := d.GetOk("reason"); ok {
|
||||||
|
req.Reason = reason.(string)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
@@ -379,9 +388,9 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"disk_name": {
|
"disk_name": {
|
||||||
@@ -395,9 +404,9 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Size in GB",
|
Description: "Size in GB",
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the grid (platform)",
|
Description: "ID of the grid (platform)",
|
||||||
},
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
@@ -448,6 +457,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"restore": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
},
|
||||||
"iotune": {
|
"iotune": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,15 +169,15 @@ func resourceDiskSnapshotDelete(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"label": {
|
"label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Name of the snapshot",
|
Description: "Name of the snapshot",
|
||||||
},
|
},
|
||||||
"rollback": {
|
"rollback": {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,10 +118,6 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(ecs))
|
res := make([]map[string]interface{}, 0, len (ecs))
|
||||||
for _, ec := range ecs {
|
for _, ec := range ecs {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"net_id": ec.ID,
|
"net_id": ec.ID,
|
||||||
@@ -129,7 +129,6 @@ func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
|||||||
"net_id": e.ID,
|
"net_id": e.ID,
|
||||||
"ipcidr": e.IPCIDR,
|
"ipcidr": e.IPCIDR,
|
||||||
"name": e.Name,
|
"name": e.Name,
|
||||||
"status": e.Status,
|
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,10 +66,6 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"client_ids": {
|
"client_ids": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -89,26 +85,10 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
"default_gw": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
"desc": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -141,28 +121,16 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
"net_mask": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_time": {
|
"ckey": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,13 +185,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,21 +36,15 @@ package flipgroup
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
||||||
d.Set("account_id", fg.AccountID)
|
d.Set("account_id", fg.AccountID)
|
||||||
d.Set("account_name", fg.AccountName)
|
|
||||||
d.Set("client_ids", fg.ClientIDs)
|
d.Set("client_ids", fg.ClientIDs)
|
||||||
d.Set("client_type", fg.ClientType)
|
d.Set("client_type", fg.ClientType)
|
||||||
d.Set("conn_id", fg.ConnID)
|
d.Set("conn_id", fg.ConnID)
|
||||||
d.Set("conn_type", fg.ConnType)
|
d.Set("conn_type", fg.ConnType)
|
||||||
d.Set("created_by", fg.CreatedBy)
|
|
||||||
d.Set("created_time", fg.CreatedTime)
|
|
||||||
d.Set("default_gw", fg.DefaultGW)
|
d.Set("default_gw", fg.DefaultGW)
|
||||||
d.Set("deleted_by", fg.DeletedBy)
|
|
||||||
d.Set("deleted_time", fg.DeletedTime)
|
|
||||||
d.Set("desc", fg.Description)
|
d.Set("desc", fg.Description)
|
||||||
d.Set("gid", fg.GID)
|
d.Set("gid", fg.GID)
|
||||||
d.Set("guid", fg.GUID)
|
d.Set("guid", fg.GUID)
|
||||||
@@ -60,20 +54,13 @@ func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
|||||||
d.Set("name", fg.Name)
|
d.Set("name", fg.Name)
|
||||||
d.Set("net_id", fg.NetID)
|
d.Set("net_id", fg.NetID)
|
||||||
d.Set("net_type", fg.NetType)
|
d.Set("net_type", fg.NetType)
|
||||||
d.Set("network", fg.Network)
|
|
||||||
d.Set("rg_id", fg.RGID)
|
|
||||||
d.Set("rg_name", fg.RGName)
|
|
||||||
d.Set("status", fg.Status)
|
d.Set("status", fg.Status)
|
||||||
d.Set("updated_by", fg.UpdatedBy)
|
|
||||||
d.Set("updated_time", fg.UpdatedTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, fg := range fg_list.Data {
|
for _, fg := range fg_list.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ckey": fg.CKey,
|
|
||||||
"meta": flattens.FlattenMeta(fg.Meta),
|
|
||||||
"account_id": fg.AccountID,
|
"account_id": fg.AccountID,
|
||||||
"client_ids": fg.ClientIDs,
|
"client_ids": fg.ClientIDs,
|
||||||
"client_type": fg.ClientType,
|
"client_type": fg.ClientType,
|
||||||
@@ -89,7 +76,6 @@ func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interf
|
|||||||
"name": fg.Name,
|
"name": fg.Name,
|
||||||
"net_id": fg.NetID,
|
"net_id": fg.NetID,
|
||||||
"net_type": fg.NetType,
|
"net_type": fg.NetType,
|
||||||
"net_mask": fg.NetMask,
|
|
||||||
"status": fg.Status,
|
"status": fg.Status,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,6 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +148,6 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,10 +205,6 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"conn_id": {
|
"conn_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -221,26 +213,10 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
"default_gw": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -257,26 +233,14 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
"net_mask": {
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rg_name": {
|
"ckey": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ package image
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
@@ -44,11 +44,12 @@ import (
|
|||||||
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
image, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(int(image.ID)))
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
|
||||||
flattenImage(d, image)
|
flattenImage(d, image)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package image
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenHistory(history []image.History) []map[string]interface{} {
|
func flattenHistory(history []image.History) []map[string]interface{} {
|
||||||
@@ -24,7 +23,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
|||||||
d.Set("unc_path", img.UNCPath)
|
d.Set("unc_path", img.UNCPath)
|
||||||
d.Set("ckey", img.CKey)
|
d.Set("ckey", img.CKey)
|
||||||
d.Set("account_id", img.AccountID)
|
d.Set("account_id", img.AccountID)
|
||||||
d.Set("acl", FlattenACL(img.ACL))
|
d.Set("acl", img.ACL)
|
||||||
d.Set("architecture", img.Architecture)
|
d.Set("architecture", img.Architecture)
|
||||||
d.Set("boot_type", img.BootType)
|
d.Set("boot_type", img.BootType)
|
||||||
d.Set("bootable", img.Bootable)
|
d.Set("bootable", img.Bootable)
|
||||||
@@ -86,18 +85,3 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func FlattenACL(acl interface{}) string {
|
|
||||||
switch d := acl.(type) {
|
|
||||||
case string:
|
|
||||||
return d
|
|
||||||
case int:
|
|
||||||
return strconv.Itoa(d)
|
|
||||||
case int64:
|
|
||||||
return strconv.FormatInt(d, 10)
|
|
||||||
case float64:
|
|
||||||
return strconv.FormatInt(int64(d), 10)
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +158,6 @@ func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
_, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import (
|
|||||||
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
||||||
@@ -400,10 +399,6 @@ func dataSourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -271,10 +271,6 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func dataSourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(aclList))
|
res := make([]map[string]interface{}, 0, len (aclList))
|
||||||
for _, acl := range aclList {
|
for _, acl := range aclList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"explicit": acl.Explicit,
|
"explicit": acl.Explicit,
|
||||||
@@ -134,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
res := make([]map[string]interface{}, 0, len (interfaces))
|
||||||
for _, interfaceCompute := range interfaces {
|
for _, interfaceCompute := range interfaces {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"def_gw": interfaceCompute.DefGW,
|
"def_gw": interfaceCompute.DefGW,
|
||||||
@@ -147,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(detailedInfoList))
|
res := make([]map[string]interface{}, 0, len (detailedInfoList))
|
||||||
if computes != nil {
|
if computes != nil {
|
||||||
for i, detailedInfo := range detailedInfoList {
|
for i, detailedInfo := range detailedInfoList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -247,7 +247,6 @@ func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []com
|
|||||||
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
||||||
d.Set("lb_id", cluster.LBID)
|
d.Set("lb_id", cluster.LBID)
|
||||||
d.Set("name", cluster.Name)
|
d.Set("name", cluster.Name)
|
||||||
d.Set("network_plugin", cluster.NetworkPlugin)
|
|
||||||
d.Set("rg_id", cluster.RGID)
|
d.Set("rg_id", cluster.RGID)
|
||||||
d.Set("rg_name", cluster.RGName)
|
d.Set("rg_name", cluster.RGName)
|
||||||
d.Set("status", cluster.Status)
|
d.Set("status", cluster.Status)
|
||||||
@@ -268,7 +267,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(workersGroups))
|
res := make([]map[string]interface{}, 0, len (workersGroups))
|
||||||
for _, worker := range workersGroups {
|
for _, worker := range workersGroups {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"annotations": worker.Annotations,
|
"annotations": worker.Annotations,
|
||||||
@@ -289,11 +288,11 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(k8sItems.Data))
|
res := make([]map[string]interface{}, 0, len (k8sItems.Data))
|
||||||
for _, item := range k8sItems.Data {
|
for _, item := range k8sItems.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": item.AccountID,
|
"account_id": item.AccountID,
|
||||||
"account_name": item.AccountName,
|
"account_name": item.Name,
|
||||||
"acl": item.ACL,
|
"acl": item.ACL,
|
||||||
"bservice_id": item.BServiceID,
|
"bservice_id": item.BServiceID,
|
||||||
"ci_id": item.CIID,
|
"ci_id": item.CIID,
|
||||||
@@ -309,7 +308,6 @@ func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
|||||||
"lb_id": item.LBID,
|
"lb_id": item.LBID,
|
||||||
"milestones": item.Milestones,
|
"milestones": item.Milestones,
|
||||||
"k8s_name": item.Name,
|
"k8s_name": item.Name,
|
||||||
"network_plugin": item.NetworkPlugin,
|
|
||||||
"rg_id": item.RGID,
|
"rg_id": item.RGID,
|
||||||
"rg_name": item.RGName,
|
"rg_name": item.RGName,
|
||||||
"service_account": flattenServiceAccount(item.ServiceAccount),
|
"service_account": flattenServiceAccount(item.ServiceAccount),
|
||||||
|
|||||||
@@ -1,396 +0,0 @@
|
|||||||
package k8s
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceK8sCPSchemaV1() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the cluster.",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "Resource group ID that this instance belongs to.",
|
|
||||||
},
|
|
||||||
"k8sci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "ID of the k8s catalog item to base this instance on.",
|
|
||||||
},
|
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Network plugin to be used",
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true),
|
|
||||||
},
|
|
||||||
"num": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
|
||||||
Description: "Number of VMs to create. Can be either 1 or 3",
|
|
||||||
},
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node CPU count.",
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node RAM in MB.",
|
|
||||||
},
|
|
||||||
"disk": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node boot disk size in GB.",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Storage Endpoint ID",
|
|
||||||
},
|
|
||||||
"sep_pool": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Storage Endpoint Pool",
|
|
||||||
},
|
|
||||||
"with_lb": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "Create k8s with load balancer if true.",
|
|
||||||
},
|
|
||||||
"extnet_only": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Use only selected ExtNet for infrastructure connections",
|
|
||||||
},
|
|
||||||
// /4.4.0
|
|
||||||
"cloud_init": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
|
|
||||||
},
|
|
||||||
"join_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings for joining a node to a cluster. It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"kube_proxy_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster. It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"kubelet_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster. It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"cluster_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to define global settings and configurations for the entire cluster. It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"init_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to define settings and actions that should be performed before any other component in the cluster starts. It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"additional_sans": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names",
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"ha_mode": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Use Highly Available schema for LB deploy",
|
|
||||||
},
|
|
||||||
"lb_sysctl_params": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
|
|
||||||
},
|
|
||||||
"oidc_cert": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "insert ssl certificate in x509 pem format",
|
|
||||||
},
|
|
||||||
////
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Text description of this instance.",
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "Start k8s cluster.",
|
|
||||||
},
|
|
||||||
"detailed_info": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"interfaces": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"def_gw": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ip_address": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"natable_vins_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"natable_vins_network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"master_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Master group ID.",
|
|
||||||
},
|
|
||||||
"master_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Master group name.",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"k8s_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"rg_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"bservice_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"k8s_ci_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"lb_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"k8s_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"lb_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "IP address of default load balancer.",
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"kubeconfig": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Kubeconfig for cluster access.",
|
|
||||||
},
|
|
||||||
"vins_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of default vins for this instace.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -189,6 +189,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
||||||
createReq.OidcCertificate = oidcCertificate.(string)
|
createReq.OidcCertificate = oidcCertificate.(string)
|
||||||
}
|
}
|
||||||
|
///
|
||||||
|
|
||||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||||
|
|
||||||
@@ -198,19 +199,12 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
createReq.ExtNetID = 0
|
createReq.ExtNetID = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if vins, ok := d.GetOk("vins_id"); ok {
|
|
||||||
createReq.VinsId = uint64(vins.(int))
|
|
||||||
} else {
|
|
||||||
createReq.VinsId = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if desc, ok := d.GetOk("desc"); ok {
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
createReq.Description = desc.(string)
|
createReq.Description = desc.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.CloudAPI().K8S().Create(ctx, createReq)
|
resp, err := c.CloudAPI().K8S().Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +310,7 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k8sList, err := utilityK8sListForResourceCheckPresence(ctx, d, m)
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -515,7 +509,7 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceK8sRead(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceK8sDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -551,15 +545,15 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Name of the cluster.",
|
Description: "Name of the cluster.",
|
||||||
},
|
},
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Resource group ID that this instance belongs to.",
|
Description: "Resource group ID that this instance belongs to.",
|
||||||
},
|
},
|
||||||
"k8sci_id": {
|
"k8sci_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the k8s catalog item to base this instance on.",
|
Description: "ID of the k8s catalog item to base this instance on.",
|
||||||
},
|
},
|
||||||
"wg_name": {
|
"wg_name": {
|
||||||
@@ -598,7 +592,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: mastersSchemaMake(),
|
Schema: mastersSchemaMake(),
|
||||||
@@ -627,17 +621,11 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Use only selected ExtNet for infrastructure connections",
|
Description: "Use only selected ExtNet for infrastructure connections",
|
||||||
},
|
},
|
||||||
"extnet_id": {
|
"extnet_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
|
||||||
},
|
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: false,
|
Computed: true,
|
||||||
Description: "Determines if cluster should be destroyed",
|
ForceNew: true,
|
||||||
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
},
|
},
|
||||||
|
|
||||||
///4.4.0
|
///4.4.0
|
||||||
@@ -705,6 +693,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: true,
|
Default: true,
|
||||||
Description: "Start k8s cluster",
|
Description: "Start k8s cluster",
|
||||||
},
|
},
|
||||||
|
|
||||||
"acl": {
|
"acl": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -753,6 +742,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "IP address of default load balancer.",
|
Description: "IP address of default load balancer.",
|
||||||
},
|
},
|
||||||
|
"permanently": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Determines if cluster should be destroyed",
|
||||||
|
},
|
||||||
|
|
||||||
"rg_name": {
|
"rg_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -159,9 +159,9 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
createReq.JoinConfiguration = joinConfig.(string)
|
createReq.JoinConfiguration = joinConfig.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||||
// createReq.UserData = cloudInit.(string)
|
createReq.UserData = cloudInit.(string)
|
||||||
// }
|
}
|
||||||
|
|
||||||
if initConfig, ok := d.GetOk("init_config"); ok {
|
if initConfig, ok := d.GetOk("init_config"); ok {
|
||||||
createReq.InitConfiguration = initConfig.(string)
|
createReq.InitConfiguration = initConfig.(string)
|
||||||
@@ -176,6 +176,8 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
log.Debug(createReq.OidcCertificate)
|
log.Debug(createReq.OidcCertificate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||||
|
|
||||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||||
@@ -184,19 +186,12 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
createReq.ExtNetID = 0
|
createReq.ExtNetID = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if vins, ok := d.GetOk("vins_id"); ok {
|
|
||||||
createReq.VinsId = uint64(vins.(int))
|
|
||||||
} else {
|
|
||||||
createReq.VinsId = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if desc, ok := d.GetOk("desc"); ok {
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
createReq.Description = desc.(string)
|
createReq.Description = desc.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.CloudAPI().K8S().Create(ctx, createReq)
|
resp, err := c.CloudAPI().K8S().Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +312,7 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k8sList, err := utilityK8sListForResourceCheckPresence(ctx, d, m)
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -532,16 +527,15 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceK8sCPRead(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
|
||||||
log.Debugf("resourceK8sControlPlaneDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
|
log.Debugf("resourceK8sDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
|
||||||
|
|
||||||
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,9 +552,8 @@ func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||||
@@ -571,15 +564,15 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Name of the cluster.",
|
Description: "Name of the cluster.",
|
||||||
},
|
},
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Resource group ID that this instance belongs to.",
|
Description: "Resource group ID that this instance belongs to.",
|
||||||
},
|
},
|
||||||
"k8sci_id": {
|
"k8sci_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the k8s catalog item to base this instance on.",
|
Description: "ID of the k8s catalog item to base this instance on.",
|
||||||
},
|
},
|
||||||
"network_plugin": {
|
"network_plugin": {
|
||||||
@@ -641,6 +634,12 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "Use only selected ExtNet for infrastructure connections",
|
Description: "Use only selected ExtNet for infrastructure connections",
|
||||||
},
|
},
|
||||||
|
///4.4.0
|
||||||
|
"cloud_init": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
|
||||||
|
},
|
||||||
"join_config": {
|
"join_config": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -689,11 +688,19 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "insert ssl certificate in x509 pem format",
|
Description: "insert ssl certificate in x509 pem format",
|
||||||
},
|
},
|
||||||
|
"permanently": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Determines if cluster should be destroyed",
|
||||||
|
},
|
||||||
|
|
||||||
|
////
|
||||||
"extnet_id": {
|
"extnet_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
},
|
},
|
||||||
"desc": {
|
"desc": {
|
||||||
@@ -776,12 +783,6 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "IP address of default load balancer.",
|
Description: "IP address of default load balancer.",
|
||||||
},
|
},
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Determines if cluster should be destroyed",
|
|
||||||
},
|
|
||||||
"rg_name": {
|
"rg_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -809,7 +810,6 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
"vins_id": {
|
"vins_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "ID of default vins for this instace.",
|
Description: "ID of default vins for this instace.",
|
||||||
},
|
},
|
||||||
@@ -818,7 +818,7 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
|||||||
|
|
||||||
func ResourceK8sCP() *schema.Resource {
|
func ResourceK8sCP() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 2,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceK8sCPCreate,
|
CreateContext: resourceK8sCPCreate,
|
||||||
ReadContext: resourceK8sCPRead,
|
ReadContext: resourceK8sCPRead,
|
||||||
@@ -838,12 +838,5 @@ func ResourceK8sCP() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceK8sCPSchemaMake(),
|
Schema: resourceK8sCPSchemaMake(),
|
||||||
StateUpgraders: []schema.StateUpgrader{
|
|
||||||
{
|
|
||||||
Type: resourceK8sCPSchemaV1().CoreConfigSchema().ImpliedType(),
|
|
||||||
Upgrade: resourceK8sCPStateUpgradeV1,
|
|
||||||
Version: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceK8sWgRead(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -210,7 +210,6 @@ func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
wg, err := utilityK8sWgCheckPresence(ctx, d, m)
|
wg, err := utilityK8sWgCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,8 +224,6 @@ func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,14 +232,14 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
|||||||
"k8s_id": {
|
"k8s_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
// ForceNew: true,
|
||||||
Description: "ID of k8s instance.",
|
Description: "ID of k8s instance.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
// ForceNew: true,
|
||||||
Description: "Name of the worker group.",
|
Description: "Name of the worker group.",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -256,7 +253,7 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
|||||||
"cpu": {
|
"cpu": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
//ForceNew: true,
|
// ForceNew: true,
|
||||||
Default: 1,
|
Default: 1,
|
||||||
Description: "Worker node CPU count.",
|
Description: "Worker node CPU count.",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package k8s
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceK8sCPStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
|
||||||
log.Debug("resourceK8sCPStateUpgradeV1: upgrading state")
|
|
||||||
|
|
||||||
delete(rawState, "cloud_init")
|
|
||||||
|
|
||||||
return rawState, nil
|
|
||||||
}
|
|
||||||
@@ -273,22 +273,7 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return k8sList, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func utilityK8sListForResourceCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*k8s.ListK8SClusters, error) {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := k8s.ListRequest{
|
|
||||||
IncludeDeleted: false,
|
|
||||||
}
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
|
||||||
req.Name = name.(string)
|
|
||||||
}
|
|
||||||
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
return nil, fmt.Errorf("not found wg with id: %v in k8s cluster: %v", wgId, cluster.ID)
|
return nil, fmt.Errorf("not found wg with id: %v in k8s cluster: %v", wgId, cluster.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (k8s.ListK8SGroups, error) {
|
func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (k8s.ListK8SGroups, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := k8s.GetRequest{
|
req := k8s.GetRequest{
|
||||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||||
@@ -142,7 +142,7 @@ func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
|||||||
func utilityK8sWgCloudInitCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
func utilityK8sWgCloudInitCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := k8s.GetWorkerNodesMetaDataRequest{
|
req := k8s.GetWorkerNodesMetaDataRequest{
|
||||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||||
WorkersGroupID: uint64(d.Get("wg_id").(int)),
|
WorkersGroupID: uint64(d.Get("wg_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ func findInExtraDisks(DiskId uint, ExtraDisks []interface{}) bool {
|
|||||||
func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
compute, err := utilityDataComputeCheckPresence(ctx, d, m)
|
compute, err := utilityDataComputeCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId(strconv.Itoa(int(compute.ID)))
|
d.SetId(strconv.Itoa(int(compute.ID)))
|
||||||
@@ -291,10 +290,6 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"image_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"images": {
|
"images": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -449,10 +444,6 @@ func computeInterfacesSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"flip_group_id": {
|
"flip_group_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -615,7 +606,7 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"boot_disk_size": {
|
"bootdisk_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
@@ -720,10 +711,6 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"need_reboot" : {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"natable_vins_id": {
|
"natable_vins_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeAudits, err := utilityComputeAuditsCheckPresence(ctx, d, m)
|
computeAudits, err := utilityComputeAuditsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeGetAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeGetAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeAudits, err := utilityComputeGetAuditsCheckPresence(ctx, d, m)
|
computeAudits, err := utilityComputeGetAuditsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -45,13 +45,12 @@ import (
|
|||||||
func dataSourceComputeGetConsoleUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeGetConsoleUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeConsoleUrl, err := utilityComputeGetConsoleUrlCheckPresence(ctx, d, m)
|
computeConsoleUrl, err := utilityComputeGetConsoleUrlCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
result := strings.ReplaceAll(computeConsoleUrl, "\"", "")
|
result := strings.ReplaceAll(string(computeConsoleUrl), "\"", "")
|
||||||
result = strings.ReplaceAll(result, "\\", "")
|
result = strings.ReplaceAll(string(result), "\\", "")
|
||||||
d.Set("console_url", result)
|
d.Set("console_url", result)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeGetLogRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeGetLogRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeGetLog, err := utilityComputeGetLogCheckPresence(ctx, d, m)
|
computeGetLog, err := utilityComputeGetLogCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeList, err := utilityDataComputeListCheckPresence(ctx, d, m)
|
computeList, err := utilityDataComputeListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"boot_disk_size": {
|
"bootdisk_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
@@ -233,10 +232,6 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"need_reboot": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pinned": {
|
"pinned": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeList, err := utilityDataComputeListDeletedCheckPresence(ctx, d, m)
|
computeList, err := utilityDataComputeListDeletedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputePCIDeviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputePCIDeviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computePCIDeviceList, err := utilityComputePCIDeviceListCheckPresence(ctx, d, m)
|
computePCIDeviceList, err := utilityComputePCIDeviceListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
@@ -81,13 +80,13 @@ func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Find by status",
|
Description: "Find by status",
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page number",
|
Description: "Page number",
|
||||||
},
|
},
|
||||||
"size": {
|
"size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page size",
|
Description: "Page size",
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computePfwList, err := utilityComputePfwListCheckPresence(ctx, d, m)
|
computePfwList, err := utilityComputePfwListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
func dataSourceComputeSnapshotUsageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeSnapshotUsageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeSnapshotUsage, err := utilityComputeSnapshotUsageCheckPresence(ctx, d, m)
|
computeSnapshotUsage, err := utilityComputeSnapshotUsageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeUserListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeUserListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeUserList, err := utilityComputeUserListCheckPresence(ctx, d, m)
|
computeUserList, err := utilityComputeUserListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceComputeVGPUListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceComputeVGPUListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
computeVGPUList, err := utilityComputeVGPUListCheckPresence(ctx, d, m)
|
computeVGPUList, err := utilityComputeVGPUListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
@@ -76,18 +75,18 @@ func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Find by status",
|
Description: "Find by status",
|
||||||
},
|
},
|
||||||
"includedeleted": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
|
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page number",
|
Description: "Page number",
|
||||||
},
|
},
|
||||||
"size": {
|
"size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page size",
|
Description: "Page size",
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
@@ -95,6 +94,7 @@ func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"entry_count": {
|
"entry_count": {
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
|||||||
"conn_id": interfaceItem.ConnID,
|
"conn_id": interfaceItem.ConnID,
|
||||||
"conn_type": interfaceItem.ConnType,
|
"conn_type": interfaceItem.ConnType,
|
||||||
"def_gw": interfaceItem.DefGW,
|
"def_gw": interfaceItem.DefGW,
|
||||||
"enabled": interfaceItem.Enabled,
|
|
||||||
"flip_group_id": interfaceItem.FLIPGroupID,
|
"flip_group_id": interfaceItem.FLIPGroupID,
|
||||||
"guid": interfaceItem.GUID,
|
"guid": interfaceItem.GUID,
|
||||||
"ip_address": interfaceItem.IPAddress,
|
"ip_address": interfaceItem.IPAddress,
|
||||||
@@ -164,7 +163,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
|||||||
"anti_affinity_rules": flattenListRules(compute.AntiAffinityRules),
|
"anti_affinity_rules": flattenListRules(compute.AntiAffinityRules),
|
||||||
"arch": compute.Architecture,
|
"arch": compute.Architecture,
|
||||||
"boot_order": compute.BootOrder,
|
"boot_order": compute.BootOrder,
|
||||||
"boot_disk_size": compute.BootDiskSize,
|
"bootdisk_size": compute.BootDiskSize,
|
||||||
"clone_reference": compute.CloneReference,
|
"clone_reference": compute.CloneReference,
|
||||||
"clones": compute.Clones,
|
"clones": compute.Clones,
|
||||||
"computeci_id": compute.ComputeCIID,
|
"computeci_id": compute.ComputeCIID,
|
||||||
@@ -189,7 +188,6 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
|||||||
"migrationjob": compute.MigrationJob,
|
"migrationjob": compute.MigrationJob,
|
||||||
"milestones": compute.Milestones,
|
"milestones": compute.Milestones,
|
||||||
"name": compute.Name,
|
"name": compute.Name,
|
||||||
"need_reboot": compute.NeedReboot,
|
|
||||||
"pinned": compute.Pinned,
|
"pinned": compute.Pinned,
|
||||||
"ram": compute.RAM,
|
"ram": compute.RAM,
|
||||||
"reference_id": compute.ReferenceID,
|
"reference_id": compute.ReferenceID,
|
||||||
@@ -267,6 +265,7 @@ func flattenComputeDisksDemo(ctx context.Context, d *schema.ResourceData, disksL
|
|||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(res, func(i, j int) bool {
|
sort.Slice(res, func(i, j int) bool {
|
||||||
return res[i]["disk_id"].(uint64) < res[j]["disk_id"].(uint64)
|
return res[i]["disk_id"].(uint64) < res[j]["disk_id"].(uint64)
|
||||||
})
|
})
|
||||||
@@ -332,7 +331,6 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
|
|||||||
d.Set("affinity_weight", computeRec.AffinityWeight)
|
d.Set("affinity_weight", computeRec.AffinityWeight)
|
||||||
d.Set("arch", computeRec.Architecture)
|
d.Set("arch", computeRec.Architecture)
|
||||||
d.Set("boot_order", computeRec.BootOrder)
|
d.Set("boot_order", computeRec.BootOrder)
|
||||||
// we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform
|
|
||||||
d.Set("boot_disk_size", bootDisk.SizeMax)
|
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||||
d.Set("boot_disk", flattenBootDisk(bootDisk))
|
d.Set("boot_disk", flattenBootDisk(bootDisk))
|
||||||
d.Set("boot_disk_id", bootDisk.ID)
|
d.Set("boot_disk_id", bootDisk.ID)
|
||||||
@@ -369,7 +367,6 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
|
|||||||
d.Set("migrationjob", computeRec.MigrationJob)
|
d.Set("migrationjob", computeRec.MigrationJob)
|
||||||
d.Set("milestones", computeRec.Milestones)
|
d.Set("milestones", computeRec.Milestones)
|
||||||
d.Set("name", computeRec.Name)
|
d.Set("name", computeRec.Name)
|
||||||
d.Set("need_reboot", computeRec.NeedReboot)
|
|
||||||
d.Set("natable_vins_id", computeRec.NatableVINSID)
|
d.Set("natable_vins_id", computeRec.NatableVINSID)
|
||||||
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
|
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
|
||||||
d.Set("natable_vins_name", computeRec.NatableVINSName)
|
d.Set("natable_vins_name", computeRec.NatableVINSName)
|
||||||
@@ -389,7 +386,7 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
|
|||||||
d.Set("stateless_sep_id", computeRec.StatelessSepID)
|
d.Set("stateless_sep_id", computeRec.StatelessSepID)
|
||||||
d.Set("stateless_sep_type", computeRec.StatelessSepType)
|
d.Set("stateless_sep_type", computeRec.StatelessSepType)
|
||||||
d.Set("status", computeRec.Status)
|
d.Set("status", computeRec.Status)
|
||||||
// d.Set("tags", flattenTags(computeRec.Tags))
|
d.Set("tags", flattenTags(computeRec.Tags))
|
||||||
d.Set("tech_status", computeRec.TechStatus)
|
d.Set("tech_status", computeRec.TechStatus)
|
||||||
d.Set("updated_by", computeRec.UpdatedBy)
|
d.Set("updated_by", computeRec.UpdatedBy)
|
||||||
d.Set("updated_time", computeRec.UpdatedTime)
|
d.Set("updated_time", computeRec.UpdatedTime)
|
||||||
@@ -563,7 +560,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
|||||||
d.Set("anti_affinity_rules", flattenListRules(computeRec.AntiAffinityRules))
|
d.Set("anti_affinity_rules", flattenListRules(computeRec.AntiAffinityRules))
|
||||||
d.Set("arch", computeRec.Architecture)
|
d.Set("arch", computeRec.Architecture)
|
||||||
d.Set("boot_order", computeRec.BootOrder)
|
d.Set("boot_order", computeRec.BootOrder)
|
||||||
d.Set("boot_disk_size", computeRec.BootDiskSize)
|
d.Set("bootdisk_size", computeRec.BootDiskSize)
|
||||||
d.Set("clone_reference", computeRec.CloneReference)
|
d.Set("clone_reference", computeRec.CloneReference)
|
||||||
d.Set("clones", computeRec.Clones)
|
d.Set("clones", computeRec.Clones)
|
||||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||||
@@ -581,7 +578,6 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
|||||||
d.Set("guid", computeRec.GUID)
|
d.Set("guid", computeRec.GUID)
|
||||||
d.Set("compute_id", computeRec.ID)
|
d.Set("compute_id", computeRec.ID)
|
||||||
d.Set("image_id", computeRec.ImageID)
|
d.Set("image_id", computeRec.ImageID)
|
||||||
d.Set("image_name", computeRec.ImageName)
|
|
||||||
d.Set("interfaces", flattenInterfaces(computeRec.Interfaces))
|
d.Set("interfaces", flattenInterfaces(computeRec.Interfaces))
|
||||||
d.Set("lock_status", computeRec.LockStatus)
|
d.Set("lock_status", computeRec.LockStatus)
|
||||||
d.Set("manager_id", computeRec.ManagerID)
|
d.Set("manager_id", computeRec.ManagerID)
|
||||||
@@ -589,7 +585,6 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
|||||||
d.Set("migrationjob", computeRec.MigrationJob)
|
d.Set("migrationjob", computeRec.MigrationJob)
|
||||||
d.Set("milestones", computeRec.Milestones)
|
d.Set("milestones", computeRec.Milestones)
|
||||||
d.Set("name", computeRec.Name)
|
d.Set("name", computeRec.Name)
|
||||||
d.Set("need_reboot", computeRec.NeedReboot)
|
|
||||||
d.Set("natable_vins_id", computeRec.NatableVINSID)
|
d.Set("natable_vins_id", computeRec.NatableVINSID)
|
||||||
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
|
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
|
||||||
d.Set("natable_vins_name", computeRec.NatableVINSName)
|
d.Set("natable_vins_name", computeRec.NatableVINSName)
|
||||||
@@ -682,19 +677,19 @@ func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []ma
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// func flattenSnapshotList(computeSnapshotUsages *compute.ListSnapShots) []map[string]interface{} {
|
func flattenSnapshotList(computeSnapshotUsages *compute.ListSnapShots) []map[string]interface{} {
|
||||||
// res := make([]map[string]interface{}, 0, len(computeSnapshotUsages.Data))
|
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages.Data))
|
||||||
// for _, computeUsage := range computeSnapshotUsages.Data {
|
for _, computeUsage := range computeSnapshotUsages.Data {
|
||||||
// temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
// "disks": computeUsage.Disks,
|
"disks": computeUsage.Disks,
|
||||||
// "guid": computeUsage.GUID,
|
"guid": computeUsage.GUID,
|
||||||
// "label": computeUsage.Label,
|
"label": computeUsage.Label,
|
||||||
// "timestamp": computeUsage.Timestamp,
|
"timestamp": computeUsage.Timestamp,
|
||||||
// }
|
}
|
||||||
// res = append(res, temp)
|
res = append(res, temp)
|
||||||
// }
|
}
|
||||||
// return res
|
return res
|
||||||
// }
|
}
|
||||||
|
|
||||||
func flattenVGPU(m []interface{}) []string {
|
func flattenVGPU(m []interface{}) []string {
|
||||||
output := []string{}
|
output := []string{}
|
||||||
|
|||||||
@@ -160,32 +160,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createReqPPC.Interfaces = make([]kvmppc.Interface, 0)
|
|
||||||
|
|
||||||
if networks, ok := d.GetOk("network"); ok {
|
|
||||||
if networks.(*schema.Set).Len() > 0 {
|
|
||||||
ns := networks.(*schema.Set).List()
|
|
||||||
|
|
||||||
interfaces := make([]kvmppc.Interface, 0)
|
|
||||||
for _, elem := range ns {
|
|
||||||
netInterfaceVal := elem.(map[string]interface{})
|
|
||||||
reqInterface := kvmppc.Interface{
|
|
||||||
NetType: netInterfaceVal["net_type"].(string),
|
|
||||||
NetID: uint64(netInterfaceVal["net_id"].(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
ipaddr, ipSet := netInterfaceVal["ip_address"]
|
|
||||||
if ipSet {
|
|
||||||
reqInterface.IPAddr = ipaddr.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaces = append(interfaces, reqInterface)
|
|
||||||
}
|
|
||||||
|
|
||||||
createReqPPC.Interfaces = interfaces
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
argVal, ok = d.GetOk("cloud_init")
|
argVal, ok = d.GetOk("cloud_init")
|
||||||
if ok {
|
if ok {
|
||||||
userdata := argVal.(string)
|
userdata := argVal.(string)
|
||||||
@@ -273,81 +247,33 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if disks, ok := d.GetOk("disks"); ok {
|
// Note bene: we created compute in a STOPPED state (this is required to properly attach 1st network interface),
|
||||||
log.Debugf("resourceComputeCreate: Create disks on ComputeID: %d", computeId)
|
// now we need to start it before we report the sequence complete
|
||||||
addedDisks := disks.([]interface{})
|
if d.Get("started").(bool) {
|
||||||
if len(addedDisks) > 0 {
|
req := compute.StartRequest{ComputeID: computeId}
|
||||||
for _, disk := range addedDisks {
|
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||||
diskConv := disk.(map[string]interface{})
|
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||||
req := compute.DiskAddRequest{
|
warnings.Add(err)
|
||||||
ComputeID: computeId,
|
}
|
||||||
DiskName: diskConv["disk_name"].(string),
|
}
|
||||||
Size: uint64(diskConv["size"].(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
if diskConv["sep_id"].(int) != 0 {
|
if enabled, ok := d.GetOk("enabled"); ok {
|
||||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
if enabled.(bool) {
|
||||||
}
|
req := compute.EnableRequest{ComputeID: computeId}
|
||||||
if diskConv["disk_type"].(string) != "" {
|
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
|
||||||
req.DiskType = diskConv["disk_type"].(string)
|
if _, err := c.CloudAPI().Compute().Enable(ctx, req); err != nil {
|
||||||
}
|
warnings.Add(err)
|
||||||
if diskConv["pool"].(string) != "" {
|
}
|
||||||
req.Pool = diskConv["pool"].(string)
|
} else {
|
||||||
}
|
req := compute.DisableRequest{ComputeID: computeId}
|
||||||
if diskConv["desc"].(string) != "" {
|
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
|
||||||
req.Description = diskConv["desc"].(string)
|
if _, err := c.CloudAPI().Compute().Disable(ctx, req); err != nil {
|
||||||
}
|
warnings.Add(err)
|
||||||
if diskConv["image_id"].(int) != 0 {
|
|
||||||
req.ImageID = uint64(diskConv["image_id"].(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
cleanup = true
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cleanup {
|
if !cleanup {
|
||||||
if enabled, ok := d.GetOk("enabled"); ok {
|
|
||||||
if enabled.(bool) {
|
|
||||||
req := compute.EnableRequest{ComputeID: computeId}
|
|
||||||
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
|
|
||||||
if _, err := c.CloudAPI().Compute().Enable(ctx, req); err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
req := compute.DisableRequest{ComputeID: computeId}
|
|
||||||
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
|
|
||||||
if _, err := c.CloudAPI().Compute().Disable(ctx, req); err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note bene: we created compute in a STOPPED state (this is required to properly attach 1st network interface),
|
|
||||||
// now we need to start it before we report the sequence complete
|
|
||||||
if start, ok := d.GetOk("started"); ok {
|
|
||||||
if start.(bool) {
|
|
||||||
req := compute.StartRequest{ComputeID: computeId}
|
|
||||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !start.(bool) {
|
|
||||||
req := compute.StopRequest{ComputeID: computeId}
|
|
||||||
log.Debugf("resourceComputeCreate: stoping Compute ID %d after completing its resource configuration", computeId)
|
|
||||||
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if affinityLabel, ok := d.GetOk("affinity_label"); ok {
|
if affinityLabel, ok := d.GetOk("affinity_label"); ok {
|
||||||
req := compute.AffinityLabelSetRequest{
|
req := compute.AffinityLabelSetRequest{
|
||||||
ComputeID: computeId,
|
ComputeID: computeId,
|
||||||
@@ -360,6 +286,43 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if disks, ok := d.GetOk("disks"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create disks on ComputeID: %d", computeId)
|
||||||
|
addedDisks := disks.([]interface{})
|
||||||
|
if len(addedDisks) > 0 {
|
||||||
|
for _, disk := range addedDisks {
|
||||||
|
diskConv := disk.(map[string]interface{})
|
||||||
|
req := compute.DiskAddRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
DiskName: diskConv["disk_name"].(string),
|
||||||
|
Size: uint64(diskConv["size"].(int)),
|
||||||
|
SepID: uint64(diskConv["sep_id"].(int)),
|
||||||
|
}
|
||||||
|
|
||||||
|
if diskConv["disk_type"].(string) != "" {
|
||||||
|
req.DiskType = diskConv["disk_type"].(string)
|
||||||
|
}
|
||||||
|
if diskConv["pool"].(string) != "" {
|
||||||
|
req.Pool = diskConv["pool"].(string)
|
||||||
|
}
|
||||||
|
if diskConv["desc"].(string) != "" {
|
||||||
|
req.Description = diskConv["desc"].(string)
|
||||||
|
}
|
||||||
|
if diskConv["image_id"].(int) != 0 {
|
||||||
|
req.ImageID = uint64(diskConv["image_id"].(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
cleanup = true
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ars, ok := d.GetOk("affinity_rules"); ok {
|
if ars, ok := d.GetOk("affinity_rules"); ok {
|
||||||
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", computeId)
|
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", computeId)
|
||||||
addedAR := ars.([]interface{})
|
addedAR := ars.([]interface{})
|
||||||
@@ -405,134 +368,133 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if tags, ok := d.GetOk("tags"); ok {
|
if tags, ok := d.GetOk("tags"); ok {
|
||||||
log.Debugf("resourceComputeCreate: Create tags on ComputeID: %d", computeId)
|
log.Debugf("resourceComputeCreate: Create tags on ComputeID: %d", computeId)
|
||||||
addedTags := tags.(*schema.Set).List()
|
addedTags := tags.(*schema.Set).List()
|
||||||
if len(addedTags) > 0 {
|
if len(addedTags) > 0 {
|
||||||
for _, tagInterface := range addedTags {
|
for _, tagInterface := range addedTags {
|
||||||
tagItem := tagInterface.(map[string]interface{})
|
tagItem := tagInterface.(map[string]interface{})
|
||||||
req := compute.TagAddRequest{
|
req := compute.TagAddRequest{
|
||||||
ComputeID: computeId,
|
|
||||||
Key: tagItem["key"].(string),
|
|
||||||
Value: tagItem["value"].(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Compute().TagAdd(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if pfws, ok := d.GetOk("port_forwarding"); ok {
|
|
||||||
log.Debugf("resourceComputeCreate: Create port farwarding on ComputeID: %d", computeId)
|
|
||||||
addedPfws := pfws.(*schema.Set).List()
|
|
||||||
if len(addedPfws) > 0 {
|
|
||||||
for _, pfwInterface := range addedPfws {
|
|
||||||
pfwItem := pfwInterface.(map[string]interface{})
|
|
||||||
req := compute.PFWAddRequest{
|
|
||||||
ComputeID: computeId,
|
|
||||||
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
|
|
||||||
LocalBasePort: uint64(pfwItem["local_port"].(int)),
|
|
||||||
Proto: pfwItem["proto"].(string),
|
|
||||||
}
|
|
||||||
if pfwItem["public_port_end"].(int) != 0 {
|
|
||||||
req.PublicPortEnd = int64(pfwItem["public_port_end"].(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Compute().PFWAdd(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if userAcess, ok := d.GetOk("user_access"); ok {
|
|
||||||
log.Debugf("resourceComputeCreate: Create user access on ComputeID: %d", computeId)
|
|
||||||
usersAcess := userAcess.(*schema.Set).List()
|
|
||||||
if len(usersAcess) > 0 {
|
|
||||||
for _, userAcessInterface := range usersAcess {
|
|
||||||
userAccessItem := userAcessInterface.(map[string]interface{})
|
|
||||||
req := compute.UserGrantRequest{
|
|
||||||
ComputeID: computeId,
|
|
||||||
Username: userAccessItem["username"].(string),
|
|
||||||
AccessType: userAccessItem["access_type"].(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Compute().UserGrant(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if snapshotList, ok := d.GetOk("snapshot"); ok {
|
|
||||||
log.Debugf("resourceComputeCreate: Create snapshot on ComputeID: %d", computeId)
|
|
||||||
snapshots := snapshotList.(*schema.Set).List()
|
|
||||||
if len(snapshots) > 0 {
|
|
||||||
for _, snapshotInterface := range snapshots {
|
|
||||||
snapshotItem := snapshotInterface.(map[string]interface{})
|
|
||||||
req := compute.SnapshotCreateRequest{
|
|
||||||
ComputeID: computeId,
|
|
||||||
Label: snapshotItem["label"].(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Compute().SnapshotCreate(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if cdtList, ok := d.GetOk("cd"); ok {
|
|
||||||
log.Debugf("resourceComputeCreate: Create cd on ComputeID: %d", computeId)
|
|
||||||
cds := cdtList.(*schema.Set).List()
|
|
||||||
if len(cds) > 0 {
|
|
||||||
snapshotItem := cds[0].(map[string]interface{})
|
|
||||||
req := compute.CDInsertRequest{
|
|
||||||
ComputeID: computeId,
|
ComputeID: computeId,
|
||||||
CDROMID: uint64(snapshotItem["cdrom_id"].(int)),
|
Key: tagItem["key"].(string),
|
||||||
|
Value: tagItem["value"].(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().Compute().CDInsert(ctx, req)
|
_, err := c.CloudAPI().Compute().TagAdd(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if d.Get("pin_to_stack").(bool) {
|
if pfws, ok := d.GetOk("port_forwarding"); ok {
|
||||||
req := compute.PinToStackRequest{
|
log.Debugf("resourceComputeCreate: Create port farwarding on ComputeID: %d", computeId)
|
||||||
ComputeID: computeId,
|
addedPfws := pfws.(*schema.Set).List()
|
||||||
}
|
if len(addedPfws) > 0 {
|
||||||
_, err := c.CloudAPI().Compute().PinToStack(ctx, req)
|
for _, pfwInterface := range addedPfws {
|
||||||
if err != nil {
|
pfwItem := pfwInterface.(map[string]interface{})
|
||||||
warnings.Add(err)
|
req := compute.PFWAddRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
|
||||||
|
PublicPortEnd: int64(pfwItem["public_port_end"].(int)),
|
||||||
|
LocalBasePort: uint64(pfwItem["local_port"].(int)),
|
||||||
|
Proto: pfwItem["proto"].(string),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Compute().PFWAdd(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if userAcess, ok := d.GetOk("user_access"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create user access on ComputeID: %d", computeId)
|
||||||
|
usersAcess := userAcess.(*schema.Set).List()
|
||||||
|
if len(usersAcess) > 0 {
|
||||||
|
for _, userAcessInterface := range usersAcess {
|
||||||
|
userAccessItem := userAcessInterface.(map[string]interface{})
|
||||||
|
req := compute.UserGrantRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
Username: userAccessItem["username"].(string),
|
||||||
|
AccessType: userAccessItem["access_type"].(string),
|
||||||
|
}
|
||||||
|
|
||||||
if d.Get("pause").(bool) {
|
_, err := c.CloudAPI().Compute().UserGrant(ctx, req)
|
||||||
req := compute.PauseRequest{
|
if err != nil {
|
||||||
ComputeID: computeId,
|
warnings.Add(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_, err := c.CloudAPI().Compute().Pause(ctx, req)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if snapshotList, ok := d.GetOk("snapshot"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create snapshot on ComputeID: %d", computeId)
|
||||||
|
snapshots := snapshotList.(*schema.Set).List()
|
||||||
|
if len(snapshots) > 0 {
|
||||||
|
for _, snapshotInterface := range snapshots {
|
||||||
|
snapshotItem := snapshotInterface.(map[string]interface{})
|
||||||
|
req := compute.SnapshotCreateRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
Label: snapshotItem["label"].(string),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Compute().SnapshotCreate(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if cdtList, ok := d.GetOk("cd"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create cd on ComputeID: %d", computeId)
|
||||||
|
cds := cdtList.(*schema.Set).List()
|
||||||
|
if len(cds) > 0 {
|
||||||
|
snapshotItem := cds[0].(map[string]interface{})
|
||||||
|
req := compute.CDInsertRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
CDROMID: uint64(snapshotItem["cdrom_id"].(int)),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Compute().CDInsert(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.Get("pin_to_stack").(bool) == true {
|
||||||
|
req := compute.PinToStackRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().Compute().PinToStack(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Get("pause").(bool) == true {
|
||||||
|
req := compute.PauseRequest{
|
||||||
|
ComputeID: computeId,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().Compute().Pause(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
||||||
|
|
||||||
// We may reuse dataSourceComputeRead here as we maintain similarity
|
// We may reuse dataSourceComputeRead here as we maintain similarity
|
||||||
// between Compute resource and Compute data source schemas
|
// between Compute resource and Compute data source schemas
|
||||||
// Compute read function will also update resource ID on success, so that Terraform
|
// Compute read function will also update resource ID on success, so that Terraform
|
||||||
// will know the resource exists
|
// will know the resource exists
|
||||||
return append(warnings.Get(), resourceComputeRead(ctx, d, m)...)
|
defer resourceComputeRead(ctx, d, m)
|
||||||
|
return warnings.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -543,7 +505,6 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,76 +608,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged := false
|
|
||||||
|
|
||||||
// check compute statuses
|
|
||||||
switch computeRec.Status {
|
|
||||||
case status.Deleted:
|
|
||||||
if restore, ok := d.GetOk("restore"); ok && restore.(bool) {
|
|
||||||
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
|
||||||
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if enabled, ok := d.GetOk("enabled"); ok {
|
|
||||||
if enabled.(bool) {
|
|
||||||
enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
|
||||||
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !enabled.(bool) {
|
|
||||||
enableReq := compute.DisableRequest{ComputeID: computeRec.ID}
|
|
||||||
_, err = c.CloudAPI().Compute().Disable(ctx, enableReq)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if start, ok := d.GetOk("started"); ok {
|
|
||||||
if start.(bool) {
|
|
||||||
req := compute.StartRequest{ComputeID: computeRec.ID}
|
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !start.(bool) {
|
|
||||||
req := compute.StopRequest{ComputeID: computeRec.ID}
|
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hasChanged = true
|
|
||||||
case status.Destroyed:
|
|
||||||
d.SetId("")
|
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
|
||||||
// return resourceComputeCreate(ctx, d, m)
|
|
||||||
case status.Disabled:
|
|
||||||
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", computeRec.Status)
|
|
||||||
case status.Redeploying:
|
|
||||||
case status.Deleting:
|
|
||||||
case status.Destroying:
|
|
||||||
return diag.Errorf("The compute is in progress with status: %s", computeRec.Status)
|
|
||||||
case status.Modeled:
|
|
||||||
return diag.Errorf("The compute is in status: %s, please, contant the support for more information", computeRec.Status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if hasChanged {
|
|
||||||
computeRec, err = utilityComputeCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("enabled") {
|
if d.HasChange("enabled") {
|
||||||
enabled := d.Get("enabled").(bool)
|
enabled := d.Get("enabled").(bool)
|
||||||
if enabled {
|
if enabled {
|
||||||
@@ -739,39 +630,45 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
log.Debugf("resourceComputeUpdate: enable=%s Compute ID %v after completing its resource configuration", d.Id(), enabled)
|
log.Debugf("resourceComputeUpdate: enable=%s Compute ID %v after completing its resource configuration", d.Id(), enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("started") {
|
// check compute statuses
|
||||||
start := d.Get("started").(bool)
|
switch computeRec.Status {
|
||||||
if start {
|
case status.Deleted:
|
||||||
req := compute.StartRequest{ComputeID: computeRec.ID}
|
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
||||||
|
enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
if !start {
|
|
||||||
req := compute.StopRequest{ComputeID: computeRec.ID}
|
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
|
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case status.Destroyed:
|
||||||
|
d.SetId("")
|
||||||
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceComputeCreate(ctx, d, m)
|
||||||
|
case status.Disabled:
|
||||||
|
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", computeRec.Status)
|
||||||
|
case status.Redeploying:
|
||||||
|
case status.Deleting:
|
||||||
|
case status.Destroying:
|
||||||
|
return diag.Errorf("The compute is in progress with status: %s", computeRec.Status)
|
||||||
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The compute is in status: %s, please, contant the support for more information", computeRec.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
doUpdate := false
|
doUpdate := false
|
||||||
resizeReq := compute.ResizeRequest{
|
resizeReq := compute.ResizeRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
Force: true,
|
||||||
forceResize, ok := d.GetOk("force_resize")
|
|
||||||
if ok {
|
|
||||||
resizeReq.Force = forceResize.(bool)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
warnings := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
oldCpu, newCpu := d.GetChange("cpu")
|
oldCpu, newCpu := d.GetChange("cpu")
|
||||||
if oldCpu.(int) > newCpu.(int) && !forceResize.(bool) {
|
|
||||||
return diag.Errorf("Cannot resize compute ID %d: enable 'force_resize' to reduce compute vCPUs", computeRec.ID)
|
|
||||||
}
|
|
||||||
if oldCpu.(int) != newCpu.(int) {
|
if oldCpu.(int) != newCpu.(int) {
|
||||||
resizeReq.CPU = uint64(newCpu.(int))
|
resizeReq.CPU = uint64(newCpu.(int))
|
||||||
doUpdate = true
|
doUpdate = true
|
||||||
@@ -839,16 +736,14 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChanges("description", "name") {
|
if d.HasChange("description") || d.HasChange("name") {
|
||||||
req := compute.UpdateRequest{
|
req := compute.UpdateRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
|
Name: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("name") {
|
if desc, ok := d.GetOk("description"); ok {
|
||||||
req.Name = d.Get("name").(string)
|
req.Description = desc.(string)
|
||||||
}
|
|
||||||
if d.HasChange("description") {
|
|
||||||
req.Description = d.Get("description").(string)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
||||||
@@ -958,11 +853,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
DiskName: diskConv["disk_name"].(string),
|
DiskName: diskConv["disk_name"].(string),
|
||||||
Size: uint64(diskConv["size"].(int)),
|
Size: uint64(diskConv["size"].(int)),
|
||||||
|
SepID: uint64(diskConv["sep_id"].(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if diskConv["sep_id"].(int) != 0 {
|
|
||||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
|
||||||
}
|
|
||||||
if diskConv["disk_type"].(string) != "" {
|
if diskConv["disk_type"].(string) != "" {
|
||||||
req.DiskType = diskConv["disk_type"].(string)
|
req.DiskType = diskConv["disk_type"].(string)
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1303,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
if d.HasChange("pin_to_stack") {
|
if d.HasChange("pin_to_stack") {
|
||||||
oldPin, newPin := d.GetChange("pin_to_stack")
|
oldPin, newPin := d.GetChange("pin_to_stack")
|
||||||
if !newPin.(bool) {
|
if oldPin.(bool) == true && newPin.(bool) == false {
|
||||||
req := compute.UnpinFromStackRequest{
|
req := compute.UnpinFromStackRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
@@ -1420,7 +1313,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !oldPin.(bool) {
|
if oldPin.(bool) == false && newPin.(bool) == true {
|
||||||
req := compute.PinToStackRequest{
|
req := compute.PinToStackRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
@@ -1434,7 +1327,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
if d.HasChange("pause") {
|
if d.HasChange("pause") {
|
||||||
oldPause, newPause := d.GetChange("pause")
|
oldPause, newPause := d.GetChange("pause")
|
||||||
if !newPause.(bool) {
|
if oldPause.(bool) == true && newPause.(bool) == false {
|
||||||
req := compute.ResumeRequest{
|
req := compute.ResumeRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
@@ -1443,7 +1336,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !oldPause.(bool) {
|
if oldPause.(bool) == false && newPause.(bool) == true {
|
||||||
req := compute.PauseRequest{
|
req := compute.PauseRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
@@ -1456,8 +1349,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("reset") {
|
if d.HasChange("reset") {
|
||||||
_, newReset := d.GetChange("reset")
|
oldReset, newReset := d.GetChange("reset")
|
||||||
if newReset.(bool) {
|
if oldReset.(bool) == false && newReset.(bool) == true {
|
||||||
req := compute.ResetRequest{
|
req := compute.ResetRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
@@ -1537,8 +1430,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||||
// between Compute resource and Compute data source schemas
|
// between Compute resource and Compute data source schemas
|
||||||
|
defer resourceComputeRead(ctx, d, m)
|
||||||
return append(warnings.Get(), resourceComputeRead(ctx, d, m)...)
|
return warnings.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func isResizeDisk(els []interface{}, el interface{}) bool {
|
func isResizeDisk(els []interface{}, el interface{}) bool {
|
||||||
@@ -1611,8 +1504,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1662,6 +1553,7 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
"permanently": {
|
"permanently": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
Description: "Disk deletion status",
|
Description: "Disk deletion status",
|
||||||
},
|
},
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
@@ -2036,12 +1928,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
"restore": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
"auto_start": {
|
"auto_start": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -2054,12 +1940,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "Flag for redeploy compute",
|
Description: "Flag for redeploy compute",
|
||||||
},
|
},
|
||||||
"force_resize": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Flag for resize compute",
|
|
||||||
},
|
|
||||||
"data_disks": {
|
"data_disks": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -2198,10 +2078,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"need_reboot": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"natable_vins_id": {
|
"natable_vins_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -34,17 +34,18 @@ package kvmvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func matchComputes(computeList *compute.ListComputes) *compute.ListComputes {
|
func matchComputes(computeList *compute.ListComputes) *compute.ListComputes {
|
||||||
matched, _ := regexp.Compile(`[a-zA-Z]+\\d+-[a-zA-Z]+\\d+-[a-zA-Z]+\\d+`)
|
matched, _ := regexp.Compile("[a-zA-Z]+\\d+-[a-zA-Z]+\\d+-[a-zA-Z]+\\d+")
|
||||||
result := computeList.FilterFunc(func(ic compute.ItemCompute) bool {
|
result := computeList.FilterFunc(func(ic compute.ItemCompute) bool {
|
||||||
res := matched.Match([]byte(ic.Name))
|
res := matched.Match([]byte(ic.Name))
|
||||||
return !res
|
return !res
|
||||||
@@ -175,6 +176,17 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
|
|
||||||
old_set, new_set := d.GetChange("network")
|
old_set, new_set := d.GetChange("network")
|
||||||
|
|
||||||
|
req := compute.StopRequest{
|
||||||
|
ComputeID: computeID,
|
||||||
|
Force: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityComputeNetworksConfigure: stopping compute %d", computeID)
|
||||||
|
_, err := c.CloudAPI().Compute().Stop(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
apiErrCount := 0
|
apiErrCount := 0
|
||||||
var lastSavedError error
|
var lastSavedError error
|
||||||
|
|
||||||
@@ -234,17 +246,6 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
needStart:= false
|
|
||||||
|
|
||||||
if d.Get("network").(*schema.Set).Len() == 1 || old_set.(*schema.Set).Len() < 1 {
|
|
||||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
if err := utilityComputeStop(ctx, computeId, m); err != nil {
|
|
||||||
apiErrCount++
|
|
||||||
lastSavedError = err
|
|
||||||
}
|
|
||||||
needStart = true
|
|
||||||
}
|
|
||||||
|
|
||||||
attach_set := new_set.(*schema.Set).Difference(old_set.(*schema.Set))
|
attach_set := new_set.(*schema.Set).Difference(old_set.(*schema.Set))
|
||||||
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", attach_set.Len(), d.Id())
|
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", attach_set.Len(), d.Id())
|
||||||
for _, runner := range attach_set.List() {
|
for _, runner := range attach_set.List() {
|
||||||
@@ -269,12 +270,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if needStart {
|
startReq := compute.StartRequest{ComputeID: computeID}
|
||||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
|
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
|
||||||
apiErrCount+= numErr
|
_, err = c.CloudAPI().Compute().Start(ctx, startReq)
|
||||||
lastSavedError = err
|
if err != nil {
|
||||||
}
|
apiErrCount++
|
||||||
|
lastSavedError = err
|
||||||
}
|
}
|
||||||
|
|
||||||
if apiErrCount > 0 {
|
if apiErrCount > 0 {
|
||||||
@@ -300,30 +302,3 @@ func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
return *computeRecord, nil
|
return *computeRecord, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) error {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := compute.StopRequest{
|
|
||||||
ComputeID: computeID,
|
|
||||||
Force: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityComputeNetworksConfigure: stopping compute %d", computeID)
|
|
||||||
_, err := c.CloudAPI().Compute().Stop(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
startReq := compute.StartRequest{ComputeID: computeID}
|
|
||||||
|
|
||||||
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
|
|
||||||
_, err := c.CloudAPI().Compute().Start(ctx, startReq)
|
|
||||||
if err != nil {
|
|
||||||
return 1, err
|
|
||||||
}
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lb, err := utilityLBCheckPresence(ctx, d, m)
|
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|||||||
@@ -79,12 +79,6 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["safe"] = &schema.Schema{
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Default: true,
|
|
||||||
Optional: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
sch["config_reset"] = &schema.Schema{
|
sch["config_reset"] = &schema.Schema{
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -99,6 +93,7 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
sch["permanently"] = &schema.Schema{
|
sch["permanently"] = &schema.Schema{
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -95,16 +94,21 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
|
|
||||||
lbId, err := c.CloudAPI().LB().Create(ctx, req)
|
lbId, err := c.CloudAPI().LB().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(lbId, 10))
|
lbIdParsed := strconv.Itoa(int(lbId))
|
||||||
|
|
||||||
|
d.SetId(lbIdParsed)
|
||||||
d.Set("lb_id", lbId)
|
d.Set("lb_id", lbId)
|
||||||
|
|
||||||
w := dc.Warnings{}
|
_, err = utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
|
lbId := uint64(d.Get("lb_id").(int))
|
||||||
req := lb.DisableEnableRequest{
|
req := lb.DisableEnableRequest{
|
||||||
LBID: lbId,
|
LBID: lbId,
|
||||||
}
|
}
|
||||||
@@ -112,33 +116,17 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
if enable.(bool) {
|
if enable.(bool) {
|
||||||
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
return diag.FromErr(err)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
|
||||||
if start.(bool) {
|
|
||||||
req := lb.StartRequest{LBID: lbId}
|
|
||||||
_, err := c.CloudAPI().LB().Start(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
w.Add(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
req := lb.StopRequest{LBID: lbId}
|
|
||||||
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
w.Add(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return append(w.Get(), resourceLBRead(ctx, d, m)...)
|
return resourceLBRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -205,17 +193,21 @@ func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBDelete")
|
log.Debugf("resourceLBDelete")
|
||||||
|
|
||||||
|
_, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
req := lb.DeleteRequest{
|
req := lb.DeleteRequest{
|
||||||
LBID: lbId,
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
req.Permanently = permanently.(bool)
|
req.Permanently = permanently.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Delete(ctx, req)
|
_, err = c.CloudAPI().LB().Delete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -271,47 +263,19 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
case status.Created:
|
case status.Created:
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
if restore, ok := d.GetOk("restore"); ok && restore.(bool) {
|
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
restoreReq := lb.RestoreRequest{LBID: lbRec.ID}
|
restoreReq := lb.RestoreRequest{LBID: lbId}
|
||||||
|
enableReq := lb.DisableEnableRequest{LBID: lbId}
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
_, err = c.CloudAPI().LB().Enable(ctx, enableReq)
|
||||||
req := lb.DisableEnableRequest{
|
if err != nil {
|
||||||
LBID: lbRec.ID,
|
return diag.FromErr(err)
|
||||||
}
|
|
||||||
|
|
||||||
if enable.(bool) {
|
|
||||||
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
|
||||||
if start.(bool) {
|
|
||||||
req := lb.StartRequest{LBID: lbRec.ID}
|
|
||||||
_, err := c.CloudAPI().LB().Start(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
req := lb.StopRequest{LBID: lbRec.ID}
|
|
||||||
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged = true
|
hasChanged = true
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
||||||
@@ -338,7 +302,7 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
if d.HasChange("ha_mode") {
|
if d.HasChange("ha_mode") {
|
||||||
hamode := d.Get("ha_mode").(bool)
|
hamode := d.Get("ha_mode").(bool)
|
||||||
if hamode {
|
if hamode {
|
||||||
req := lb.HighlyAvailableRequest{
|
req:= lb.HighlyAvailableRequest {
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
_, err := c.CloudAPI().LB().HighlyAvailable(ctx, req)
|
_, err := c.CloudAPI().LB().HighlyAvailable(ctx, req)
|
||||||
@@ -363,6 +327,7 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,9 +367,6 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
req := lb.RestartRequest{
|
req := lb.RestartRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
if safe, ok:= d.GetOk("safe"); ok {
|
|
||||||
req.Safe = safe.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Restart(ctx, req)
|
_, err := c.CloudAPI().LB().Restart(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendCreate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendCreate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +101,6 @@ func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +128,6 @@ func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
_, err := utilityLBBackendCheckPresence(ctx, d, m)
|
_, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +139,6 @@ func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendDelete(ctx, req)
|
_, err = c.CloudAPI().LB().BackendDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +195,6 @@ func resourceLBBackendUpdate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerAdd(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerAdd(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +105,6 @@ func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +133,6 @@ func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
_, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
_, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +145,6 @@ func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@@ -162,7 +158,6 @@ func resourceLBBackendServerUpdate(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +203,6 @@ func resourceLBBackendServerUpdate(ctx context.Context, d *schema.ResourceData,
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendCreate(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendCreate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
|
|
||||||
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +100,6 @@ func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
|
|
||||||
_, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
_, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +111,6 @@ func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendDelete(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBind(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBind(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +75,6 @@ func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +103,6 @@ func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
_, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
_, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +115,6 @@ func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBindDelete(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBindDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +152,6 @@ func resourceLBFrontendBindUpdate(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBindUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBindUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} {
|
func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(ll.Data))
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, l := range ll.Data {
|
for _, l := range ll.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ckey": l.CKey,
|
"ckey": l.CKey,
|
||||||
"meta": flattens.FlattenMeta(l.Meta),
|
"meta": flattens.FlattenMeta(l.Meta),
|
||||||
"auth_broker": l.AuthBroker,
|
|
||||||
"flag": l.Flag,
|
"flag": l.Flag,
|
||||||
"gid": l.GID,
|
"gid": l.GID,
|
||||||
"guid": l.GUID,
|
"guid": l.GUID,
|
||||||
@@ -66,7 +65,6 @@ func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{}
|
|||||||
func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
locations, err := utilityLocationsListCheckPresence(ctx, d, m)
|
locations, err := utilityLocationsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,13 +126,6 @@ func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"auth_broker": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"flag": {
|
"flag": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceLocationUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLocationUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
url, err := utilityLocationUrlCheckPresence(ctx, m)
|
url, err := utilityLocationUrlCheckPresence(ctx, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,172 +42,145 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func sepsSchemaMake() map[string]*schema.Schema {
|
||||||
rg, err := utilityResgroupCheckPresence(ctx, d, m)
|
res := map[string]*schema.Schema{
|
||||||
if err != nil {
|
"sep_id": {
|
||||||
d.SetId("") // ensure ID is empty in this case
|
Type: schema.TypeString,
|
||||||
return diag.FromErr(err)
|
Computed: true,
|
||||||
}
|
},
|
||||||
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
|
"data_name": {
|
||||||
flattenRg(d, *rg)
|
Type: schema.TypeString,
|
||||||
return nil
|
Computed: true,
|
||||||
}
|
},
|
||||||
|
"disk_size": {
|
||||||
func DataSourceResgroup() *schema.Resource {
|
Type: schema.TypeFloat,
|
||||||
return &schema.Resource{
|
Computed: true,
|
||||||
SchemaVersion: 1,
|
},
|
||||||
|
"disk_size_max": {
|
||||||
ReadContext: dataSourceResgroupRead,
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceRgSchemaMake(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resourcesSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"current": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeSet,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
Type: schema.TypeMap,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"reserved": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeSet,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"map": {
|
||||||
|
Type: schema.TypeMap,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// func sepsSchemaMake() map[string]*schema.Schema {
|
return res
|
||||||
// res := map[string]*schema.Schema{
|
}
|
||||||
// "sep_id": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "data_name": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size": {
|
|
||||||
// Type: schema.TypeFloat,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size_max": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return res
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func resourcesSchemaMake() map[string]*schema.Schema {
|
|
||||||
// res := map[string]*schema.Schema{
|
|
||||||
// "current": {
|
|
||||||
// Type: schema.TypeList,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Resource{
|
|
||||||
// Schema: map[string]*schema.Schema{
|
|
||||||
// "cpu": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size": {
|
|
||||||
// Type: schema.TypeFloat,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size_max": {
|
|
||||||
// Type: schema.TypeFloat,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "extips": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "exttraffic": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "gpu": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "ram": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "seps": {
|
|
||||||
// Type: schema.TypeSet,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Resource{
|
|
||||||
// Schema: map[string]*schema.Schema{
|
|
||||||
// "sep_id": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "map": {
|
|
||||||
// Type: schema.TypeMap,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Schema{
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// "reserved": {
|
|
||||||
// Type: schema.TypeList,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Resource{
|
|
||||||
// Schema: map[string]*schema.Schema{
|
|
||||||
// "cpu": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size": {
|
|
||||||
// Type: schema.TypeFloat,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "disk_size_max": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "extips": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "exttraffic": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "gpu": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "ram": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "seps": {
|
|
||||||
// Type: schema.TypeSet,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Resource{
|
|
||||||
// Schema: map[string]*schema.Schema{
|
|
||||||
// "sep_id": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// },
|
|
||||||
// "map": {
|
|
||||||
// Type: schema.TypeMap,
|
|
||||||
// Computed: true,
|
|
||||||
// Elem: &schema.Schema{
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return res
|
|
||||||
// }
|
|
||||||
|
|
||||||
func aclSchemaMake() map[string]*schema.Schema {
|
func aclSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
@@ -419,4 +392,28 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dataSourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
rg, err := utilityDataResgroupCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("") // ensure ID is empty in this case
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
|
||||||
|
flattenRg(d, *rg)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceResgroup() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceResgroupRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceRgSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceRgAffinityGroupComputesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceRgAffinityGroupComputesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
rgComputes, err := utilityRgAffinityGroupComputesCheckPresence(ctx, d, m)
|
rgComputes, err := utilityRgAffinityGroupComputesCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +64,7 @@ func dataSourceRgAffinityGroupComputesSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "Affinity group label",
|
Description: "Affinity group label",
|
||||||
},
|
},
|
||||||
|
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user