Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2453a32d01 | ||
|
|
0602a4b693 | ||
|
|
28b60de115 | ||
|
|
b705ce4aab | ||
|
|
83ca627cea | ||
|
|
739289fbb8 | ||
|
|
c89574c3e6 | ||
|
|
a1e61674c8 | ||
|
|
cb9ff26bb0 | ||
|
|
6932f9d305 | ||
|
|
712f8edf9e | ||
|
|
805ffe1f29 | ||
|
|
bf8d3fb437 | ||
| d7a7eb9cb3 | |||
|
|
b60f32c570 | ||
| 272e385318 | |||
| f731cf246f | |||
| 6365f63fc1 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,4 +2,6 @@ decort/vendor/
|
||||
examples/
|
||||
url_scrapping/
|
||||
terraform-provider-decort*
|
||||
.vscode/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,5 +1,8 @@
|
||||
## Version 4.2.2
|
||||
## Version 4.4.2
|
||||
|
||||
## Bug Fixes
|
||||
- Fixed inability of decort_lb_backend_server resource deletion;
|
||||
- Fixed possible panic when adding NAT rules to decort_vins resource;
|
||||
### Feature
|
||||
- Added state upgrade from schema version 2 to schema version 3
|
||||
|
||||
### Bugfix
|
||||
- Fixed incorrect work data_source_static_route
|
||||
- Fixed bug with old field "with_default_vins" in state
|
||||
|
||||
34
Makefile
34
Makefile
@@ -1,30 +1,29 @@
|
||||
TEST?=$$(go list ./... | grep -v 'vendor')
|
||||
HOSTNAME=digitalenergy.online
|
||||
HOSTNAME=basis
|
||||
NAMESPACE=decort
|
||||
NAME=terraform-provider-decort
|
||||
BINDIR = ./bin
|
||||
ZIPDIR = ./zip
|
||||
#BINARY=terraform-provider-${NAME}
|
||||
BINARY=${NAME}.exe
|
||||
BINARY=${NAME}
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=4.2.2
|
||||
#OS_ARCH=darwin_amd64
|
||||
OS_ARCH=windows_amd64
|
||||
#OS_ARCH=linux_amd64
|
||||
VERSION=4.4.2
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES= ${BINARY}_${VERSION}_darwin_amd64\
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
${BINARY}_${VERSION}_darwin_arm64\
|
||||
${BINARY}_${VERSION}_freebsd_386\
|
||||
${BINARY}_${VERSION}_freebsd_amd64\
|
||||
${BINARY}_${VERSION}_freebsd_arm\
|
||||
${BINARY}_${VERSION}_linux_386\
|
||||
${BINARY}_${VERSION}_linux_amd64\
|
||||
${BINARY}_${VERSION}_linux_arm\
|
||||
${BINARY}_${VERSION}_linux_arm64\
|
||||
${BINARY}_${VERSION}_openbsd_386\
|
||||
${BINARY}_${VERSION}_openbsd_amd64\
|
||||
${BINARY}_${VERSION}_solaris_amd64\
|
||||
${BINARY}_${VERSION}_windows_386 \
|
||||
${BINARY}_${VERSION}_windows_amd64\
|
||||
${BINARY}_${VERSION}_windows_386.exe\
|
||||
${BINARY}_${VERSION}_windows_amd64.exe\
|
||||
|
||||
BINS = $(addprefix bin/, $(FILES))
|
||||
|
||||
@@ -50,6 +49,7 @@ release: $(FILES)
|
||||
|
||||
$(FILES) : $(BINDIR) $(ZIPDIR) $(BINS)
|
||||
zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@
|
||||
zip -rj $(ZIPDIR)/$@.zip scripts/install.bat scripts/install.sh
|
||||
|
||||
$(BINDIR):
|
||||
mkdir $@
|
||||
@@ -59,25 +59,27 @@ $(ZIPDIR):
|
||||
|
||||
$(BINS):
|
||||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 $(MAINPATH)
|
||||
GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64 $(MAINPATH)
|
||||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 $(MAINPATH)
|
||||
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 $(MAINPATH)
|
||||
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm $(MAINPATH)
|
||||
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 $(MAINPATH)
|
||||
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 $(MAINPATH)
|
||||
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm $(MAINPATH)
|
||||
GOOS=linux GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_linux_arm64 ${MAINPATH}
|
||||
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 $(MAINPATH)
|
||||
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(MAINPATH)
|
||||
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 $(MAINPATH)
|
||||
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 $(MAINPATH)
|
||||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 $(MAINPATH)
|
||||
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386.exe $(MAINPATH)
|
||||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64.exe $(MAINPATH)
|
||||
|
||||
install: build
|
||||
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
||||
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
||||
|
||||
test:
|
||||
go test -i $(TEST) || exit 1
|
||||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
||||
test:
|
||||
go test -i $(TEST) || exit 1
|
||||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
||||
|
||||
testacc:
|
||||
testacc:
|
||||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
||||
|
||||
180
README.md
180
README.md
@@ -6,7 +6,9 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
||||
|
||||
| Версия DECORT API | Версия провайдера Terraform |
|
||||
| ------ | ------ |
|
||||
| 3.8.6 | 4.x.x |
|
||||
| 3.8.8 | 4.4.x |
|
||||
| 3.8.7 | 4.3.x |
|
||||
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
||||
| 3.8.5 | 3.4.x |
|
||||
| 3.8.0 - 3.8.4 | 3.3.1 |
|
||||
| 3.7.x | rc-1.25 |
|
||||
@@ -28,14 +30,13 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
||||
- Работа с disks,
|
||||
- Работа с k8s,
|
||||
- Работа с image,
|
||||
- Работа с flipgroups,
|
||||
- Работа с stacks,
|
||||
- Работа с reource groups,
|
||||
- Работа с VINS,
|
||||
- Работа с pfw,
|
||||
- Работа с accounts,
|
||||
- Работа с snapshots,
|
||||
- Работа с pcidevice,
|
||||
- Работа с sep,
|
||||
- Работа с vgpu,
|
||||
- Работа с bservice,
|
||||
- Работа с extnets,
|
||||
- Работа с locations,
|
||||
@@ -43,99 +44,125 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
||||
|
||||
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
|
||||
## Начало
|
||||
|
||||
Старт возможен по двум путям:
|
||||
|
||||
1. Установка через собранные пакеты.
|
||||
2. Ручная установка.
|
||||
|
||||
### Установка через собранные пакеты.
|
||||
|
||||
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
||||
## Установка
|
||||
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
||||
Чтобы выполнить установку, необходимо:
|
||||
1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
|
||||
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
|
||||
3. Скачать архив.
|
||||
4. Распаковать архив.
|
||||
5. Выполнить скрипт установщика, `install.sh` или `install.bat` для Windows.<br/>
|
||||
*Для запуска `install.sh` не забудьте изменить права доступа к файлу*
|
||||
```bash
|
||||
chmod u+x install.sh
|
||||
```
|
||||
6. Дождаться сообщения об успешной установке. Установщик выведет актуальный блок конфигурации провайдера, скопируйте его
|
||||
```bash
|
||||
DECORT provider version 4.3.0 has been successfully installed
|
||||
|
||||
Copy this provider configuration to main.tf file:
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "4.3.0"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
7. После этого, создайте файл `main.tf` в рабочей директории, которая может находится в любом удобном для пользователя месте.
|
||||
В данном примере, рабочая директория с файлом main.tf находится по пути:
|
||||
```bash
|
||||
~/work/tfdir/main.tf
|
||||
```
|
||||
8. Вставьте в `main.tf` блок конфигурации провайдера, который был выведен на экран установщиком:
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "4.3.0"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
9. Добавьте в файл блок с инициализацией провайдера.
|
||||
```terraform
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
authenticator = "oauth2"
|
||||
controller_url = "https://mr4.digitalenergy.online"
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
```
|
||||
|
||||
3. Выполните команду
|
||||
|
||||
```
|
||||
10. В консоли выполните команду
|
||||
```bash
|
||||
terraform init
|
||||
```
|
||||
|
||||
Провайдер автоматически будет установлен на ваш компьютер из terraform registry.
|
||||
|
||||
### Ручная установка
|
||||
|
||||
1. Скачайте и установите Go по ссылке: https://go.dev/dl/
|
||||
2. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||
3. Склонируйте репозиторий с провайдером, выполнив команду:
|
||||
|
||||
```bash
|
||||
git clone https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
```
|
||||
|
||||
4. Перейдите в скачанную папку с провайдером и выполните команду
|
||||
|
||||
```bash
|
||||
go build -o terraform-provider-decort
|
||||
```
|
||||
|
||||
Если вы знаете как устроен _makefile_, то можно изменить в файле `Makefile` параметры под вашу ОС и выполнить команду
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
5. Полученный файл необходимо поместить:
|
||||
Linux:
|
||||
11. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
|
||||
|
||||
## Установка из релизов
|
||||
Terraform провайдер DECORT имеет скомпилированные релизные версии, которые расположены по адресу: [Релизы](https://repository.basistech.ru/BASIS/terraform-provider-decort/releases).
|
||||
Чтобы выполнить установку из релиза, необходимо:
|
||||
1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
|
||||
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
|
||||
3. Скачать архив.
|
||||
4. Распаковать архив.
|
||||
5. Полученный файл (в директории `bin/`) необходимо поместить:
|
||||
Linux:
|
||||
```bash
|
||||
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
|
||||
```
|
||||
|
||||
Windows:
|
||||
|
||||
```powershell
|
||||
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
|
||||
```
|
||||
|
||||
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
|
||||
Где:
|
||||
|
||||
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online
|
||||
- namespace - пространство имен хоста, например decort
|
||||
- host_name - имя хоста, держателя провайдера, например, basis
|
||||
- namespace - пространство имен хоста, например decort
|
||||
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
||||
- version - версия провайдера, например 1.2
|
||||
- target - версия ОС, например windows_amd64
|
||||
- version - версия провайдера, например 4.3.0
|
||||
- target - архитектура операционной системы, например windows_amd64
|
||||
|
||||
6. После этого, создайте файл `main.tf`.
|
||||
7. Добавьте в него следующий блок
|
||||
В примере ниже используется путь до провайдера на машине с ОС Linux:
|
||||
|
||||
```bash
|
||||
~/.terraform.d/plugins/basis/decort/decort/4.3.0/linux_amd64/tf-provider
|
||||
^ ^ ^ ^ ^ ^
|
||||
host_name | | | | | |
|
||||
| | | | |
|
||||
namespace | | | | |
|
||||
| | | |
|
||||
type | | | |
|
||||
| | |
|
||||
version | | |
|
||||
| |
|
||||
target | |
|
||||
|
|
||||
исполняемый файл |
|
||||
```
|
||||
|
||||
6. После этого, создайте файл `main.tf` в рабочей директории, которая может находится в любом удобном для пользователя месте.
|
||||
В данном примере, рабочая директория с файлом main.tf находится по пути:
|
||||
```bash
|
||||
~/work/tfdir/main.tf
|
||||
```
|
||||
7. Добавьте в `main.tf` следующий блок
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.2"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "4.3.0"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
В поле `version` указывается версия провайдера.
|
||||
Обязательный параметр
|
||||
Тип поля - строка
|
||||
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
|
||||
В поле `version` указывается версия провайдера.
|
||||
<br/>
|
||||
**ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
|
||||
|
||||
В поле `source` помещается путь до репозитория с версией вида:
|
||||
|
||||
@@ -143,17 +170,24 @@ terraform {
|
||||
${host_name}/${namespace}/${type}
|
||||
```
|
||||
|
||||
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
||||
**ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
|
||||
|
||||
8. В консоле выполнить команду
|
||||
8. Добавьте в файл блок с инициализацией провайдера.
|
||||
```terraform
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
controller_url = "https://mr4.digitalenergy.online"
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
```
|
||||
|
||||
9. В консоли выполните команду
|
||||
```bash
|
||||
terraform init
|
||||
```
|
||||
|
||||
9. Если все прошло хорошо - ошибок не будет.
|
||||
|
||||
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
||||
10. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
|
||||
|
||||
## Примеры работы
|
||||
|
||||
@@ -162,8 +196,4 @@ terraform init
|
||||
- На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
- В папке `samples`
|
||||
|
||||
Схемы к terraform'у доступны:
|
||||
|
||||
- В папке `docs`
|
||||
|
||||
Хорошей работы!
|
||||
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
15
go.mod
15
go.mod
@@ -8,8 +8,8 @@ require (
|
||||
github.com/hashicorp/terraform-plugin-docs v0.13.0
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
golang.org/x/net v0.5.0
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.6
|
||||
golang.org/x/net v0.15.0
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -21,9 +21,10 @@ require (
|
||||
github.com/armon/go-radix v1.0.0 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.2 // indirect
|
||||
github.com/go-playground/validator/v10 v10.15.4 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
@@ -48,7 +49,7 @@ require (
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/huandu/xstrings v1.4.0 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mitchellh/cli v1.1.5 // indirect
|
||||
@@ -66,9 +67,9 @@ require (
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
|
||||
github.com/vmihailenco/tagparser v0.1.2 // indirect
|
||||
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
golang.org/x/crypto v0.13.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
|
||||
google.golang.org/grpc v1.51.0 // indirect
|
||||
|
||||
39
go.sum
39
go.sum
@@ -39,6 +39,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||
@@ -53,8 +55,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
|
||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
||||
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
|
||||
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
@@ -152,8 +154,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
@@ -191,7 +193,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
|
||||
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
|
||||
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
|
||||
@@ -208,14 +210,19 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
@@ -242,8 +249,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -258,8 +265,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -286,8 +293,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
@@ -297,8 +304,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
@@ -332,5 +339,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.6 h1:kUKBLbRGbhDQlqMvPvfdCarrXSbLmaN+YlB0cMlvyBM=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.6/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5 h1:37OLNiSgF3SXjj0ZMRikVrBiNlNdS9NY8QxD9YFfHBY=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package constants
|
||||
|
||||
//CloudApi - a part of url for cloudapi
|
||||
const CloudApi = "/restmachine/cloudapi"
|
||||
|
||||
//CloudBroker - a part of url for cloudbroker
|
||||
const CloudBroker = "/restmachine/cloudbroker"
|
||||
@@ -22,7 +22,6 @@ package controller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -30,7 +29,6 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
// "time"
|
||||
|
||||
@@ -373,82 +371,3 @@ func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
||||
client, _ := config.caller.(*decort.DecortClient)
|
||||
return client.CloudBroker()
|
||||
}
|
||||
|
||||
func (config *ControllerCfg) DecortAPICall(ctx context.Context, method string, api_name string, url_values *url.Values) (json_resp string, err error) { //nolint:unparam
|
||||
// This is a convenience wrapper around standard HTTP request methods that is aware of the
|
||||
// authorization mode for which the provider was initialized and compiles request accordingly.
|
||||
|
||||
if config.cc_client == nil {
|
||||
// this should never happen if ClientConfig was properly called prior to decortAPICall
|
||||
return "", fmt.Errorf("decortAPICall method called with unconfigured DECORT cloud controller HTTP client.")
|
||||
}
|
||||
|
||||
// Example: to create api_params, one would generally do the following:
|
||||
//
|
||||
// data := []byte(`{"machineId": "2638"}`)
|
||||
// api_params := bytes.NewBuffer(data))
|
||||
//
|
||||
// Or:
|
||||
//
|
||||
// params := url.Values{}
|
||||
// params.Add("machineId", "2638")
|
||||
// params.Add("username", "u")
|
||||
// params.Add("password", "b")
|
||||
// req, _ := http.NewRequest(method, url, strings.NewReader(params.Encode()))
|
||||
//
|
||||
|
||||
if config.auth_mode_code == MODE_UNDEF {
|
||||
return "", fmt.Errorf("decortAPICall method called for unknown authorization mode.")
|
||||
}
|
||||
|
||||
if config.auth_mode_code == MODE_LEGACY {
|
||||
url_values.Add("authkey", config.legacy_sid)
|
||||
}
|
||||
params_str := url_values.Encode()
|
||||
|
||||
req, err := http.NewRequest(method, config.controller_url+api_name, strings.NewReader(params_str))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
if config.auth_mode_code == MODE_OAUTH2 || config.auth_mode_code == MODE_JWT {
|
||||
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
|
||||
}
|
||||
|
||||
var resp *http.Response
|
||||
var body []byte
|
||||
for i := 0; i < 5; i++ {
|
||||
resp, err = config.cc_client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
body, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resp.Body.Close()
|
||||
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
return string(body), nil
|
||||
} else {
|
||||
if resp.StatusCode == http.StatusInternalServerError {
|
||||
log.Warnf("got 500, retrying %d/5", i+1)
|
||||
time.Sleep(time.Second * 5)
|
||||
continue
|
||||
}
|
||||
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
|
||||
resp.StatusCode, req.URL, params_str, body)
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
|
||||
resp.StatusCode, req.URL, params_str, body)
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ func UtilityLocationGetDefaultGridID(ctx context.Context, m interface{}) (int, e
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(locList) == 0 {
|
||||
if len(locList.Data) == 0 {
|
||||
DefaultGridID = 0
|
||||
return 0, fmt.Errorf("utilityLocationGetDefaultGridID: retrieved 0 length locations list")
|
||||
}
|
||||
|
||||
DefaultGridID = int(locList[0].GID)
|
||||
log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList[0].Name)
|
||||
DefaultGridID = int(locList.Data[0].GID)
|
||||
log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList.Data[0].Name)
|
||||
|
||||
return DefaultGridID, nil
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
||||
"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_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_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_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||
@@ -48,80 +50,93 @@ import (
|
||||
|
||||
func newDataSourcesMap() map[string]*schema.Resource {
|
||||
return map[string]*schema.Resource{
|
||||
"decort_account": account.DataSourceAccount(),
|
||||
"decort_resgroup": rg.DataSourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||
"decort_k8s": k8s.DataSourceK8s(),
|
||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||
"decort_vins": vins.DataSourceVins(),
|
||||
"decort_vins_list": vins.DataSourceVinsList(),
|
||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||
"decort_disk": disks.DataSourceDisk(),
|
||||
"decort_disk_list": disks.DataSourceDiskList(),
|
||||
"decort_rg_list": rg.DataSourceRgList(),
|
||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||
"decort_account_list": account.DataSourceAccountList(),
|
||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||
"decort_bservice": bservice.DataSourceBasicService(),
|
||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||
"decort_extnet": extnet.DataSourceExtnet(),
|
||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||
"decort_image_list": image.DataSourceImageList(),
|
||||
"decort_image": image.DataSourceImage(),
|
||||
"decort_lb": lb.DataSourceLB(),
|
||||
"decort_lb_list": lb.DataSourceLBList(),
|
||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||
"decort_account": account.DataSourceAccount(),
|
||||
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||
"decort_resgroup": rg.DataSourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||
"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_list": k8s.DataSourceK8sList(),
|
||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||
"decort_vins": vins.DataSourceVins(),
|
||||
"decort_vins_list": vins.DataSourceVinsList(),
|
||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||
"decort_disk": disks.DataSourceDisk(),
|
||||
"decort_disk_list": disks.DataSourceDiskList(),
|
||||
"decort_rg_list": rg.DataSourceRgList(),
|
||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||
"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_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||
"decort_account_list": account.DataSourceAccountList(),
|
||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||
"decort_bservice": bservice.DataSourceBasicService(),
|
||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||
"decort_extnet": extnet.DataSourceExtnet(),
|
||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||
"decort_image_list": image.DataSourceImageList(),
|
||||
"decort_image": image.DataSourceImage(),
|
||||
"decort_lb": lb.DataSourceLB(),
|
||||
"decort_lb_list": lb.DataSourceLBList(),
|
||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||
"decort_stack": stack.DataSourceStack(),
|
||||
"decort_stack_list": stack.DataSourceStackList(),
|
||||
|
||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||
@@ -132,6 +147,9 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
||||
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
||||
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
||||
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
||||
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||
"decort_cb_image": cb_image.DataSourceImage(),
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
|
||||
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_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||
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_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||
@@ -71,8 +72,10 @@ func newResourcesMap() map[string]*schema.Resource {
|
||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
||||
|
||||
"decort_cb_account": cb_account.ResourceAccount(),
|
||||
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||
"decort_cb_image": cb_image.ResourceImage(),
|
||||
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
// TODO: resources (additional ds / additional request inside body (?))
|
||||
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -268,13 +269,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"resources": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: resourcesSchemaMake(),
|
||||
},
|
||||
},
|
||||
// "resources": {
|
||||
// Type: schema.TypeList,
|
||||
// Computed: true,
|
||||
// Elem: &schema.Resource{
|
||||
// Schema: resourcesSchemaMake(),
|
||||
// },
|
||||
// },
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountComputesList(acl account.ListComputes) []map[string]interface{} {
|
||||
func flattenAccountComputesList(acl *account.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, acc := range acl {
|
||||
for _, acc := range acl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": acc.AccountID,
|
||||
"account_name": acc.AccountName,
|
||||
@@ -82,6 +82,7 @@ func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceDa
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountComputesList(accountComputesList))
|
||||
d.Set("entry_count", accountComputesList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -93,6 +94,56 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by compute ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by compute name",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by RG name",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by tech. status",
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by IP address",
|
||||
},
|
||||
"extnet_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by extnet name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by extnet ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -182,6 +233,10 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -50,10 +50,17 @@ func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceDat
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountList(accountDeletedList))
|
||||
d.Set("entry_count", accountDeletedList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
temp := dataSourceAccountListSchemaMake()
|
||||
delete(temp, "status")
|
||||
return temp
|
||||
}
|
||||
|
||||
func DataSourceAccountDeletedList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
@@ -65,6 +72,6 @@ func DataSourceAccountDeletedList() *schema.Resource {
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAccountListSchemaMake(),
|
||||
Schema: dataSourceAccountDeletedListSchemaMake(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountDisksList(adl account.ListDisks) []map[string]interface{} {
|
||||
func flattenAccountDisksList(adl *account.ListDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ad := range adl {
|
||||
for _, ad := range adl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"disk_id": ad.ID,
|
||||
"disk_name": ad.Name,
|
||||
@@ -68,6 +68,7 @@ func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountDisksList(accountDisksList))
|
||||
d.Set("entry_count", accountDisksList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -79,6 +80,36 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by disk ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by disk name",
|
||||
},
|
||||
"disk_max_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by disk max size",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by disk type",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -116,6 +147,10 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountFlipGroupsList(afgl account.ListFLIPGroups) []map[string]interface{} {
|
||||
func flattenAccountFlipGroupsList(afgl *account.ListFLIPGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, afg := range afgl {
|
||||
for _, afg := range afgl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": afg.AccountID,
|
||||
"client_type": afg.ClientType,
|
||||
@@ -83,6 +83,7 @@ func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.Resource
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
||||
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -94,6 +95,46 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"vins_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by extnet ID",
|
||||
},
|
||||
"by_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by IP",
|
||||
},
|
||||
"flipgroup_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by flipgroup ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -187,6 +228,10 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
flattenResourceConsumption(d, accountResourceConsumptionRec)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceResourceLimitsSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"cu_c": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_d": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_dm": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_i": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_m": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_np": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"gpu_units": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceAccountResourceConsumptionGet() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceAccountResourceConsumptionGetRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAccountResourceConsumptionGetSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountList(al account.ListAccounts) []map[string]interface{} {
|
||||
func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, acc := range al {
|
||||
for _, acc := range al.Data {
|
||||
temp := map[string]interface{}{
|
||||
"acl": flattenRgAcl(acc.ACL),
|
||||
"created_time": acc.CreatedTime,
|
||||
@@ -84,12 +84,33 @@ func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m in
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountList(accountList))
|
||||
d.Set("entry_count", accountList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"acl": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by ACL",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -164,6 +185,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccResourceConsumption(accountResourceConsumptionList))
|
||||
d.Set("entry_count", accountResourceConsumptionList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
|
||||
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.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceAccResourceSchemaMake() map[string]*schema.Schema {
|
||||
res := 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,
|
||||
},
|
||||
"ext_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ext_traffic": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"seps": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceSepsSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceAccountResourceConsumptionList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceAccountResourceConsumptionListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAccountResourceConsumptionListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountRGList(argl account.ListRG) []map[string]interface{} {
|
||||
func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, arg := range argl {
|
||||
for _, arg := range argl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"computes": flattenAccRGComputes(arg.Computes),
|
||||
"resources": flattenAccRGResources(arg.Resources),
|
||||
@@ -125,6 +125,7 @@ func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountRGList(accountRGList))
|
||||
d.Set("entry_count", accountRGList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -136,6 +137,41 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"vm_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by VM ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -311,6 +347,10 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountTemplatesList(atl account.ListTemplates) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, at := range atl {
|
||||
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(atl.Data))
|
||||
for _, at := range atl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"unc_path": at.UNCPath,
|
||||
"account_id": at.AccountID,
|
||||
@@ -72,7 +72,7 @@ func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceD
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
||||
|
||||
d.Set("entry_count", accountTemplatesList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -83,6 +83,35 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"include_deleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by image id",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by type",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -132,6 +161,10 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenAccountVinsList(avl account.ListVINS) []map[string]interface{} {
|
||||
func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, av := range avl {
|
||||
for _, av := range avl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": av.AccountID,
|
||||
"account_name": av.AccountName,
|
||||
@@ -79,6 +79,7 @@ func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountVinsList(accountVinsList))
|
||||
d.Set("entry_count", accountVinsList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -90,6 +91,36 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the account",
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"ext_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by external IP",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -167,6 +198,10 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
||||
d.Set("dc_location", acc.DCLocation)
|
||||
d.Set("resources", flattenAccResources(acc.Resources))
|
||||
// d.Set("resources", flattenAccResources(acc.Resources))
|
||||
d.Set("ckey", acc.CKey)
|
||||
d.Set("acl", flattenAccAcl(acc.ACL))
|
||||
d.Set("company", acc.Company)
|
||||
@@ -21,7 +21,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
||||
d.Set("guid", acc.GUID)
|
||||
d.Set("account_id", acc.ID)
|
||||
d.Set("account_name", acc.Name)
|
||||
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
|
||||
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||
d.Set("send_access_emails", acc.SendAccessEmails)
|
||||
d.Set("status", acc.Status)
|
||||
d.Set("updated_time", acc.UpdatedTime)
|
||||
@@ -79,11 +79,19 @@ func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
|
||||
func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
|
||||
d.Set("account_id", acc.AccountID)
|
||||
d.Set("consumed", flattenAccResource(acc.Consumed))
|
||||
d.Set("reserved", flattenAccResource(acc.Reserved))
|
||||
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||
}
|
||||
|
||||
func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cu_c": rl.CUC,
|
||||
"cu_d": rl.CUD,
|
||||
"cu_dm": rl.CUDM,
|
||||
"cu_i": rl.CUI,
|
||||
"cu_m": rl.CUM,
|
||||
"cu_np": rl.CUNP,
|
||||
@@ -95,15 +103,15 @@ func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{}
|
||||
|
||||
}
|
||||
|
||||
func flattenAccResources(r account.Resources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"current": flattenAccResource(r.Current),
|
||||
"reserved": flattenAccResource(r.Reserved),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
// func flattenAccResources(r account.Resources) []map[string]interface{} {
|
||||
// res := make([]map[string]interface{}, 0)
|
||||
// temp := map[string]interface{}{
|
||||
// "current": flattenAccResource(r.Current),
|
||||
// "reserved": flattenAccResource(r.Reserved),
|
||||
// }
|
||||
// res = append(res, temp)
|
||||
// return res
|
||||
// }
|
||||
|
||||
func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
@@ -124,14 +132,28 @@ func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[stri
|
||||
func flattenAccResource(r account.Resource) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": r.CPU,
|
||||
"disksize": r.DiskSize,
|
||||
"extips": r.ExtIPs,
|
||||
"exttraffic": r.ExtTraffic,
|
||||
"gpu": r.GPU,
|
||||
"ram": r.RAM,
|
||||
"seps": flattenAccountSeps(r.SEPs),
|
||||
"cpu": r.CPU,
|
||||
"disk_size": r.DiskSize,
|
||||
"disk_size_max": r.DiskSizeMax,
|
||||
"ext_ips": r.ExtIPs,
|
||||
"ext_traffic": r.ExtTraffic,
|
||||
"gpu": r.GPU,
|
||||
"ram": r.RAM,
|
||||
"seps": flattenAccountSeps(r.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lrc.Data))
|
||||
for _, rc := range lrc.Data {
|
||||
temp := map[string]interface{}{
|
||||
"consumed": flattenAccResource(rc.Consumed),
|
||||
"reserved": flattenAccResource(rc.Reserved),
|
||||
"account_id": rc.AccountID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -47,135 +47,14 @@ import (
|
||||
)
|
||||
|
||||
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceAccountCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := account.CreateRequest{}
|
||||
|
||||
req.Name = d.Get("account_name").(string)
|
||||
req.Username = d.Get("username").(string)
|
||||
|
||||
if emailaddress, ok := d.GetOk("emailaddress"); ok {
|
||||
req.EmailAddress = emailaddress.(string)
|
||||
}
|
||||
if sendAccessEmails, ok := d.GetOk("send_access_emails"); ok {
|
||||
req.SendAccessEmails = sendAccessEmails.(bool)
|
||||
}
|
||||
|
||||
if resLimits, ok := d.GetOk("resource_limits"); ok {
|
||||
resLimit := resLimits.([]interface{})[0]
|
||||
resLimitConv := resLimit.(map[string]interface{})
|
||||
if resLimitConv["cu_m"] != nil {
|
||||
maxMemCap := int(resLimitConv["cu_m"].(float64))
|
||||
if maxMemCap == 0 {
|
||||
req.MaxMemoryCapacity = -1
|
||||
} else {
|
||||
req.MaxMemoryCapacity = int64(maxMemCap)
|
||||
}
|
||||
}
|
||||
if resLimitConv["cu_d"] != nil {
|
||||
maxDiskCap := int(resLimitConv["cu_d"].(float64))
|
||||
if maxDiskCap == 0 {
|
||||
req.MaxVDiskCapacity = -1
|
||||
} else {
|
||||
req.MaxVDiskCapacity = int64(maxDiskCap)
|
||||
}
|
||||
}
|
||||
if resLimitConv["cu_c"] != nil {
|
||||
maxCPUCap := int(resLimitConv["cu_c"].(float64))
|
||||
if maxCPUCap == 0 {
|
||||
req.MaxCPUCapacity = -1
|
||||
} else {
|
||||
req.MaxCPUCapacity = int64(maxCPUCap)
|
||||
}
|
||||
|
||||
}
|
||||
if resLimitConv["cu_i"] != nil {
|
||||
maxNumPublicIP := int(resLimitConv["cu_i"].(float64))
|
||||
if maxNumPublicIP == 0 {
|
||||
req.MaxNumPublicIP = -1
|
||||
} else {
|
||||
req.MaxNumPublicIP = int64(maxNumPublicIP)
|
||||
}
|
||||
|
||||
}
|
||||
if resLimitConv["cu_np"] != nil {
|
||||
maxNP := int(resLimitConv["cu_np"].(float64))
|
||||
if maxNP == 0 {
|
||||
req.MaxNetworkPeerTransfer = -1
|
||||
} else {
|
||||
req.MaxNetworkPeerTransfer = int64(maxNP)
|
||||
}
|
||||
|
||||
}
|
||||
if resLimitConv["gpu_units"] != nil {
|
||||
gpuUnits := int(resLimitConv["gpu_units"].(float64))
|
||||
if gpuUnits == 0 {
|
||||
req.GPUUnits = -1
|
||||
} else {
|
||||
req.GPUUnits = int64(gpuUnits)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
accountId, err := c.CloudAPI().Account().Create(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(accountId, 10))
|
||||
d.Set("account_id", accountId)
|
||||
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
reqSwitch := account.DisableEnableRequest{
|
||||
AccountID: accountId,
|
||||
}
|
||||
enable := enable.(bool)
|
||||
|
||||
if enable {
|
||||
|
||||
_, err := c.CloudAPI().Account().Enable(ctx, reqSwitch)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
|
||||
} else {
|
||||
|
||||
_, err := c.CloudAPI().Account().Disable(ctx, reqSwitch)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if users, ok := d.GetOk("users"); ok {
|
||||
addedUsers := users.([]interface{})
|
||||
|
||||
if len(addedUsers) > 0 {
|
||||
for _, user := range addedUsers {
|
||||
userConv := user.(map[string]interface{})
|
||||
|
||||
req := account.AddUserRequest{
|
||||
AccountID: accountId,
|
||||
UserID: userConv["user_id"].(string),
|
||||
AccessType: strings.ToUpper(userConv["access_type"].(string)),
|
||||
}
|
||||
_, err := c.CloudAPI().Account().AddUser(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resourceAccountRead(ctx, d, m)
|
||||
return diag.Errorf(
|
||||
"Only users with admin privileges are able to create accounts. Contact your platform administrator.\nUse 'terraform import decort_account.<NAME> <ID>' command to import existing account configuration")
|
||||
}
|
||||
|
||||
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -188,22 +67,23 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
switch acc.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceAccountCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceAccountCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
req := account.RestoreRequest{
|
||||
AccountID: id,
|
||||
}
|
||||
// req := account.RestoreRequest{
|
||||
// AccountID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Disabled:
|
||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||
case status.Confirmed:
|
||||
@@ -263,7 +143,8 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
switch acc.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceAccountCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceAccountCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||
case status.Deleted:
|
||||
@@ -629,13 +510,13 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"resources": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: resourcesSchemaMake(),
|
||||
},
|
||||
},
|
||||
// "resources": {
|
||||
// Type: schema.TypeList,
|
||||
// Computed: true,
|
||||
// Elem: &schema.Resource{
|
||||
// Schema: resourcesSchemaMake(),
|
||||
// },
|
||||
// },
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListComputes, error) {
|
||||
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
@@ -52,6 +52,46 @@ func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.Reso
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||
req.ComputeID = uint64(compute_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if rg_name, ok := d.GetOk("rg_name"); ok {
|
||||
req.RGName = rg_name.(string)
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if ip_address, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ip_address.(string)
|
||||
}
|
||||
|
||||
if extnet_name, ok := d.GetOk("extnet_name"); ok {
|
||||
req.ExtNetName = extnet_name.(string)
|
||||
}
|
||||
|
||||
if extnet_id, ok := d.GetOk("extnet_id"); ok {
|
||||
req.ExtNetID = uint64(extnet_id.(int))
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
|
||||
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,23 +42,29 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListAccounts, error) {
|
||||
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var (
|
||||
pageVal uint64 = 0
|
||||
sizeVal uint64 = 0
|
||||
)
|
||||
|
||||
req := account.ListDeletedRequest{}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
pageVal = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
sizeVal = uint64(size.(int))
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
req := account.ListDeletedRequest{
|
||||
Page: pageVal,
|
||||
Size: sizeVal,
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if acl, ok := d.GetOk("acl"); ok {
|
||||
req.ACL = acl.(string)
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountDeletedListCheckPresence: load")
|
||||
|
||||
@@ -41,7 +41,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListDisks, error) {
|
||||
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
@@ -51,6 +51,30 @@ func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.Resourc
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if disk_id, ok := d.GetOk("disk_id"); ok {
|
||||
req.DiskID = uint64(disk_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||
req.DiskMaxSize = uint64(disk_max_size.(int))
|
||||
}
|
||||
|
||||
if typeVal, ok := d.GetOk("type"); ok {
|
||||
req.Type = typeVal.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListFLIPGroups, error) {
|
||||
func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListFLIPGroups, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
@@ -52,6 +52,38 @@ func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.Re
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if vins_id, ok := d.GetOk("vins_id"); ok {
|
||||
req.VINSID = uint64(vins_id.(int))
|
||||
}
|
||||
|
||||
if vins_name, ok := d.GetOk("vins_name"); ok {
|
||||
req.VINSName = vins_name.(string)
|
||||
}
|
||||
|
||||
if extnet_id, ok := d.GetOk("extnet_id"); ok {
|
||||
req.ExtNetID = uint64(extnet_id.(int))
|
||||
}
|
||||
|
||||
if by_ip, ok := d.GetOk("by_ip"); ok {
|
||||
req.ByIP = by_ip.(string)
|
||||
}
|
||||
|
||||
if flipgroup_id, ok := d.GetOk("flipgroup_id"); ok {
|
||||
req.FLIPGroupID = uint64(flipgroup_id.(int))
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountFlipGroupsListCheckPresence")
|
||||
accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
id := uint64(d.Get("account_id").(int))
|
||||
|
||||
req:= account.GetResourceConsumptionRequest {
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
|
||||
accountResourceConsumptionRec, err := c.CloudAPI().Account().GetResourceConsumption(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountResourceConsumptionRec, nil
|
||||
}
|
||||
@@ -42,23 +42,31 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListAccounts, error) {
|
||||
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var (
|
||||
pageVal uint64 = 0
|
||||
sizeVal uint64 = 0
|
||||
)
|
||||
req := account.ListRequest{}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
pageVal = uint64(page.(int))
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
sizeVal = uint64(size.(int))
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
req := account.ListRequest{
|
||||
Page: pageVal,
|
||||
Size: sizeVal,
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if acl, ok := d.GetOk("acl"); ok {
|
||||
req.ACL = acl.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountListCheckPresence: load account list")
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
log.Debugf("utilityAccountResourceConsumptionListCheckPresence: load")
|
||||
accountResourceConsumptionList, err := c.CloudAPI().Account().ListResourceConsumption(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountResourceConsumptionList, nil
|
||||
}
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListRG, error) {
|
||||
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
@@ -52,6 +52,34 @@ func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceDa
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if vins_id, ok := d.GetOk("vins_id"); ok {
|
||||
req.VINSID = uint64(vins_id.(int))
|
||||
}
|
||||
|
||||
if vm_id, ok := d.GetOk("vm_id"); ok {
|
||||
req.VMID = uint64(vm_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountRGListCheckPresence: load account list")
|
||||
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,16 +42,34 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListTemplates, error) {
|
||||
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
id = uint64(d.Get("account_id").(int))
|
||||
id := uint64(d.Get("account_id").(int))
|
||||
|
||||
req := account.ListTemplatesRequest{
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
||||
req.IncludeDeleted = include_deleted.(bool)
|
||||
}
|
||||
if imageId, ok := d.GetOk("image_id"); ok {
|
||||
req.ImageID = uint64(imageId.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if typeTemplates, ok := d.GetOk("type"); ok {
|
||||
req.Type = typeTemplates.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
||||
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListVINS, error) {
|
||||
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
@@ -52,6 +52,30 @@ func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.Resource
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
if vins_id, ok := d.GetOk("vins_id"); ok {
|
||||
req.VINSID = uint64(vins_id.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if ext_ip, ok := d.GetOk("ext_ip"); ok {
|
||||
req.ExtIP = ext_ip.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
|
||||
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -146,7 +146,7 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"disk_total": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
@@ -185,13 +185,13 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"groups_name": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
// "groups_name": {
|
||||
// Type: schema.TypeList,
|
||||
// Computed: true,
|
||||
// Elem: &schema.Schema{
|
||||
// Type: schema.TypeString,
|
||||
// },
|
||||
// },
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -50,10 +50,24 @@ func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.Resour
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
|
||||
d.Set("entry_count", basicServiceDeletedList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceBasicServiceDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
temp := dataSourceBasicServiceListSchemaMake()
|
||||
|
||||
delete(temp, "by_id")
|
||||
delete(temp, "name")
|
||||
delete(temp, "rg_name")
|
||||
delete(temp, "status")
|
||||
delete(temp, "tech_status")
|
||||
delete(temp, "account_name")
|
||||
|
||||
return temp
|
||||
}
|
||||
|
||||
func DataSourceBasicServiceDeletedList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
@@ -65,6 +79,6 @@ func DataSourceBasicServiceDeletedList() *schema.Resource {
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceBasicServiceListSchemaMake(),
|
||||
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenBasicServiceList(bsl bservice.ListBasicServices) []map[string]interface{} {
|
||||
func flattenBasicServiceList(bsl *bservice.ListBasicServices) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, bs := range bsl {
|
||||
for _, bs := range bsl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": bs.AccountID,
|
||||
"account_name": bs.AccountName,
|
||||
@@ -83,12 +83,43 @@ func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenBasicServiceList(basicServiceList))
|
||||
d.Set("entry_count", basicServiceList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by bservice name",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by resource group name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by tech status",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by account name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -208,6 +239,10 @@ func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.Reco
|
||||
d.Set("rg_name", bsg.RGName)
|
||||
d.Set("role", bsg.Role)
|
||||
d.Set("sep_id", bsg.SEPID)
|
||||
d.Set("sep_pool", bsg.PoolName)
|
||||
d.Set("seq_no", bsg.SeqNo)
|
||||
d.Set("status", bsg.Status)
|
||||
d.Set("tech_status", bsg.TechStatus)
|
||||
|
||||
@@ -77,13 +77,40 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
||||
d.SetId(strconv.FormatUint(serviceId, 10))
|
||||
d.Set("service_id", serviceId)
|
||||
|
||||
service, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
|
||||
log.Debugf("trying to enable bservice %v", serviceId)
|
||||
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||
ServiceID: serviceId,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
if d.Get("start").(bool) && d.Get("enable").(bool) {
|
||||
log.Debugf("trying to start bservice %v", serviceId)
|
||||
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||
ServiceID: serviceId,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceBasicServiceRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceBasicServiceRead")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -104,29 +131,30 @@ func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m int
|
||||
case status.Disabling:
|
||||
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := bservice.RestoreRequest{
|
||||
ServiceID: id,
|
||||
}
|
||||
enableReq := bservice.EnableRequest{
|
||||
ServiceID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := bservice.RestoreRequest{
|
||||
// ServiceID: id,
|
||||
// }
|
||||
// enableReq := bservice.EnableRequest{
|
||||
// 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)
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceBasicServiceCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceBasicServiceCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||
case status.Restoring:
|
||||
@@ -224,7 +252,8 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceBasicServiceCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceBasicServiceCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||
case status.Restoring:
|
||||
@@ -533,7 +562,7 @@ func resourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"disk_total": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
|
||||
@@ -68,6 +68,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
|
||||
req.TimeoutStart = uint64(timeoutStart.(int))
|
||||
}
|
||||
|
||||
///4.4.0
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
req.SEPID = uint64(sepId.(int))
|
||||
}
|
||||
|
||||
if sepPool, ok := d.GetOk("sep_pool"); ok {
|
||||
req.SEPPool = sepPool.(string)
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
req.UserData = cloudInit.(string)
|
||||
}
|
||||
///
|
||||
|
||||
if vinses, ok := d.GetOk("vinses"); ok {
|
||||
res := []uint64{}
|
||||
for _, vins := range vinses.([]interface{}) {
|
||||
@@ -93,6 +107,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
|
||||
d.SetId(strconv.FormatUint(compgroupId, 10))
|
||||
d.Set("compgroup_id", compgroupId)
|
||||
|
||||
serviceId:= uint64(d.Get("service_id").(int))
|
||||
|
||||
if d.Get("start").(bool) {
|
||||
log.Debugf("trying to start bservice group %v", compgroupId)
|
||||
_, err := c.CloudAPI().BService().GroupStart(ctx, bservice.GroupStartRequest{
|
||||
ServiceID: serviceId,
|
||||
CompGroupID: compgroupId,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceBasicServiceGroupRead(ctx, d, m)
|
||||
}
|
||||
|
||||
@@ -362,6 +390,25 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "compute driver like a KVM_X86, KVM_PPC, etc.",
|
||||
},
|
||||
///4.4.0
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "storage endpoint provider ID",
|
||||
},
|
||||
"sep_pool": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "pool to use if sepId is set, can be also empty if needed to be chosen by system",
|
||||
},
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
|
||||
},
|
||||
///
|
||||
"role": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -524,10 +571,6 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"seq_no": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -20,5 +20,5 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
|
||||
rgId := uint64(d.Get("rg_id").(int))
|
||||
|
||||
return len(rgList.FilterByID(rgId)) != 0, nil
|
||||
return len(rgList.FilterByID(rgId).Data) != 0, nil
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityBasicServiceDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListBasicServices, error) {
|
||||
func utilityBasicServiceDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := bservice.ListRequest{}
|
||||
req := bservice.ListDeletedRequest{}
|
||||
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListBasicServices, error) {
|
||||
func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := bservice.ListRequest{}
|
||||
|
||||
@@ -59,6 +59,30 @@ func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.Resourc
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if rg_name, ok := d.GetOk("rg_name"); ok {
|
||||
req.RGName = rg_name.(string)
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
if acc_name, ok := d.GetOk("account_name"); ok {
|
||||
req.AccountName = acc_name.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilityBasicServiceListCheckPresence")
|
||||
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -50,12 +50,43 @@ func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m inter
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenDiskList(diskList))
|
||||
d.Set("entry_count", diskList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by account name",
|
||||
},
|
||||
"disk_max_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by max disk size",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"shared": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Find by shared field",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -66,6 +97,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "type of the disks",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by sep ID",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by pool name",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -434,6 +475,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -49,12 +49,23 @@ func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("types", listTypes)
|
||||
d.Set("types", listTypes.Data)
|
||||
d.Set("entry_count", listTypes.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -63,6 +74,10 @@ func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -38,16 +38,18 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenDiskListTypesDetailed(tld []interface{}) []map[string]interface{} {
|
||||
func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, typeListDetailed := range tld {
|
||||
for _, typeListDetailed := range tld.Data {
|
||||
toMap := typeListDetailed.(map[string]interface{})
|
||||
temp := map[string]interface{}{
|
||||
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
||||
"sep_id": toMap["sepId"].(float64),
|
||||
"sep_name": toMap["sepName"].(string),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -60,6 +62,7 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
||||
toMap := pool.(map[string]interface{})
|
||||
temp := map[string]interface{}{
|
||||
"name": toMap["name"].(string),
|
||||
"system": toMap["system"].(string),
|
||||
"types": toMap["types"].([]interface{}),
|
||||
}
|
||||
res = append(res, temp)
|
||||
@@ -77,11 +80,22 @@ func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.Resource
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
|
||||
d.Set("entry_count", listTypesDetailed.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -97,6 +111,10 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Pool name",
|
||||
},
|
||||
"system": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -113,9 +131,17 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Storage endpoint provider ID to create disk",
|
||||
},
|
||||
"sep_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceDat
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenDiskListUnattached(diskListUnattached))
|
||||
d.Set("entry_count", diskListUnattached.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -71,12 +72,56 @@ func DataSourceDiskListUnattached() *schema.Resource {
|
||||
|
||||
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by account name",
|
||||
},
|
||||
"disk_max_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by max disk size",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "ID of the account the disks belong to",
|
||||
},
|
||||
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by sep ID",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by pool name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "type of the disks",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -401,6 +446,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +43,7 @@ import (
|
||||
)
|
||||
|
||||
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
||||
diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@@ -50,10 +51,424 @@ func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenDiskList(diskList))
|
||||
d.Set("entry_count", diskList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by disk ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by disk name",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by account name",
|
||||
},
|
||||
"disk_max_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by max disk size",
|
||||
},
|
||||
"shared": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Find shared disks",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "ID of the account the disks belong to",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "type of the disks",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "The unique ID of the subscriber-owner of the disk",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "The name of the subscriber '(account') to whom this disk belongs",
|
||||
},
|
||||
"acl": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
// "boot_partition": {
|
||||
// Type: schema.TypeInt,
|
||||
// Computed: true,
|
||||
// Description: "Number of disk partitions",
|
||||
// },
|
||||
"computes": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"compute_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Created time",
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Deleted time",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Description of disk",
|
||||
},
|
||||
"destruction_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Time of final deletion",
|
||||
},
|
||||
"devicename": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the device",
|
||||
},
|
||||
// "disk_path": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// Description: "Disk path",
|
||||
// },
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "ID of the grid (platform)",
|
||||
},
|
||||
// "guid": {
|
||||
// Type: schema.TypeInt,
|
||||
// Computed: true,
|
||||
// Description: "Disk ID on the storage side",
|
||||
// },
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "The unique ID of the subscriber-owner of the disk",
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Image ID",
|
||||
},
|
||||
"images": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "IDs of images using the disk",
|
||||
},
|
||||
"iotune": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"read_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Number of bytes to read per second",
|
||||
},
|
||||
"read_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum number of bytes to read",
|
||||
},
|
||||
"read_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Number of io read operations per second",
|
||||
},
|
||||
"read_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum number of io read operations",
|
||||
},
|
||||
"size_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Size of io operations",
|
||||
},
|
||||
"total_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Total size bytes per second",
|
||||
},
|
||||
"total_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum total size of bytes per second",
|
||||
},
|
||||
"total_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Total number of io operations per second",
|
||||
},
|
||||
"total_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum total number of io operations per second",
|
||||
},
|
||||
"write_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Number of bytes to write per second",
|
||||
},
|
||||
"write_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum number of bytes to write per second",
|
||||
},
|
||||
"write_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Number of write operations per second",
|
||||
},
|
||||
"write_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Maximum number of write operations per second",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
// "iqn": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// Description: "Disk IQN",
|
||||
// },
|
||||
// "login": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// Description: "Login to access the disk",
|
||||
// },
|
||||
"machine_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Machine ID",
|
||||
},
|
||||
"machine_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Machine name",
|
||||
},
|
||||
// "milestones": {
|
||||
// Type: schema.TypeInt,
|
||||
// Computed: true,
|
||||
// Description: "Milestones",
|
||||
// },
|
||||
"disk_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of disk",
|
||||
},
|
||||
"order": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Disk order",
|
||||
},
|
||||
"params": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Disk params",
|
||||
},
|
||||
"parent_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "ID of the parent disk",
|
||||
},
|
||||
// "passwd": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// Description: "Password to access the disk",
|
||||
// },
|
||||
"pci_slot": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "ID of the pci slot to which the disk is connected",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Pool for disk location",
|
||||
},
|
||||
"present_to": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
// "purge_attempts": {
|
||||
// Type: schema.TypeInt,
|
||||
// Computed: true,
|
||||
// Description: "Number of deletion attempts",
|
||||
// },
|
||||
"purge_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Time of the last deletion attempt",
|
||||
},
|
||||
// "reality_device_number": {
|
||||
// Type: schema.TypeInt,
|
||||
// Computed: true,
|
||||
// Description: "Reality device number",
|
||||
// },
|
||||
// "reference_id": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// Description: "ID of the reference to the disk",
|
||||
// },
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Resource ID",
|
||||
},
|
||||
"res_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the resource",
|
||||
},
|
||||
"role": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Disk role",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Storage endpoint provider ID to create disk",
|
||||
},
|
||||
"sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
||||
},
|
||||
"shareable": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Size in GB",
|
||||
},
|
||||
"size_used": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
Description: "Number of used space, in GB",
|
||||
},
|
||||
"snapshots": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ID of the snapshot",
|
||||
},
|
||||
"label": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Reference to the snapshot",
|
||||
},
|
||||
"snap_set_guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "The set snapshot ID",
|
||||
},
|
||||
"snap_set_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "The set time of the snapshot",
|
||||
},
|
||||
"timestamp": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Snapshot time",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Disk status",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Technical status of the disk",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
||||
},
|
||||
"vmid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Virtual Machine ID (Deprecated)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceDiskListDeleted() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
@@ -64,6 +479,6 @@ func DataSourceDiskListDeleted() *schema.Resource {
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceDiskListSchemaMake(),
|
||||
Schema: dataSourceDiskDeletedListSchemaMake(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ func flattenDiskSnapshot(d *schema.ResourceData, snapshot disks.ItemSnapshot) {
|
||||
d.Set("snap_set_time", snapshot.SnapSetTime)
|
||||
}
|
||||
|
||||
func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, unattachedDisk := range ul {
|
||||
func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(ul.Data))
|
||||
for _, unattachedDisk := range ul.Data {
|
||||
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
|
||||
tmp := map[string]interface{}{
|
||||
"_ckey": unattachedDisk.CKey,
|
||||
@@ -120,7 +120,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||
}
|
||||
|
||||
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||
res := make([]interface{}, 0)
|
||||
res := make([]interface{}, 0, len(sl))
|
||||
for _, snapshot := range sl {
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
@@ -136,9 +136,9 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDiskList(dl disks.ListDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, disk := range dl {
|
||||
func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(dl.Data))
|
||||
for _, disk := range dl.Data {
|
||||
diskAcl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
"account_id": disk.AccountID,
|
||||
|
||||
@@ -19,7 +19,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(accountList.FilterByID(accountId)) != 0, nil
|
||||
return len(accountList.FilterByID(accountId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -32,5 +32,5 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(locationList.FilterByGID(gid)) != 0, nil
|
||||
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||
@@ -157,23 +157,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
case status.Destroyed, status.Purged:
|
||||
d.Set("disk_id", 0)
|
||||
d.SetId("")
|
||||
return resourceDiskCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceDiskCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
req := disks.RestoreRequest{
|
||||
DiskID: disk.ID,
|
||||
}
|
||||
// hasChangeState = true
|
||||
// req := disks.RestoreRequest{
|
||||
// DiskID: disk.ID,
|
||||
// }
|
||||
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
} else {
|
||||
req.Reason = "Terraform automatic restore"
|
||||
}
|
||||
// if reason, ok := d.GetOk("reason"); ok {
|
||||
// req.Reason = reason.(string)
|
||||
// } else {
|
||||
// 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.Modeled:
|
||||
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
|
||||
@@ -227,7 +228,8 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
case status.Destroyed, status.Purged:
|
||||
d.Set("disk_id", 0)
|
||||
d.SetId("")
|
||||
return resourceDiskCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceDiskCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
req := disks.RestoreRequest{
|
||||
@@ -271,7 +273,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
Size: uint64(newSize.(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Disks().Resize(ctx, req)
|
||||
_, err := c.CloudAPI().Disks().Resize2(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
@@ -43,22 +43,46 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (disks.ListDisks, error) {
|
||||
func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if account_name, ok := d.GetOk("account_name"); ok {
|
||||
req.AccountName = account_name.(string)
|
||||
}
|
||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if shared, ok := d.GetOk("shared"); ok {
|
||||
req.Shared = shared.(bool)
|
||||
}
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = strings.ToUpper(diskType.(string))
|
||||
}
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
req.AccountID = uint64(sepId.(int))
|
||||
}
|
||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||
req.Pool = pool_name.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = strings.ToUpper(diskType.(string))
|
||||
}
|
||||
if accountId, ok := d.GetOk("accountId"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
||||
|
||||
92
internal/service/cloudapi/disks/utility_disk_list_deleted.go
Normal file
92
internal/service/cloudapi/disks/utility_disk_list_deleted.go
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListDeletedRequest{}
|
||||
|
||||
if account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if typev, ok := d.GetOk("type"); ok {
|
||||
req.Type = typev.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if account_name, ok := d.GetOk("account_name"); ok {
|
||||
req.AccountName = account_name.(string)
|
||||
}
|
||||
|
||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||
}
|
||||
|
||||
if shared, ok := d.GetOk("shared"); ok {
|
||||
req.Shared = shared.(bool)
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListDeletedCheckPresence: load disk list")
|
||||
diskList, err := c.CloudAPI().Disks().ListDeleted(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return diskList, nil
|
||||
}
|
||||
@@ -9,12 +9,40 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (disks.ListDisksUnattached, error) {
|
||||
func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisksUnattached, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListUnattachedRequest{}
|
||||
if accountId, ok := d.GetOk("accountId"); ok {
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
if account_name, ok := d.GetOk("account_name"); ok {
|
||||
req.AccountName = account_name.(string)
|
||||
}
|
||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = diskType.(string)
|
||||
}
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
req.AccountID = uint64(sepId.(int))
|
||||
}
|
||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||
req.Pool = pool_name.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
||||
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
||||
|
||||
@@ -41,11 +41,18 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]interface{}, error) {
|
||||
func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListTypesRequest{
|
||||
Detailed: true,
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
|
||||
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||
|
||||
@@ -41,12 +41,19 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]interface{}, error) {
|
||||
func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListTypesRequest{
|
||||
Detailed: false,
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
|
||||
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -71,13 +72,6 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "meta",
|
||||
},
|
||||
"check__ips": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"check_ips": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -50,7 +50,7 @@ func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceDat
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
||||
|
||||
d.Set("entry_count", extnetComputesList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,6 +61,26 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "filter by account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by compute ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -117,6 +137,10 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m int
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenExtnetList(extnetList))
|
||||
d.Set("entry_count", extnetList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -59,7 +60,36 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "filter by account ID",
|
||||
Description: "Find by account ID",
|
||||
},
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"vlan_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by VLAN ID",
|
||||
},
|
||||
"vnfdev_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by VnfDEV ID",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -91,6 +121,10 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import (
|
||||
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
||||
d.Set("ckey", e.CKey)
|
||||
d.Set("meta", flattens.FlattenMeta(e.Meta))
|
||||
d.Set("check__ips", e.CheckIPs)
|
||||
d.Set("check_ips", e.CheckIps)
|
||||
d.Set("check_ips", e.CheckIPs)
|
||||
d.Set("default", e.Default)
|
||||
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
|
||||
d.Set("desc", e.Description)
|
||||
@@ -36,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
||||
}
|
||||
|
||||
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ex))
|
||||
for _, item := range ex {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": item.ClientType,
|
||||
@@ -52,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ers))
|
||||
for _, er := range ers {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": er.ClientType,
|
||||
@@ -93,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (ecs))
|
||||
for _, ec := range ecs {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": ec.ID,
|
||||
@@ -106,9 +105,9 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ec := range ecl {
|
||||
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(ecl.Data))
|
||||
for _, ec := range ecl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": ec.AccountID,
|
||||
"account_name": ec.AccountName,
|
||||
@@ -123,9 +122,9 @@ func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]inter
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetList(el extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, e := range el {
|
||||
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(el.Data))
|
||||
for _, e := range el.Data {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
|
||||
@@ -42,12 +42,26 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (extnet.ListExtNetComputes, error) {
|
||||
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNetComputes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := extnet.ListComputesRequest{
|
||||
AccountID: uint64(d.Get("account_id").(int)),
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||
req.ComputeID = uint64(compute_id.(int))
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
|
||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,13 +42,31 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (extnet.ListExtNets, error) {
|
||||
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNets, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := extnet.ListRequest{}
|
||||
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
req.Network = network.(string)
|
||||
}
|
||||
if vlan_id, ok := d.GetOk("vlan_id"); ok {
|
||||
req.VLANID = uint64(vlan_id.(int))
|
||||
}
|
||||
if vnfdev_id, ok := d.GetOk("vnfdev_id"); ok {
|
||||
req.VNFDevID = uint64(vnfdev_id.(int))
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
@@ -66,10 +66,6 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -77,13 +73,6 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -96,26 +85,10 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -148,28 +121,16 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -53,12 +53,48 @@ func dataSourceFlipgroupList(ctx context.Context, d *schema.ResourceData, m inte
|
||||
d.SetId(id.String())
|
||||
|
||||
d.Set("items", flattenFlipgroupList(fg_list))
|
||||
d.Set("entry_count", fg_list.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by Name",
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"vins_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ExtNetID",
|
||||
},
|
||||
"by_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by IP-address",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -82,10 +118,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -93,13 +125,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -112,26 +137,10 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -164,33 +173,25 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,19 +38,13 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||
)
|
||||
|
||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.ItemFLIPGroup) {
|
||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
||||
d.Set("account_id", fg.AccountID)
|
||||
d.Set("account_name", fg.AccountName)
|
||||
d.Set("client_ids", fg.ClientIDs)
|
||||
d.Set("client_names", fg.ClientNames)
|
||||
d.Set("client_type", fg.ClientType)
|
||||
d.Set("conn_id", fg.ConnID)
|
||||
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("deleted_by", fg.DeletedBy)
|
||||
d.Set("deleted_time", fg.DeletedTime)
|
||||
d.Set("desc", fg.Description)
|
||||
d.Set("gid", fg.GID)
|
||||
d.Set("guid", fg.GUID)
|
||||
@@ -60,30 +54,19 @@ func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.ItemFLIPGroup) {
|
||||
d.Set("name", fg.Name)
|
||||
d.Set("net_id", fg.NetID)
|
||||
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("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)
|
||||
for _, fg := range fg_list {
|
||||
for _, fg := range fg_list.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": fg.AccountID,
|
||||
"account_name": fg.AccountName,
|
||||
"client_ids": fg.ClientIDs,
|
||||
"client_names": fg.ClientNames,
|
||||
"client_type": fg.ClientType,
|
||||
"conn_id": fg.ConnID,
|
||||
"conn_type": fg.ConnType,
|
||||
"created_by": fg.CreatedBy,
|
||||
"created_time": fg.CreatedTime,
|
||||
"default_gw": fg.DefaultGW,
|
||||
"deleted_by": fg.DeletedBy,
|
||||
"deleted_time": fg.DeletedTime,
|
||||
"desc": fg.Description,
|
||||
"gid": fg.GID,
|
||||
"guid": fg.GUID,
|
||||
@@ -93,12 +76,7 @@ func flattenFlipgroupList(fg_list flipgroup.ListFLIPGroups) []map[string]interfa
|
||||
"name": fg.Name,
|
||||
"net_id": fg.NetID,
|
||||
"net_type": fg.NetType,
|
||||
"network": fg.Network,
|
||||
"rg_id": fg.RGID,
|
||||
"rg_name": fg.RGName,
|
||||
"status": fg.Status,
|
||||
"updated_by": fg.UpdatedBy,
|
||||
"updated_time": fg.UpdatedTime,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -205,17 +205,6 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -224,26 +213,10 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -256,28 +229,16 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.ItemFLIPGroup, warn *dc.Warnings) {
|
||||
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.RecordFLIPGroup, warn *dc.Warnings) {
|
||||
addedClients := make([]interface{}, 0)
|
||||
removedClients := make([]interface{}, 0)
|
||||
|
||||
@@ -127,7 +127,7 @@ func addComputesAfterCreation(ctx context.Context, warnings *dc.Warnings, c *con
|
||||
}
|
||||
}
|
||||
|
||||
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ItemFLIPGroup, error) {
|
||||
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.RecordFLIPGroup, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := flipgroup.GetRequest{}
|
||||
|
||||
@@ -146,10 +146,38 @@ func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
return fg, err
|
||||
}
|
||||
|
||||
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (flipgroup.ListFLIPGroups, error) {
|
||||
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ListFLIPGroups, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := flipgroup.ListRequest{}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if vinsId, ok := d.GetOk("vins_id"); ok {
|
||||
req.VINSID = uint64(vinsId.(int))
|
||||
}
|
||||
|
||||
if vinsName, ok := d.GetOk("vins_name"); ok {
|
||||
req.VINSName = vinsName.(string)
|
||||
}
|
||||
|
||||
if extNetId, ok := d.GetOk("extnet_id"); ok {
|
||||
req.ExtNetID = uint64(extNetId.(int))
|
||||
}
|
||||
|
||||
if byIp, ok := d.GetOk("by_ip"); ok {
|
||||
req.ByIP = byIp.(string)
|
||||
}
|
||||
|
||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rgId.(int))
|
||||
}
|
||||
|
||||
if byId, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(byId.(int))
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
@@ -49,16 +49,72 @@ func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m inte
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenImageList(imageList))
|
||||
d.Set("entry_count", imageList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "optional account ID to include account images",
|
||||
Description: "Filter by Storage Endpoint ID",
|
||||
},
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"architecture": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by architecture",
|
||||
},
|
||||
"type_image": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by image type",
|
||||
},
|
||||
"image_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by image size",
|
||||
},
|
||||
"sep_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by SEP name",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by pool",
|
||||
},
|
||||
"public": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Find public/private images",
|
||||
},
|
||||
"hot_resize": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Find hot resizable images",
|
||||
},
|
||||
"bootable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Find bootable images",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -78,6 +134,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||
Schema: dataSourceImageSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
return rets
|
||||
|
||||
@@ -58,9 +58,9 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
||||
d.Set("version", img.Version)
|
||||
}
|
||||
|
||||
func flattenImageList(il image.ListImages) []map[string]interface{} {
|
||||
func flattenImageList(il *image.ListImages) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, img := range il {
|
||||
for _, img := range il.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": img.AccountID,
|
||||
"architecture": img.Architecture,
|
||||
|
||||
@@ -19,7 +19,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(accounts.FilterByID(accountId)) != 0, nil
|
||||
return len(accounts.FilterByID(accountId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -32,5 +32,5 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(locationList.FilterByGID(gid)) != 0, nil
|
||||
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||
}
|
||||
|
||||
@@ -144,7 +144,8 @@ func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
case status.Created:
|
||||
case status.Destroyed, status.Purged:
|
||||
d.SetId("")
|
||||
return resourceImageCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceImageCreate(ctx, d, m)
|
||||
}
|
||||
|
||||
flattenImage(d, img)
|
||||
@@ -233,7 +234,8 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
case status.Created:
|
||||
case status.Destroyed, status.Purged:
|
||||
d.SetId("")
|
||||
return resourceImageCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceImageCreate(ctx, d, m)
|
||||
}
|
||||
|
||||
if d.HasChange("name") {
|
||||
|
||||
@@ -50,7 +50,7 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := image.CreateVirtualRequest{
|
||||
Name: d.Get("name").(string),
|
||||
TargetID: uint64(d.Get("target_id").(int)),
|
||||
TargetID: uint64(d.Get("link_to").(int)),
|
||||
}
|
||||
|
||||
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
|
||||
|
||||
@@ -42,12 +42,56 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (image.ListImages, error) {
|
||||
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := image.ListRequest{}
|
||||
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
if sep_id, ok := d.GetOk("sep_id"); ok {
|
||||
req.SEPID = uint64(sep_id.(int))
|
||||
}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
if architecture, ok := d.GetOk("architecture"); ok {
|
||||
req.Architecture = architecture.(string)
|
||||
}
|
||||
|
||||
if type_image, ok := d.GetOk("type_image"); ok {
|
||||
req.TypeImage = type_image.(string)
|
||||
}
|
||||
|
||||
if image_size, ok := d.GetOk("image_size"); ok {
|
||||
req.ImageSize = uint64(image_size.(int))
|
||||
}
|
||||
|
||||
if sep_name, ok := d.GetOk("sep_name"); ok {
|
||||
req.SEPName = sep_name.(string)
|
||||
}
|
||||
|
||||
if pool, ok := d.GetOk("pool"); ok {
|
||||
req.Pool = pool.(string)
|
||||
}
|
||||
|
||||
if public, ok := d.GetOk("public"); ok {
|
||||
req.Public = public.(bool)
|
||||
}
|
||||
|
||||
if hot_resize, ok := d.GetOk("hot_resize"); ok {
|
||||
req.HotResize = hot_resize.(bool)
|
||||
}
|
||||
|
||||
if bootable, ok := d.GetOk("bootable"); ok {
|
||||
req.Bootable = bootable.(bool)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
|
||||
175
internal/service/cloudapi/k8s/data_source_k8ci_list.go
Normal file
175
internal/service/cloudapi/k8s/data_source_k8ci_list.go
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceK8CIListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
list, err := utilityK8CIListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(uuid.New().String())
|
||||
flattenK8CIList(d, list)
|
||||
d.Set("entry_count", list.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceK8CIListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"worker_driver": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by worker driver",
|
||||
},
|
||||
"master_driver": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by master driver",
|
||||
},
|
||||
"network_plugin": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by network plugin",
|
||||
},
|
||||
"include_disabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Include deleted k8cis in result",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"k8ci_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "K8CI ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "K8CI name",
|
||||
},
|
||||
"lb_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "LB Image ID",
|
||||
},
|
||||
"network_plugins": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of available network plugins",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "K8CI Status",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"version": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceK8CIList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceK8CIListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceK8CIListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +61,7 @@ func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
|
||||
curK8s := k8s.ItemK8SCluster{}
|
||||
for _, k8sCluster := range k8sList {
|
||||
for _, k8sCluster := range k8sList.Data {
|
||||
if k8sCluster.ID == cluster.ID {
|
||||
curK8s = k8sCluster
|
||||
}
|
||||
|
||||
@@ -80,10 +80,6 @@ func computesSchemaMake() map[string]*schema.Schema {
|
||||
}
|
||||
}
|
||||
|
||||
func workerComputesSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{}
|
||||
}
|
||||
|
||||
func dataSourceK8sComputesSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"k8s_id": {
|
||||
|
||||
@@ -135,6 +135,46 @@ func k8sWorkersGroupsSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func createK8sListSchema() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by IP address",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by LB ID",
|
||||
},
|
||||
"bservice_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by BService ID",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by status",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by tech. status",
|
||||
},
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -276,6 +316,10 @@ func createK8sListSchema() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ func dataSourceK8sListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
||||
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
k8sListDeleted := createK8sListSchema()
|
||||
delete(k8sListDeleted, "includedeleted")
|
||||
delete(k8sListDeleted, "status")
|
||||
return k8sListDeleted
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("dataSourceK8sWgCloudInitRead: called with k8s id %d and wg id %d", d.Get("k8s_id").(int), d.Get("wg_id").(int))
|
||||
|
||||
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("cloud_init", metaData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceK8sWgCloudInitSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"k8s_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Kubernetes cluster ID",
|
||||
},
|
||||
"wg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the workers compute group",
|
||||
},
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Worker group Cloud init",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceK8sWgCloudInit() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceK8sWgCloudInitRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceK8sWgCloudInitSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,34 @@ import (
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8ci"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
)
|
||||
|
||||
func flattenK8CIItems(list *k8ci.ListK8CI) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(list.Data))
|
||||
for _, item := range list.Data {
|
||||
temp := map[string]interface{}{
|
||||
"k8ci_id": item.ID,
|
||||
"name": item.Name,
|
||||
"lb_image_id": item.LBImageID,
|
||||
"network_plugins": item.NetworkPlugins,
|
||||
"status": item.Status,
|
||||
"desc": item.Description,
|
||||
"created_time": item.CreatedTime,
|
||||
"version": item.Version,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenK8CIList(d *schema.ResourceData, list *k8ci.ListK8CI) {
|
||||
d.Set("items", flattenK8CIItems(list))
|
||||
}
|
||||
|
||||
func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
||||
d.Set("k8s_id", cluster.ID)
|
||||
d.Set("masters", flattenMasterComputes(cluster))
|
||||
@@ -47,7 +72,7 @@ func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
||||
}
|
||||
|
||||
func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Masters.DetailedInfo))
|
||||
for _, comp := range cluster.K8SGroups.Masters.DetailedInfo {
|
||||
temp := map[string]interface{}{
|
||||
"id": comp.ID,
|
||||
@@ -63,7 +88,7 @@ func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Workers))
|
||||
for _, wg := range cluster.K8SGroups.Workers {
|
||||
for _, comp := range wg.DetailedInfo {
|
||||
temp := map[string]interface{}{
|
||||
@@ -81,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (aclList))
|
||||
for _, acl := range aclList {
|
||||
temp := map[string]interface{}{
|
||||
"explicit": acl.Explicit,
|
||||
@@ -109,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (interfaces))
|
||||
for _, interfaceCompute := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"def_gw": interfaceCompute.DefGW,
|
||||
@@ -122,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
||||
}
|
||||
|
||||
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (detailedInfoList))
|
||||
if computes != nil {
|
||||
for i, detailedInfo := range detailedInfoList {
|
||||
temp := map[string]interface{}{
|
||||
@@ -168,7 +193,7 @@ func flattenMasterGroup(mastersGroup k8s.MasterGroup, masters []compute.RecordCo
|
||||
}
|
||||
|
||||
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(k8SGroupList))
|
||||
for _, k8sGroup := range k8SGroupList {
|
||||
labels := make([]string, 0)
|
||||
for _, label := range k8sGroup.Labels {
|
||||
@@ -197,15 +222,15 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"masters": flattenMasterGroup(k8sGroups.Masters, masters),
|
||||
"workers": flattenK8sGroup(k8sGroups.Workers, workers),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
// func flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []map[string]interface{} {
|
||||
// res := make([]map[string]interface{}, 0)
|
||||
// temp := map[string]interface{}{
|
||||
// "masters": flattenMasterGroup(k8sGroups.Masters, masters),
|
||||
// "workers": flattenK8sGroup(k8sGroups.Workers, workers),
|
||||
// }
|
||||
// res = append(res, temp)
|
||||
// return res
|
||||
// }
|
||||
|
||||
func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
|
||||
d.Set("acl", flattenAcl(cluster.ACL))
|
||||
@@ -242,7 +267,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
|
||||
}
|
||||
|
||||
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (workersGroups))
|
||||
for _, worker := range workersGroups {
|
||||
temp := map[string]interface{}{
|
||||
"annotations": worker.Annotations,
|
||||
@@ -262,9 +287,9 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenK8sItems(k8sItems k8s.ListK8SClusters) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, item := range k8sItems {
|
||||
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len (k8sItems.Data))
|
||||
for _, item := range k8sItems.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": item.AccountID,
|
||||
"account_name": item.Name,
|
||||
@@ -299,8 +324,9 @@ func flattenK8sItems(k8sItems k8s.ListK8SClusters) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenK8sList(d *schema.ResourceData, k8sItems k8s.ListK8SClusters) {
|
||||
func flattenK8sList(d *schema.ResourceData, k8sItems *k8s.ListK8SClusters) {
|
||||
d.Set("items", flattenK8sItems(k8sItems))
|
||||
d.Set("entry_count", k8sItems.EntryCount)
|
||||
}
|
||||
|
||||
func flattenResourceK8sCP(d *schema.ResourceData, k8s k8s.RecordK8S, masters []compute.RecordCompute) {
|
||||
@@ -370,7 +396,7 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
|
||||
}
|
||||
|
||||
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
|
||||
labels := make([]string, 0)
|
||||
labels := make([]string, 0, len(wg.Labels))
|
||||
for _, label := range wg.Labels {
|
||||
if strings.HasPrefix(label, "workersGroupName") {
|
||||
continue
|
||||
@@ -392,7 +418,7 @@ func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.R
|
||||
}
|
||||
|
||||
func flattenWgList(wgList k8s.ListK8SGroups, computesMap map[uint64][]compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(wgList))
|
||||
for _, wg := range wgList {
|
||||
computes := computesMap[wg.ID]
|
||||
temp := map[string]interface{}{
|
||||
|
||||
@@ -21,7 +21,7 @@ func existK8sID(ctx context.Context, d *schema.ResourceData, m interface{}) (boo
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(k8sList.FilterByID(k8sID)) != 0, nil
|
||||
return len(k8sList.FilterByID(k8sID).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existK8sCIID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -34,7 +34,7 @@ func existK8sCIID(ctx context.Context, d *schema.ResourceData, m interface{}) (b
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(k8sciList.FilterByID(k8sciID)) != 0, nil
|
||||
return len(k8sciList.FilterByID(k8sciID).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -47,7 +47,7 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(rgList.FilterByID(rgID)) != 0, nil
|
||||
return len(rgList.FilterByID(rgID).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -65,5 +65,5 @@ func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(extNetList.FilterByID(extNetID)) != 0, nil
|
||||
return len(extNetList.FilterByID(extNetID).Data) != 0, nil
|
||||
}
|
||||
|
||||
@@ -145,6 +145,54 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
createReq.WithLB = d.Get("with_lb").(bool)
|
||||
|
||||
///4.4.0
|
||||
createReq.HighlyAvailable = d.Get("ha_mode").(bool)
|
||||
|
||||
if additionalSans, ok := d.GetOk("additional_sans"); ok {
|
||||
addSans := additionalSans.([]interface{})
|
||||
resSans := make([]string, 0)
|
||||
for _, san := range addSans {
|
||||
resSans = append(resSans, san.(string))
|
||||
}
|
||||
|
||||
createReq.AdditionalSANs = resSans
|
||||
}
|
||||
|
||||
if clusterConfig, ok := d.GetOk("cluster_config"); ok {
|
||||
createReq.ClusterConfiguration = clusterConfig.(string)
|
||||
}
|
||||
|
||||
if kubeletConfig, ok := d.GetOk("kubelet_config"); ok {
|
||||
createReq.KubeletConfiguration = kubeletConfig.(string)
|
||||
}
|
||||
|
||||
if kubeProxyConfig, ok := d.GetOk("kube_proxy_config"); ok {
|
||||
createReq.KubeProxyConfiguration = kubeProxyConfig.(string)
|
||||
}
|
||||
|
||||
if joinConfig, ok := d.GetOk("join_config"); ok {
|
||||
createReq.JoinConfiguration = joinConfig.(string)
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
createReq.UserData = cloudInit.(string)
|
||||
}
|
||||
|
||||
if initConfig, ok := d.GetOk("init_config"); ok {
|
||||
createReq.InitConfiguration = initConfig.(string)
|
||||
}
|
||||
|
||||
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
|
||||
createReq.LbSysctlParams = lbSysctlParams.(string)
|
||||
}
|
||||
|
||||
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
||||
createReq.OidcCertificate = oidcCertificate.(string)
|
||||
}
|
||||
///
|
||||
|
||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||
|
||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||
createReq.ExtNetID = uint64(extNet.(int))
|
||||
} else {
|
||||
@@ -181,7 +229,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 10)
|
||||
time.Sleep(time.Second * 20)
|
||||
}
|
||||
|
||||
return resourceK8sRead(ctx, d, m)
|
||||
@@ -205,31 +253,32 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
case status.Created:
|
||||
case status.Deleting:
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := k8s.RestoreRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := k8s.RestoreRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
enableReq := k8s.DisableEnableRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// enableReq := k8s.DisableEnableRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -267,7 +316,7 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
curK8s := k8s.ItemK8SCluster{}
|
||||
for _, k8sCluster := range k8sList {
|
||||
for _, k8sCluster := range k8sList.Data {
|
||||
if k8sCluster.ID == cluster.ID {
|
||||
curK8s = k8sCluster
|
||||
}
|
||||
@@ -299,17 +348,19 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
|
||||
flattenResourceK8s(d, *cluster, masterComputeList, workersComputeList)
|
||||
|
||||
lbGetReq := lb.GetRequest{
|
||||
LBID: cluster.LBID,
|
||||
}
|
||||
if d.Get("with_lb").(bool) || cluster.LBID != 0 {
|
||||
lbGetReq := lb.GetRequest{
|
||||
LBID: cluster.LBID,
|
||||
}
|
||||
|
||||
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.Set("extnet_id", lb.ExtNetID)
|
||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||
d.Set("extnet_id", lb.ExtNetID)
|
||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||
}
|
||||
|
||||
kubeconfigReq := k8s.GetConfigRequest{
|
||||
K8SID: cluster.ID,
|
||||
@@ -386,7 +437,8 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -559,6 +611,12 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
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",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -566,6 +624,63 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
ForceNew: true,
|
||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||
},
|
||||
|
||||
///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",
|
||||
},
|
||||
////
|
||||
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -658,6 +773,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "ID of default vins for this instace.",
|
||||
},
|
||||
|
||||
@@ -129,6 +129,56 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
|
||||
createReq.WithLB = d.Get("with_lb").(bool)
|
||||
|
||||
///4.4.0
|
||||
createReq.HighlyAvailable = d.Get("ha_mode").(bool)
|
||||
|
||||
if additionalSans, ok := d.GetOk("additional_sans"); ok {
|
||||
addSans := additionalSans.([]interface{})
|
||||
resSans := make([]string, 0)
|
||||
for _, san := range addSans {
|
||||
resSans = append(resSans, san.(string))
|
||||
}
|
||||
|
||||
createReq.AdditionalSANs = resSans
|
||||
}
|
||||
|
||||
if clusterConfig, ok := d.GetOk("cluster_config"); ok {
|
||||
createReq.ClusterConfiguration = clusterConfig.(string)
|
||||
}
|
||||
|
||||
if kubeletConfig, ok := d.GetOk("kubelet_config"); ok {
|
||||
createReq.KubeletConfiguration = kubeletConfig.(string)
|
||||
}
|
||||
|
||||
if kubeProxyConfig, ok := d.GetOk("kube_proxy_config"); ok {
|
||||
createReq.KubeProxyConfiguration = kubeProxyConfig.(string)
|
||||
}
|
||||
|
||||
if joinConfig, ok := d.GetOk("join_config"); ok {
|
||||
createReq.JoinConfiguration = joinConfig.(string)
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
createReq.UserData = cloudInit.(string)
|
||||
}
|
||||
|
||||
if initConfig, ok := d.GetOk("init_config"); ok {
|
||||
createReq.InitConfiguration = initConfig.(string)
|
||||
}
|
||||
|
||||
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
|
||||
createReq.LbSysctlParams = lbSysctlParams.(string)
|
||||
}
|
||||
|
||||
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
|
||||
createReq.OidcCertificate = oidcCertificate.(string)
|
||||
log.Debug(createReq.OidcCertificate)
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
|
||||
|
||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||
createReq.ExtNetID = uint64(extNet.(int))
|
||||
} else {
|
||||
@@ -165,7 +215,7 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 10)
|
||||
time.Sleep(time.Second * 20)
|
||||
}
|
||||
|
||||
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||
@@ -204,31 +254,32 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
case status.Created:
|
||||
case status.Deleting:
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := k8s.RestoreRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := k8s.RestoreRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
enableReq := k8s.DisableEnableRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// enableReq := k8s.DisableEnableRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -267,7 +318,7 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
|
||||
curK8s := k8s.ItemK8SCluster{}
|
||||
for _, k8sCluster := range k8sList {
|
||||
for _, k8sCluster := range k8sList.Data {
|
||||
if k8sCluster.ID == cluster.ID {
|
||||
curK8s = k8sCluster
|
||||
}
|
||||
@@ -291,7 +342,7 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
|
||||
if _, ok := d.GetOk("k8s_id"); !ok {
|
||||
for _, worker := range cluster.K8SGroups.Workers {
|
||||
err := fmt.Errorf("Found worker-group with ID %d. Make sure to import it to decort_k8s_wg resource if you wish to manage it", worker.ID)
|
||||
err := fmt.Errorf("found worker-group with ID %d. Make sure to import it to decort_k8s_wg resource if you wish to manage it", worker.ID)
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
@@ -302,13 +353,15 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
LBID: cluster.LBID,
|
||||
}
|
||||
|
||||
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
if d.Get("with_lb").(bool) || cluster.LBID != 0 {
|
||||
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.Set("extnet_id", lb.ExtNetID)
|
||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||
d.Set("extnet_id", lb.ExtNetID)
|
||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||
}
|
||||
|
||||
kubeconfigReq := k8s.GetConfigRequest{
|
||||
K8SID: cluster.ID,
|
||||
@@ -385,7 +438,8 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -565,6 +619,67 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
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,
|
||||
|
||||
@@ -92,6 +92,10 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
req.WorkerDisk = uint64(d.Get("disk").(int))
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
req.UserData = cloudInit.(string)
|
||||
}
|
||||
|
||||
resp, err := c.CloudAPI().K8S().WorkersGroupAdd(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -110,7 +114,7 @@ func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
workersComputeList := make([]compute.RecordCompute, 0, 0)
|
||||
workersComputeList := make([]compute.RecordCompute, 0)
|
||||
for _, info := range wg.DetailedInfo {
|
||||
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||
if err != nil {
|
||||
@@ -184,6 +188,19 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cloud_init") {
|
||||
req := k8s.UpdateWorkerNodesMetaDataRequest{
|
||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||
WorkersGroupID: wgId,
|
||||
UserData: d.Get("cloud_init").(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().K8S().UpdateWorkerNodesMetaData(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -286,6 +303,11 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DiffSuppressFunc: cloudInitDiffSupperss,
|
||||
},
|
||||
"wg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
83
internal/service/cloudapi/k8s/utility_k8ci.go
Normal file
83
internal/service/cloudapi/k8s/utility_k8ci.go
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8ci"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityK8CIListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*k8ci.ListK8CI, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := k8ci.ListRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if worker_driver, ok := d.GetOk("worker_driver"); ok {
|
||||
req.WorkerDriver = worker_driver.(string)
|
||||
}
|
||||
if master_driver, ok := d.GetOk("master_driver"); ok {
|
||||
req.MasterDriver = master_driver.(string)
|
||||
}
|
||||
if network_plugin, ok := d.GetOk("network_plugin"); ok {
|
||||
req.NetworkPlugins = network_plugin.(string)
|
||||
}
|
||||
if include_disabled, ok := d.GetOk("include_disabled"); ok {
|
||||
req.IncludeDisabled = include_disabled.(bool)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
resList, err := c.CloudAPI().K8CI().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resList, nil
|
||||
}
|
||||
@@ -223,12 +223,57 @@ func utilityDataK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
return k8s, nil
|
||||
}
|
||||
|
||||
func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (k8s.ListK8SClusters, error) {
|
||||
func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*k8s.ListK8SClusters, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := k8s.ListRequest{
|
||||
IncludeDeleted: false,
|
||||
}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if ip_address, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ip_address.(string)
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if lb_id, ok := d.GetOk("lb_id"); ok {
|
||||
req.LBID = uint64(lb_id.(int))
|
||||
}
|
||||
|
||||
if bservice_id, ok := d.GetOk("bservice_id"); ok {
|
||||
req.BasicServiceID = uint64(bservice_id.(int))
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||
req.IncludeDeleted = includedeleted.(bool)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
|
||||
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -237,10 +282,46 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
return k8sList, nil
|
||||
}
|
||||
|
||||
func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (k8s.ListK8SClusters, error) {
|
||||
func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*k8s.ListK8SClusters, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := k8s.ListDeletedRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if ip_address, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ip_address.(string)
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if lb_id, ok := d.GetOk("lb_id"); ok {
|
||||
req.LBID = uint64(lb_id.(int))
|
||||
}
|
||||
|
||||
if bservice_id, ok := d.GetOk("bservice_id"); ok {
|
||||
req.BasicServiceID = uint64(bservice_id.(int))
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
k8sList, err := c.CloudAPI().K8S().ListDeleted(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
@@ -70,7 +71,7 @@ func utilityDataK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
return nil, nil, fmt.Errorf("WG with id %v in k8s cluster %v not found", wgId, k8sId)
|
||||
}
|
||||
|
||||
workersComputeList := make([]compute.RecordCompute, 0, 0)
|
||||
workersComputeList := make([]compute.RecordCompute, 0)
|
||||
for _, info := range curWg.DetailedInfo {
|
||||
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||
if err != nil {
|
||||
@@ -121,7 +122,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) {
|
||||
@@ -137,3 +138,27 @@ func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
|
||||
return cluster.K8SGroups.Workers, nil
|
||||
}
|
||||
|
||||
func utilityK8sWgCloudInitCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := k8s.GetWorkerNodesMetaDataRequest{
|
||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||
WorkersGroupID: uint64(d.Get("wg_id").(int)),
|
||||
}
|
||||
|
||||
cloudInit, err := c.CloudAPI().K8S().GetWorkerNodesMetaData(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return cloudInit, nil
|
||||
}
|
||||
|
||||
func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
|
||||
if newVal != "" && newVal != oldVal {
|
||||
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
|
||||
return false
|
||||
}
|
||||
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
|
||||
return true // suppress difference
|
||||
}
|
||||
|
||||
@@ -214,6 +214,10 @@ func computeSnapshotsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"reference_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -634,20 +638,8 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeList,
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"val": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
@@ -827,6 +819,14 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"stateless_sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stateless_sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ func dataSourceComputeListRead(ctx context.Context, d *schema.ResourceData, m in
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenComputeList(result))
|
||||
d.Set("entry_count", computeList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -334,6 +335,56 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by AccountID",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by resgroup name",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by RGID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by tech status",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by IP address",
|
||||
},
|
||||
"extnet_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet ID",
|
||||
},
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -359,6 +410,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Schema: itemComputeSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computeList, err := utilityDataComputeListDeletedCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
result := computeList
|
||||
if d.Get("ignore_k8s").(bool) {
|
||||
// matches automatically generated names like "s234-g2134-c1" etc
|
||||
result = matchComputes(computeList)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenComputeList(result))
|
||||
d.Set("entry_count", computeList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by AccountID",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by resgroup name",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by RGID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by tech status",
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by IP address",
|
||||
},
|
||||
"extnet_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"ignore_k8s": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "If set to true, ignores any VMs associated with any k8s cluster",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: itemComputeSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceComputeListDeleted() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeListDeletedRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeListDeletedSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceComputePCIDeviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computePCIDeviceList, err := utilityComputePCIDeviceListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenPCIDevice(computePCIDeviceList.Data))
|
||||
d.Set("entry_count", computePCIDeviceList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by RG id",
|
||||
},
|
||||
"device_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by device id",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputePCIDeviceList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputePCIDeviceListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputePCIDeviceListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenPfwList(computePfwList))
|
||||
d.Set("entry_count", computePfwList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -94,6 +95,10 @@ func dataSourceComputePfwListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
120
internal/service/cloudapi/kvmvm/data_source_compute_vgpu_list.go
Normal file
120
internal/service/cloudapi/kvmvm/data_source_compute_vgpu_list.go
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceComputeVGPUListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computeVGPUList, err := utilityComputeVGPUListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVGPU(computeVGPUList.Data))
|
||||
d.Set("entry_count", computeVGPUList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"gpu_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by GPU id",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by type",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputeVGPUList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeVGPUListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeVGPUListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -66,7 +66,7 @@ func flattenQOS(qos compute.QOS) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, interfaceItem := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"conn_id": interfaceItem.ConnID,
|
||||
@@ -92,7 +92,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
||||
return res
|
||||
}
|
||||
func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(snapSets))
|
||||
for _, snapSet := range snapSets {
|
||||
temp := map[string]interface{}{
|
||||
"disks": snapSet.Disks,
|
||||
@@ -105,7 +105,7 @@ func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenTags(tags map[string]string) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(tags))
|
||||
for key, val := range tags {
|
||||
temp := map[string]interface{}{
|
||||
"key": key,
|
||||
@@ -117,7 +117,7 @@ func flattenTags(tags map[string]string) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(listRules))
|
||||
for _, rule := range listRules {
|
||||
temp := map[string]interface{}{
|
||||
"guid": rule.GUID,
|
||||
@@ -132,7 +132,7 @@ func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(listAcl))
|
||||
for _, acl := range listAcl {
|
||||
temp := map[string]interface{}{
|
||||
"explicit": acl.Explicit,
|
||||
@@ -147,9 +147,9 @@ func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputeList(computes compute.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, compute := range computes {
|
||||
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computes.Data))
|
||||
for _, compute := range computes.Data {
|
||||
customFields, _ := json.Marshal(compute.CustomFields)
|
||||
devices, _ := json.Marshal(compute.Devices)
|
||||
temp := map[string]interface{}{
|
||||
@@ -236,10 +236,10 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []interface{}) []map[string]interface{} {
|
||||
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(disksList))
|
||||
for _, disk := range disksList {
|
||||
if disk.Name == "bootdisk" || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
|
||||
if disk.ID == bootDiskId || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
|
||||
continue
|
||||
}
|
||||
temp := map[string]interface{}{
|
||||
@@ -260,12 +260,13 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []in
|
||||
sort.Slice(res, func(i, j int) bool {
|
||||
return res[i]["disk_id"].(uint64) < res[j]["disk_id"].(uint64)
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
//index := 0
|
||||
|
||||
for _, network := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": network.NetID,
|
||||
@@ -280,7 +281,7 @@ func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{}
|
||||
|
||||
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
|
||||
for _, disk := range disks {
|
||||
if disk.Name == "bootdisk" {
|
||||
if disk.Type == "B" {
|
||||
return &disk
|
||||
}
|
||||
}
|
||||
@@ -300,7 +301,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
||||
|
||||
//check extraDisks, ipa_type, is,
|
||||
d.SetId(strconv.FormatUint(computeRec.ID, 10))
|
||||
d.Set("acl", flattenACL(computeRec.ACL))
|
||||
// d.Set("acl", flattenACL(computeRec.ACL))
|
||||
d.Set("account_id", computeRec.AccountID)
|
||||
d.Set("account_name", computeRec.AccountName)
|
||||
d.Set("affinity_weight", computeRec.AffinityWeight)
|
||||
@@ -316,12 +317,12 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||
d.Set("created_by", computeRec.CreatedBy)
|
||||
d.Set("created_time", computeRec.CreatedTime)
|
||||
d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
|
||||
// d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
|
||||
d.Set("deleted_by", computeRec.DeletedBy)
|
||||
d.Set("deleted_time", computeRec.DeletedTime)
|
||||
d.Set("description", computeRec.Description)
|
||||
d.Set("devices", string(devices))
|
||||
err := d.Set("disks", flattenComputeDisksDemo(computeRec.Disks, d.Get("extra_disks").(*schema.Set).List()))
|
||||
err := d.Set("disks", flattenComputeDisksDemo(computeRec.Disks, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -397,7 +398,7 @@ func flattenACL(acl compute.RecordACL) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenAffinityRules(affinityRules compute.ListRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(affinityRules))
|
||||
for _, affinityRule := range affinityRules {
|
||||
temp := map[string]interface{}{
|
||||
"guid": affinityRule.GUID,
|
||||
@@ -436,12 +437,13 @@ func flattenIotune(iotune compute.IOTune) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(snapshots))
|
||||
for _, snapshot := range snapshots {
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
"label": snapshot.Label,
|
||||
"res_id": snapshot.ResID,
|
||||
"reference_id": snapshot.ReferenceID,
|
||||
"snap_set_guid": snapshot.SnapSetGUID,
|
||||
"snap_set_time": snapshot.SnapSetTime,
|
||||
"timestamp": snapshot.TimeStamp,
|
||||
@@ -453,7 +455,7 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
|
||||
}
|
||||
|
||||
func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(disks))
|
||||
for _, disk := range disks {
|
||||
acl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
@@ -503,20 +505,13 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenCustomFields(customFileds map[string]interface{}) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for key, val := range customFileds {
|
||||
value, _ := json.Marshal(val)
|
||||
temp := map[string]interface{}{
|
||||
"key": key,
|
||||
"val": string(value),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
func flattenCustomFields(customFields map[string]interface{}) string {
|
||||
encoded, _ := json.Marshal(customFields)
|
||||
return string(encoded)
|
||||
}
|
||||
|
||||
func flattenOsUsers(osUsers compute.ListOSUser) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(osUsers))
|
||||
for _, user := range osUsers {
|
||||
temp := map[string]interface{}{
|
||||
"guid": user.GUID,
|
||||
@@ -595,7 +590,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
}
|
||||
|
||||
func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeAudits))
|
||||
for _, computeAudit := range computeAudits {
|
||||
temp := map[string]interface{}{
|
||||
"call": computeAudit.Call,
|
||||
@@ -609,9 +604,9 @@ func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interfa
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenPfwList(computePfws compute.ListPFWs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, computePfw := range computePfws {
|
||||
func flattenPfwList(computePfws *compute.ListPFWs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computePfws.Data))
|
||||
for _, computePfw := range computePfws.Data {
|
||||
temp := map[string]interface{}{
|
||||
"pfw_id": computePfw.ID,
|
||||
"local_ip": computePfw.LocalIP,
|
||||
@@ -626,14 +621,14 @@ func flattenPfwList(computePfws compute.ListPFWs) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenUserList(d *schema.ResourceData, userList compute.RecordACL) {
|
||||
d.Set("account_acl", flattenListACL(userList.AccountACL))
|
||||
d.Set("compute_acl", flattenListACL(userList.ComputeACL))
|
||||
d.Set("rg_acl", flattenListACL(userList.RGACL))
|
||||
func flattenUserList(d *schema.ResourceData, userList *compute.ListUsers) {
|
||||
d.Set("account_acl", flattenListACL(userList.Data.AccountACL))
|
||||
d.Set("compute_acl", flattenListACL(userList.Data.ComputeACL))
|
||||
d.Set("rg_acl", flattenListACL(userList.Data.RGACL))
|
||||
}
|
||||
|
||||
func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeAudits))
|
||||
for _, computeAudit := range computeAudits {
|
||||
temp := map[string]interface{}{
|
||||
"epoch": computeAudit.Epoch,
|
||||
@@ -645,7 +640,7 @@ func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string
|
||||
}
|
||||
|
||||
func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages))
|
||||
for _, computeUsage := range computeSnapshotUsages {
|
||||
temp := map[string]interface{}{
|
||||
"count": computeUsage.Count,
|
||||
@@ -657,3 +652,55 @@ func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []ma
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSnapshotList(computeSnapshotUsages *compute.ListSnapShots) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages.Data))
|
||||
for _, computeUsage := range computeSnapshotUsages.Data {
|
||||
temp := map[string]interface{}{
|
||||
"disks": computeUsage.Disks,
|
||||
"guid": computeUsage.GUID,
|
||||
"label": computeUsage.Label,
|
||||
"timestamp": computeUsage.Timestamp,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVGPU(m []interface{}) []string {
|
||||
output := []string{}
|
||||
for _, item := range m {
|
||||
switch d := item.(type) {
|
||||
case string:
|
||||
output = append(output, d)
|
||||
case int:
|
||||
output = append(output, strconv.Itoa(d))
|
||||
case int64:
|
||||
output = append(output, strconv.FormatInt(d, 10))
|
||||
case float64:
|
||||
output = append(output, strconv.FormatInt(int64(d), 10))
|
||||
default:
|
||||
output = append(output, "")
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
func flattenPCIDevice(m []interface{}) []string {
|
||||
output := []string{}
|
||||
for _, item := range m {
|
||||
switch d := item.(type) {
|
||||
case string:
|
||||
output = append(output, d)
|
||||
case int:
|
||||
output = append(output, strconv.Itoa(d))
|
||||
case int64:
|
||||
output = append(output, strconv.FormatInt(d, 10))
|
||||
case float64:
|
||||
output = append(output, strconv.FormatInt(int64(d), 10))
|
||||
default:
|
||||
output = append(output, "")
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -36,8 +37,8 @@ import (
|
||||
"bytes"
|
||||
"hash/fnv"
|
||||
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
||||
|
||||
"sort"
|
||||
|
||||
|
||||
1429
internal/service/cloudapi/kvmvm/old_schemas.go
Normal file
1429
internal/service/cloudapi/kvmvm/old_schemas.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +37,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
@@ -55,24 +57,26 @@ func existRgID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(rgList.FilterByID(rgId)) != 0, nil
|
||||
return len(rgList.FilterByID(rgId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
imageId := uint64(d.Get("image_id").(int))
|
||||
req := image.ListRequest{}
|
||||
req := image.ListRequest{
|
||||
ByID: imageId,
|
||||
}
|
||||
|
||||
imageList, err := c.CloudAPI().Image().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(imageList.FilterByID(imageId)) != 0, nil
|
||||
return len(imageList.Data) != 0, nil
|
||||
}
|
||||
|
||||
func existVinsIdInList(vinsId uint64, vinsList vins.ListVINS) bool {
|
||||
for _, vins := range vinsList {
|
||||
func existVinsIdInList(vinsId uint64, vinsList *vins.ListVINS) bool {
|
||||
for _, vins := range vinsList.Data {
|
||||
if vinsId == vins.ID {
|
||||
return true
|
||||
}
|
||||
@@ -81,8 +85,8 @@ func existVinsIdInList(vinsId uint64, vinsList vins.ListVINS) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func existExtNetIdInList(extId uint64, extList extnet.ListExtNets) bool {
|
||||
for _, ext := range extList {
|
||||
func existExtNetIdInList(extId uint64, extList *extnet.ListExtNets) bool {
|
||||
for _, ext := range extList.Data {
|
||||
if extId == ext.ID {
|
||||
return true
|
||||
}
|
||||
@@ -91,43 +95,35 @@ func existExtNetIdInList(extId uint64, extList extnet.ListExtNets) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func existVinsId(ctx context.Context, d *schema.ResourceData, m interface{}) (int, bool) {
|
||||
func existVinsId(ctx context.Context, m interface{}, id int) (int, bool) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.ListRequest{IncludeDeleted: false}
|
||||
|
||||
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
|
||||
if err != nil {
|
||||
log.Debugf("Unable to retrieve ViNS list, %s", err)
|
||||
return 0, false
|
||||
}
|
||||
|
||||
networks := d.Get("network").(*schema.Set).List()
|
||||
|
||||
for _, networkInterface := range networks {
|
||||
networkItem := networkInterface.(map[string]interface{})
|
||||
if !existVinsIdInList(uint64(networkItem["net_id"].(int)), vinsList) {
|
||||
return networkItem["net_id"].(int), false
|
||||
}
|
||||
if !existVinsIdInList(uint64(id), vinsList) {
|
||||
return id, false
|
||||
}
|
||||
|
||||
return 0, true
|
||||
}
|
||||
|
||||
func existExtNetId(ctx context.Context, d *schema.ResourceData, m interface{}) (int, bool) {
|
||||
func existExtNetId(ctx context.Context, m interface{}, id int) (int, bool) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := extnet.ListRequest{}
|
||||
|
||||
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
||||
if err != nil {
|
||||
log.Debugf("Unable to retrieve extnet list, %s", err)
|
||||
return 0, false
|
||||
}
|
||||
|
||||
networks := d.Get("network").(*schema.Set).List()
|
||||
|
||||
for _, networkInterface := range networks {
|
||||
networkItem := networkInterface.(map[string]interface{})
|
||||
if !existExtNetIdInList(uint64(networkItem["net_id"].(int)), extNetList) {
|
||||
return networkItem["net_id"].(int), false
|
||||
}
|
||||
if !existExtNetIdInList(uint64(id), extNetList) {
|
||||
return id, false
|
||||
}
|
||||
|
||||
return 0, true
|
||||
|
||||
@@ -4,6 +4,7 @@ Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
Tim Tkachev, <tvkachev@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -77,14 +78,22 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
||||
if networkData["net_type"].(string) == "VINS" {
|
||||
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
|
||||
}
|
||||
} else if networkData["net_type"].(string) == "EXTNET" {
|
||||
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
|
||||
networkList := network.(*schema.Set).List()
|
||||
for _, elem := range networkList {
|
||||
networkData := elem.(map[string]interface{})
|
||||
|
||||
switch networkData["net_type"].(string) {
|
||||
case "VINS":
|
||||
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
|
||||
}
|
||||
case "EXTNET":
|
||||
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
|
||||
}
|
||||
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,23 +128,30 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqPPC.IS = IS.(string)
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
ns := networks.(*schema.Set).List()
|
||||
defaultNetwork := ns[0].(map[string]interface{})
|
||||
|
||||
createReqPPC.NetType = defaultNetwork["net_type"].(string)
|
||||
createReqPPC.NetID = uint64(defaultNetwork["net_id"].(int))
|
||||
interfaces := make([]kvmx86.Interface, 0)
|
||||
for _, elem := range ns {
|
||||
netInterfaceVal := elem.(map[string]interface{})
|
||||
reqInterface := kvmx86.Interface{
|
||||
NetType: netInterfaceVal["net_type"].(string),
|
||||
NetID: uint64(netInterfaceVal["net_id"].(int)),
|
||||
}
|
||||
|
||||
createReqX86.NetType = defaultNetwork["net_type"].(string)
|
||||
createReqX86.NetID = uint64(defaultNetwork["net_id"].(int))
|
||||
ipaddr, ipSet := netInterfaceVal["ip_address"]
|
||||
if ipSet {
|
||||
reqInterface.IPAddr = ipaddr.(string)
|
||||
}
|
||||
|
||||
ipaddr, ipSet := defaultNetwork["ip_address"] // "ip_address" key is optional
|
||||
if ipSet {
|
||||
createReqPPC.IPAddr = ipaddr.(string)
|
||||
createReqX86.IPAddr = ipaddr.(string)
|
||||
interfaces = append(interfaces, reqInterface)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = interfaces
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +188,18 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.RAM = uint64(d.Get("ram").(int))
|
||||
createReqX86.ImageID = uint64(d.Get("image_id").(int))
|
||||
|
||||
createReqX86.Driver = driver
|
||||
|
||||
if custom_fields, ok := d.GetOk("custom_fields"); ok {
|
||||
val := custom_fields.(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
createReqX86.CustomFields = val
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||
if err != nil {
|
||||
@@ -206,23 +234,13 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
argVal, ok = d.GetOk("extra_disks")
|
||||
if ok && argVal.(*schema.Set).Len() > 0 {
|
||||
log.Debugf("resourceComputeCreate: calling utilityComputeExtraDisksConfigure to attach %d extra disk(s)", argVal.(*schema.Set).Len())
|
||||
err = utilityComputeExtraDisksConfigure(ctx, d, m, false)
|
||||
err = utilityComputeExtraDisksConfigure(ctx, d, m, false, nil)
|
||||
if err != nil {
|
||||
log.Errorf("resourceComputeCreate: error when attaching extra disk(s) to a new Compute ID %d: %v", computeId, err)
|
||||
cleanup = true
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
argVal, ok = d.GetOk("network")
|
||||
if ok && argVal.(*schema.Set).Len() > 0 {
|
||||
log.Debugf("resourceComputeCreate: calling utilityComputeNetworksConfigure to attach %d network(s)", argVal.(*schema.Set).Len())
|
||||
err = utilityComputeNetworksConfigure(ctx, d, m, false, true, computeId)
|
||||
if err != nil {
|
||||
log.Errorf("resourceComputeCreate: error when attaching networks to a new Compute ID %d: %s", computeId, err)
|
||||
cleanup = true
|
||||
return diag.FromErr(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
|
||||
@@ -237,13 +255,13 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
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", computeId, enabled)
|
||||
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", computeId, enabled)
|
||||
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)
|
||||
}
|
||||
@@ -476,7 +494,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
|
||||
d.Get("name").(string), d.Get("rg_id").(int))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -487,23 +505,24 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
|
||||
switch computeRec.Status {
|
||||
case status.Deleted:
|
||||
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
||||
enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
||||
// restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
||||
// enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
||||
|
||||
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceComputeCreate(ctx, d, m)
|
||||
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, troubles may occur with update. Please, enable compute first.", computeRec.Status)
|
||||
case status.Redeploying:
|
||||
@@ -557,14 +576,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
||||
if networkData["net_type"].(string) == "VINS" {
|
||||
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
||||
return diag.Errorf("resourceComputeUpdate: can't create update because vins ID %d is not allowed or does not exist", vinsId)
|
||||
}
|
||||
} else if networkData["net_type"].(string) == "EXTNET" {
|
||||
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
||||
return diag.Errorf("resourceComputeUpdate: can't create update because extnet ID %d is not allowed or does not exist", extNetId)
|
||||
networkList := network.(*schema.Set).List()
|
||||
for _, elem := range networkList {
|
||||
networkData := elem.(map[string]interface{})
|
||||
|
||||
switch networkData["net_type"].(string) {
|
||||
case "VINS":
|
||||
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
|
||||
}
|
||||
case "EXTNET":
|
||||
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
|
||||
}
|
||||
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,7 +641,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceComputeCreate(ctx, d, m)
|
||||
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:
|
||||
@@ -688,7 +716,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
if d.HasChange("extra_disks") {
|
||||
err := utilityComputeExtraDisksConfigure(ctx, d, m, true) // pass do_delta = true to apply changes, if any
|
||||
err := utilityComputeExtraDisksConfigure(ctx, d, m, true, computeRec.Disks) // pass do_delta = true to apply changes, if any
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@@ -727,7 +755,23 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
for _, el := range oldConv {
|
||||
if !isContainsDisk(newConv, el) {
|
||||
deletedDisks = append(deletedDisks, el)
|
||||
flag := false
|
||||
extraDisks := d.Get("extra_disks").(*schema.Set).List()
|
||||
delDisk := el.(map[string]interface{})
|
||||
delDiskId := delDisk["disk_id"].(int)
|
||||
|
||||
for _, extraDiskId := range extraDisks {
|
||||
if extraDiskId.(int) == delDiskId {
|
||||
flag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !flag {
|
||||
deletedDisks = append(deletedDisks, el)
|
||||
} else {
|
||||
log.Debugf("disk %d will not be deleted because it is present in the extra_disks block", delDiskId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +798,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
for _, disk := range deletedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -764,6 +808,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
Permanently: diskConv["permanently"].(bool),
|
||||
}
|
||||
|
||||
log.Debugf("trying to delete disk %d", req.DiskID)
|
||||
|
||||
_, err := c.CloudAPI().Compute().DiskDel(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -782,7 +828,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if len(addedDisks) > 0 {
|
||||
for _, disk := range addedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
continue
|
||||
}
|
||||
req := compute.DiskAddRequest{
|
||||
@@ -814,7 +860,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if len(updatedDisks) > 0 {
|
||||
for _, disk := range updatedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
continue
|
||||
}
|
||||
req := compute.DiskResizeRequest{
|
||||
@@ -1317,6 +1363,35 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("custom_fields") {
|
||||
val := d.Get("custom_fields").(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
if len(val) > 0 {
|
||||
req := compute.SetCustomFieldsRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
CustomFields: val,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().SetCustomFields(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
} else {
|
||||
req := compute.DeleteCustomFieldsRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().DeleteCustomFields(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||
// between Compute resource and Compute data source schemas
|
||||
defer resourceComputeRead(ctx, d, m)
|
||||
@@ -1537,58 +1612,50 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
|
||||
},
|
||||
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
// ForceNew: true,
|
||||
ValidateFunc: validation.IntAtLeast(1),
|
||||
Description: "ID of the resource group where this compute should be deployed.",
|
||||
},
|
||||
|
||||
"driver": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
// ForceNew: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
||||
Description: "Hardware architecture of this compute instance.",
|
||||
},
|
||||
|
||||
"cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
|
||||
Description: "Number of CPUs to allocate to this compute instance.",
|
||||
},
|
||||
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
|
||||
Description: "Amount of RAM in MB to allocate to this compute instance.",
|
||||
},
|
||||
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
//ForceNew: true, //REDEPLOY
|
||||
Description: "ID of the OS image to base this compute instance on.",
|
||||
},
|
||||
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||
},
|
||||
|
||||
"affinity_label": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Set affinity label for compute",
|
||||
},
|
||||
|
||||
"affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -1625,7 +1692,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"anti_affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -1662,7 +1728,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"disks": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -1670,6 +1735,17 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Schema: disksSubresourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"stateless": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
|
||||
},
|
||||
"boot_disk": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
@@ -1678,23 +1754,24 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
// ForceNew: true,
|
||||
Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
// ForceNew: true,
|
||||
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
|
||||
},
|
||||
|
||||
"extra_disks": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
MaxItems: constants.MaxExtraDisksPerCompute,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
@@ -1704,7 +1781,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
"network": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
MinItems: 1,
|
||||
MaxItems: constants.MaxNetworksPerCompute,
|
||||
@@ -1714,18 +1790,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
|
||||
/*
|
||||
"ssh_keys": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
MaxItems: MaxSshKeysPerCompute,
|
||||
Elem: &schema.Resource{
|
||||
Schema: sshSubresourceSchemaMake(),
|
||||
},
|
||||
Description: "SSH keys to authorize on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"tags": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
@@ -1858,7 +1922,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "compute purpose",
|
||||
},
|
||||
|
||||
// The rest are Compute properties, which are "computed" once it is created
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -1913,22 +1976,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"val": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -2085,7 +2132,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceCompute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CreateContext: resourceComputeCreate,
|
||||
ReadContext: resourceComputeRead,
|
||||
@@ -2105,5 +2152,17 @@ func ResourceCompute() *schema.Resource {
|
||||
},
|
||||
|
||||
Schema: ResourceComputeSchemaMake(),
|
||||
StateUpgraders: []schema.StateUpgrader{
|
||||
{
|
||||
Type: resourceComputeResourceV1().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceCompueteStateUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceComputeResourceV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceComputeStateUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
41
internal/service/cloudapi/kvmvm/state_upgraders.go
Normal file
41
internal/service/cloudapi/kvmvm/state_upgraders.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceCompueteStateUpgradeV1: upgrading state")
|
||||
customFields, ok := rawState["custom_fields"]
|
||||
if !ok || customFields == nil {
|
||||
rawState["custom_fields"] = "{}"
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
b := &strings.Builder{}
|
||||
b.WriteString("{")
|
||||
oldCustomFieldsSlice := customFields.([]interface{})
|
||||
for i := range oldCustomFieldsSlice {
|
||||
oldCustomFields := oldCustomFieldsSlice[i].(map[string]interface{})
|
||||
b.WriteString(fmt.Sprintf(`"%s":"%s"`, oldCustomFields["key"], oldCustomFields["val"]))
|
||||
if i < len(oldCustomFieldsSlice)-1 {
|
||||
b.WriteString(",")
|
||||
}
|
||||
}
|
||||
b.WriteString("}")
|
||||
rawState["custom_fields"] = b.String()
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
|
||||
|
||||
delete(rawState, "with_default_vins")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user