Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf8d3fb437 | ||
| d7a7eb9cb3 | |||
|
|
b60f32c570 | ||
| 272e385318 | |||
| f731cf246f | |||
| 6365f63fc1 | |||
| 85ce76564f | |||
| 928481d26f | |||
| 0e64974821 | |||
| 371bb0d90f | |||
| caf7213bca |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,4 +2,4 @@ decort/vendor/
|
|||||||
examples/
|
examples/
|
||||||
url_scrapping/
|
url_scrapping/
|
||||||
terraform-provider-decort*
|
terraform-provider-decort*
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,10 +1,5 @@
|
|||||||
## Version 4.0.2
|
## Version 4.3.2
|
||||||
|
|
||||||
## Features
|
## Bugfixes
|
||||||
- Added new data source decort_k8s_computes used to list all VMs in k8s cluster
|
- Fixed bootdisk flattens
|
||||||
- Added the ability to manipulate worker-groups inside resource decort_k8s
|
- Updated golang-decort-sdk version with fixed permamently field in cloudapi/cloudbroker/compute/diskDel
|
||||||
- Added new required field name to workers block
|
|
||||||
- Added new optional fields (labels, annotations, taints) to workers block
|
|
||||||
|
|
||||||
## Bug Fix
|
|
||||||
- Fixed incorrect state reading in resource decort_k8s
|
|
||||||
37
Makefile
37
Makefile
@@ -1,30 +1,32 @@
|
|||||||
TEST?=$$(go list ./... | grep -v 'vendor')
|
TEST?=$$(go list ./... | grep -v 'vendor')
|
||||||
HOSTNAME=digitalenergy.online
|
HOSTNAME=basis
|
||||||
NAMESPACE=decort
|
NAMESPACE=decort
|
||||||
NAME=terraform-provider-decort
|
NAME=terraform-provider-decort
|
||||||
BINDIR = ./bin
|
BINDIR = ./bin
|
||||||
ZIPDIR = ./zip
|
ZIPDIR = ./zip
|
||||||
#BINARY=terraform-provider-${NAME}
|
BINARY=${NAME}
|
||||||
BINARY=${NAME}.exe
|
|
||||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=4.0.2
|
VERSION=4.3.2
|
||||||
#OS_ARCH=darwin_amd64
|
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||||
OS_ARCH=windows_amd64
|
# OS_ARCH=darwin_arm64
|
||||||
#OS_ARCH=linux_amd64
|
# OS_ARCH=windows_amd64
|
||||||
|
# OS_ARCH=linux_amd64
|
||||||
|
|
||||||
FILES= ${BINARY}_${VERSION}_darwin_amd64\
|
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||||
|
${BINARY}_${VERSION}_darwin_arm64\
|
||||||
${BINARY}_${VERSION}_freebsd_386\
|
${BINARY}_${VERSION}_freebsd_386\
|
||||||
${BINARY}_${VERSION}_freebsd_amd64\
|
${BINARY}_${VERSION}_freebsd_amd64\
|
||||||
${BINARY}_${VERSION}_freebsd_arm\
|
${BINARY}_${VERSION}_freebsd_arm\
|
||||||
${BINARY}_${VERSION}_linux_386\
|
${BINARY}_${VERSION}_linux_386\
|
||||||
${BINARY}_${VERSION}_linux_amd64\
|
${BINARY}_${VERSION}_linux_amd64\
|
||||||
${BINARY}_${VERSION}_linux_arm\
|
${BINARY}_${VERSION}_linux_arm\
|
||||||
|
${BINARY}_${VERSION}_linux_arm64\
|
||||||
${BINARY}_${VERSION}_openbsd_386\
|
${BINARY}_${VERSION}_openbsd_386\
|
||||||
${BINARY}_${VERSION}_openbsd_amd64\
|
${BINARY}_${VERSION}_openbsd_amd64\
|
||||||
${BINARY}_${VERSION}_solaris_amd64\
|
${BINARY}_${VERSION}_solaris_amd64\
|
||||||
${BINARY}_${VERSION}_windows_386 \
|
${BINARY}_${VERSION}_windows_386.exe\
|
||||||
${BINARY}_${VERSION}_windows_amd64\
|
${BINARY}_${VERSION}_windows_amd64.exe\
|
||||||
|
|
||||||
BINS = $(addprefix bin/, $(FILES))
|
BINS = $(addprefix bin/, $(FILES))
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ release: $(FILES)
|
|||||||
|
|
||||||
$(FILES) : $(BINDIR) $(ZIPDIR) $(BINS)
|
$(FILES) : $(BINDIR) $(ZIPDIR) $(BINS)
|
||||||
zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@
|
zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@
|
||||||
|
zip -rj $(ZIPDIR)/$@.zip scripts/install.bat scripts/install.sh
|
||||||
|
|
||||||
$(BINDIR):
|
$(BINDIR):
|
||||||
mkdir $@
|
mkdir $@
|
||||||
@@ -59,25 +62,27 @@ $(ZIPDIR):
|
|||||||
|
|
||||||
$(BINS):
|
$(BINS):
|
||||||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 $(MAINPATH)
|
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=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=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 $(MAINPATH)
|
||||||
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm $(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=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=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=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=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 $(MAINPATH)
|
||||||
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(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=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=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386.exe $(MAINPATH)
|
||||||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 $(MAINPATH)
|
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64.exe $(MAINPATH)
|
||||||
|
|
||||||
install: build
|
install: build
|
||||||
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
||||||
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -i $(TEST) || exit 1
|
go test -i $(TEST) || exit 1
|
||||||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
||||||
|
|
||||||
testacc:
|
testacc:
|
||||||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
||||||
|
|||||||
177
README.md
177
README.md
@@ -6,7 +6,8 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
| Версия DECORT API | Версия провайдера Terraform |
|
| Версия DECORT API | Версия провайдера Terraform |
|
||||||
| ------ | ------ |
|
| ------ | ------ |
|
||||||
| 3.8.6 | 4.x.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.5 | 3.4.x |
|
||||||
| 3.8.0 - 3.8.4 | 3.3.1 |
|
| 3.8.0 - 3.8.4 | 3.3.1 |
|
||||||
| 3.7.x | rc-1.25 |
|
| 3.7.x | rc-1.25 |
|
||||||
@@ -33,9 +34,6 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
- Работа с pfw,
|
- Работа с pfw,
|
||||||
- Работа с accounts,
|
- Работа с accounts,
|
||||||
- Работа с snapshots,
|
- Работа с snapshots,
|
||||||
- Работа с pcidevice,
|
|
||||||
- Работа с sep,
|
|
||||||
- Работа с vgpu,
|
|
||||||
- Работа с bservice,
|
- Работа с bservice,
|
||||||
- Работа с extnets,
|
- Работа с extnets,
|
||||||
- Работа с locations,
|
- Работа с locations,
|
||||||
@@ -43,99 +41,125 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
|
||||||
## Начало
|
## Установка
|
||||||
|
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
||||||
Старт возможен по двум путям:
|
Чтобы выполнить установку, необходимо:
|
||||||
|
1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
|
||||||
1. Установка через собранные пакеты.
|
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
|
||||||
2. Ручная установка.
|
3. Скачать архив.
|
||||||
|
4. Распаковать архив.
|
||||||
### Установка через собранные пакеты.
|
5. Выполнить скрипт установщика, `install.sh` или `install.bat` для Windows.<br/>
|
||||||
|
*Для запуска `install.sh` не забудьте изменить права доступа к файлу*
|
||||||
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
```bash
|
||||||
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
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
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "oauth2"
|
authenticator = "oauth2"
|
||||||
#controller_url = <DECORT_CONTROLLER_URL>
|
controller_url = "https://mr4.digitalenergy.online"
|
||||||
controller_url = "https://ds1.digitalenergy.online"
|
|
||||||
#oauth2_url = <DECORT_SSO_URL>
|
|
||||||
oauth2_url = "https://sso.digitalenergy.online"
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Выполните команду
|
10. В консоли выполните команду
|
||||||
|
```bash
|
||||||
```
|
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
|
|
||||||
Провайдер автоматически будет установлен на ваш компьютер из terraform registry.
|
11. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
|
||||||
|
|
||||||
### Ручная установка
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
|
## Установка из релизов
|
||||||
|
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
|
```bash
|
||||||
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
|
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
|
||||||
```
|
```
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
|
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
|
||||||
```
|
```
|
||||||
|
|
||||||
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
|
|
||||||
Где:
|
Где:
|
||||||
|
- host_name - имя хоста, держателя провайдера, например, basis
|
||||||
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online
|
- namespace - пространство имен хоста, например decort
|
||||||
- namespace - пространство имен хоста, например decort
|
|
||||||
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
||||||
- version - версия провайдера, например 1.2
|
- version - версия провайдера, например 4.3.0
|
||||||
- target - версия ОС, например windows_amd64
|
- target - архитектура операционной системы, например windows_amd64
|
||||||
|
|
||||||
6. После этого, создайте файл `main.tf`.
|
В примере ниже используется путь до провайдера на машине с ОС Linux:
|
||||||
7. Добавьте в него следующий блок
|
|
||||||
|
|
||||||
|
```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
|
||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
decort = {
|
decort = {
|
||||||
version = "1.2"
|
version = "4.3.0"
|
||||||
source = "digitalenergy.online/decort/decort"
|
source = "basis/decort/decort"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
В поле `version` указывается версия провайдера.
|
||||||
В поле `version` указывается версия провайдера.
|
<br/>
|
||||||
Обязательный параметр
|
**ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
|
||||||
Тип поля - строка
|
|
||||||
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
|
|
||||||
|
|
||||||
В поле `source` помещается путь до репозитория с версией вида:
|
В поле `source` помещается путь до репозитория с версией вида:
|
||||||
|
|
||||||
@@ -143,17 +167,24 @@ terraform {
|
|||||||
${host_name}/${namespace}/${type}
|
${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
|
```bash
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
|
|
||||||
9. Если все прошло хорошо - ошибок не будет.
|
10. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
|
||||||
|
|
||||||
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
|
||||||
|
|
||||||
## Примеры работы
|
## Примеры работы
|
||||||
|
|
||||||
@@ -162,8 +193,4 @@ terraform init
|
|||||||
- На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
- На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
- В папке `samples`
|
- В папке `samples`
|
||||||
|
|
||||||
Схемы к terraform'у доступны:
|
|
||||||
|
|
||||||
- В папке `docs`
|
|
||||||
|
|
||||||
Хорошей работы!
|
Хорошей работы!
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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-docs v0.13.0
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
golang.org/x/net v0.5.0
|
golang.org/x/net v0.12.0
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -21,9 +21,10 @@ require (
|
|||||||
github.com/armon/go-radix v1.0.0 // indirect
|
github.com/armon/go-radix v1.0.0 // indirect
|
||||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||||
github.com/fatih/color v1.13.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/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.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.14.1 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-cmp v0.5.9 // indirect
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // 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/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/huandu/xstrings v1.4.0 // indirect
|
github.com/huandu/xstrings v1.4.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.13 // 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-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||||
github.com/mitchellh/cli v1.1.5 // 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/msgpack/v4 v4.3.12 // indirect
|
||||||
github.com/vmihailenco/tagparser v0.1.2 // indirect
|
github.com/vmihailenco/tagparser v0.1.2 // indirect
|
||||||
github.com/zclconf/go-cty v1.12.1 // indirect
|
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||||
golang.org/x/crypto v0.5.0 // indirect
|
golang.org/x/crypto v0.11.0 // indirect
|
||||||
golang.org/x/sys v0.4.0 // indirect
|
golang.org/x/sys v0.10.0 // indirect
|
||||||
golang.org/x/text v0.6.0 // indirect
|
golang.org/x/text v0.11.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
|
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
|
||||||
google.golang.org/grpc v1.51.0 // 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/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/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
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/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 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
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/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 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
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.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
|
||||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
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 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
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/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 v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
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.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
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/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.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
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.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||||
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
|
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/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 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
|
||||||
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
|
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
|
||||||
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
|
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/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.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.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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
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.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.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.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.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.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 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 h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
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-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.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.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.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
||||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
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-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/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-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.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.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
|
||||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
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-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/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-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.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.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.10.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-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.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
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.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.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.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.11.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-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.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
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.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3 h1:jrBl90lRfp34bE3m30N3mYIDTSlaPySuo+pE7bK4eOI=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3 h1:Rt5tE4EZcUr4ONK9u/XYe2mG1CC37xLUnNuCLYKDwYs=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3/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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -30,7 +29,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
// "time"
|
// "time"
|
||||||
|
|
||||||
@@ -158,7 +156,6 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
Username: ret_config.legacy_user,
|
Username: ret_config.legacy_user,
|
||||||
Password: ret_config.legacy_password,
|
Password: ret_config.legacy_password,
|
||||||
DecortURL: ret_config.controller_url,
|
DecortURL: ret_config.controller_url,
|
||||||
Retries: 0,
|
|
||||||
SSLSkipVerify: allow_unverified_ssl,
|
SSLSkipVerify: allow_unverified_ssl,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,82 +371,3 @@ func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
|||||||
client, _ := config.caller.(*decort.DecortClient)
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
return client.CloudBroker()
|
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
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(locList) == 0 {
|
if len(locList.Data) == 0 {
|
||||||
DefaultGridID = 0
|
DefaultGridID = 0
|
||||||
return 0, fmt.Errorf("utilityLocationGetDefaultGridID: retrieved 0 length locations list")
|
return 0, fmt.Errorf("utilityLocationGetDefaultGridID: retrieved 0 length locations list")
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultGridID = int(locList[0].GID)
|
DefaultGridID = int(locList.Data[0].GID)
|
||||||
log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList[0].Name)
|
log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList.Data[0].Name)
|
||||||
|
|
||||||
return DefaultGridID, nil
|
return DefaultGridID, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
@@ -37,6 +38,7 @@ import (
|
|||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
@@ -64,6 +66,7 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||||
|
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||||
@@ -119,6 +122,8 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_lb": lb.DataSourceLB(),
|
"decort_lb": lb.DataSourceLB(),
|
||||||
"decort_lb_list": lb.DataSourceLBList(),
|
"decort_lb_list": lb.DataSourceLBList(),
|
||||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||||
|
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||||
|
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||||
|
|
||||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||||
@@ -129,6 +134,9 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
"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": cb_disks.DataSourceDisk(),
|
||||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||||
"decort_cb_image": cb_image.DataSourceImage(),
|
"decort_cb_image": cb_image.DataSourceImage(),
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
@@ -36,6 +37,7 @@ import (
|
|||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
@@ -57,6 +59,7 @@ func newResourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_pfw": pfw.ResourcePfw(),
|
"decort_pfw": pfw.ResourcePfw(),
|
||||||
"decort_k8s": k8s.ResourceK8s(),
|
"decort_k8s": k8s.ResourceK8s(),
|
||||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||||
|
"decort_k8s_cp": k8s.ResourceK8sCP(),
|
||||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||||
"decort_account": account.ResourceAccount(),
|
"decort_account": account.ResourceAccount(),
|
||||||
"decort_bservice": bservice.ResourceBasicService(),
|
"decort_bservice": bservice.ResourceBasicService(),
|
||||||
@@ -68,22 +71,24 @@ func newResourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
||||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||||
|
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||||
|
|
||||||
"decort_cb_account": cb_account.ResourceAccount(),
|
"decort_cb_account": cb_account.ResourceAccount(),
|
||||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
||||||
"decort_cb_image": cb_image.ResourceImage(),
|
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||||
"decort_cb_virtual_image":cb_image.ResourceVirtualImage(),
|
"decort_cb_image": cb_image.ResourceImage(),
|
||||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||||
"decort_cb_delete_images":cb_image.ResourceDeleteImages(),
|
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
"decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
||||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||||
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
||||||
"decort_cb_vins": cb_vins.ResourceVins(),
|
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||||
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||||
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
||||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
||||||
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||||
|
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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 {
|
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -268,13 +269,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"resources": {
|
// "resources": {
|
||||||
Type: schema.TypeList,
|
// Type: schema.TypeList,
|
||||||
Computed: true,
|
// Computed: true,
|
||||||
Elem: &schema.Resource{
|
// Elem: &schema.Resource{
|
||||||
Schema: resourcesSchemaMake(),
|
// Schema: resourcesSchemaMake(),
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
"ckey": {
|
"ckey": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, acc := range acl {
|
for _, acc := range acl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": acc.AccountID,
|
"account_id": acc.AccountID,
|
||||||
"account_name": acc.AccountName,
|
"account_name": acc.AccountName,
|
||||||
@@ -82,6 +82,7 @@ func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceDa
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountComputesList(accountComputesList))
|
d.Set("items", flattenAccountComputesList(accountComputesList))
|
||||||
|
d.Set("entry_count", accountComputesList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -93,6 +94,56 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -182,6 +233,10 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,17 @@ func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceDat
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountList(accountDeletedList))
|
d.Set("items", flattenAccountList(accountDeletedList))
|
||||||
|
d.Set("entry_count", accountDeletedList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
|
||||||
|
temp := dataSourceAccountListSchemaMake()
|
||||||
|
delete(temp, "status")
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
func DataSourceAccountDeletedList() *schema.Resource {
|
func DataSourceAccountDeletedList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
@@ -65,6 +72,6 @@ func DataSourceAccountDeletedList() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountListSchemaMake(),
|
Schema: dataSourceAccountDeletedListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, ad := range adl {
|
for _, ad := range adl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"disk_id": ad.ID,
|
"disk_id": ad.ID,
|
||||||
"disk_name": ad.Name,
|
"disk_name": ad.Name,
|
||||||
@@ -68,6 +68,7 @@ func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData,
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountDisksList(accountDisksList))
|
d.Set("items", flattenAccountDisksList(accountDisksList))
|
||||||
|
d.Set("entry_count", accountDisksList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -79,6 +80,36 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -116,6 +147,10 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, afg := range afgl {
|
for _, afg := range afgl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": afg.AccountID,
|
"account_id": afg.AccountID,
|
||||||
"client_type": afg.ClientType,
|
"client_type": afg.ClientType,
|
||||||
@@ -83,6 +83,7 @@ func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.Resource
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
||||||
|
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -94,6 +95,46 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -187,6 +228,10 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, acc := range al {
|
for _, acc := range al.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"acl": flattenRgAcl(acc.ACL),
|
"acl": flattenRgAcl(acc.ACL),
|
||||||
"created_time": acc.CreatedTime,
|
"created_time": acc.CreatedTime,
|
||||||
@@ -84,12 +84,33 @@ func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountList(accountList))
|
d.Set("items", flattenAccountList(accountList))
|
||||||
|
d.Set("entry_count", accountList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -164,6 +185,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, arg := range argl {
|
for _, arg := range argl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"computes": flattenAccRGComputes(arg.Computes),
|
"computes": flattenAccRGComputes(arg.Computes),
|
||||||
"resources": flattenAccRGResources(arg.Resources),
|
"resources": flattenAccRGResources(arg.Resources),
|
||||||
@@ -125,6 +125,7 @@ func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountRGList(accountRGList))
|
d.Set("items", flattenAccountRGList(accountRGList))
|
||||||
|
d.Set("entry_count", accountRGList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -136,6 +137,41 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -311,6 +347,10 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountTemplatesList(atl account.ListTemplates) []map[string]interface{} {
|
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, at := range atl {
|
for _, at := range atl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"unc_path": at.UNCPath,
|
"unc_path": at.UNCPath,
|
||||||
"account_id": at.AccountID,
|
"account_id": at.AccountID,
|
||||||
@@ -83,6 +83,10 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
Description: "ID of the account",
|
||||||
},
|
},
|
||||||
|
"include_deleted": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, av := range avl {
|
for _, av := range avl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": av.AccountID,
|
"account_id": av.AccountID,
|
||||||
"account_name": av.AccountName,
|
"account_name": av.AccountName,
|
||||||
@@ -79,6 +79,7 @@ func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData,
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountVinsList(accountVinsList))
|
d.Set("items", flattenAccountVinsList(accountVinsList))
|
||||||
|
d.Set("entry_count", accountVinsList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -90,6 +91,36 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the account",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -167,6 +198,10 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
||||||
d.Set("dc_location", acc.DCLocation)
|
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("ckey", acc.CKey)
|
||||||
d.Set("acl", flattenAccAcl(acc.ACL))
|
d.Set("acl", flattenAccAcl(acc.ACL))
|
||||||
d.Set("company", acc.Company)
|
d.Set("company", acc.Company)
|
||||||
@@ -95,15 +95,15 @@ func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{}
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenAccResources(r account.Resources) []map[string]interface{} {
|
// func flattenAccResources(r account.Resources) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
// res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
// temp := map[string]interface{}{
|
||||||
"current": flattenAccResource(r.Current),
|
// "current": flattenAccResource(r.Current),
|
||||||
"reserved": flattenAccResource(r.Reserved),
|
// "reserved": flattenAccResource(r.Reserved),
|
||||||
}
|
// }
|
||||||
res = append(res, temp)
|
// res = append(res, temp)
|
||||||
return res
|
// return res
|
||||||
}
|
// }
|
||||||
|
|
||||||
func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} {
|
func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
|
|||||||
@@ -47,129 +47,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceAccountCreate")
|
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")
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -629,13 +508,13 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"resources": {
|
// "resources": {
|
||||||
Type: schema.TypeList,
|
// Type: schema.TypeList,
|
||||||
Computed: true,
|
// Computed: true,
|
||||||
Elem: &schema.Resource{
|
// Elem: &schema.Resource{
|
||||||
Schema: resourcesSchemaMake(),
|
// Schema: resourcesSchemaMake(),
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
"ckey": {
|
"ckey": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -52,6 +52,46 @@ func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.Reso
|
|||||||
AccountID: id,
|
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")
|
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
|
||||||
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
|
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -42,23 +42,29 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var (
|
|
||||||
pageVal uint64 = 0
|
req := account.ListDeletedRequest{}
|
||||||
sizeVal uint64 = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
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 := account.ListDeletedRequest{
|
if size, ok := d.GetOk("size"); ok {
|
||||||
Page: pageVal,
|
req.Size = uint64(size.(int))
|
||||||
Size: sizeVal,
|
}
|
||||||
|
|
||||||
|
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")
|
log.Debugf("utilityAccountDeletedListCheckPresence: load")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -51,6 +51,30 @@ func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.Resourc
|
|||||||
AccountID: id,
|
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)
|
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -52,6 +52,38 @@ func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.Re
|
|||||||
AccountID: id,
|
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")
|
log.Debugf("utilityAccountFlipGroupsListCheckPresence")
|
||||||
accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req)
|
accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -42,23 +42,31 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var (
|
req := account.ListRequest{}
|
||||||
pageVal uint64 = 0
|
|
||||||
sizeVal uint64 = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
pageVal = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
sizeVal = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
req := account.ListRequest{
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
Page: pageVal,
|
req.ByID = uint64(by_id.(int))
|
||||||
Size: sizeVal,
|
}
|
||||||
|
|
||||||
|
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")
|
log.Debugf("utilityAccountListCheckPresence: load account list")
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -52,6 +52,34 @@ func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceDa
|
|||||||
AccountID: id,
|
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")
|
log.Debugf("utilityAccountRGListCheckPresence: load account list")
|
||||||
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
|
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -52,6 +52,10 @@ func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.Res
|
|||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
||||||
|
req.IncludeDeleted = include_deleted.(bool)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
||||||
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
@@ -52,6 +52,30 @@ func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.Resource
|
|||||||
AccountID: id,
|
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")
|
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
|
||||||
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
|
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -50,10 +50,24 @@ func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.Resour
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
|
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
|
||||||
|
d.Set("entry_count", basicServiceDeletedList.EntryCount)
|
||||||
|
|
||||||
return nil
|
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 {
|
func DataSourceBasicServiceDeletedList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
@@ -65,6 +79,6 @@ func DataSourceBasicServiceDeletedList() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceBasicServiceListSchemaMake(),
|
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, bs := range bsl {
|
for _, bs := range bsl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": bs.AccountID,
|
"account_id": bs.AccountID,
|
||||||
"account_name": bs.AccountName,
|
"account_name": bs.AccountName,
|
||||||
@@ -83,12 +83,43 @@ func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData,
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenBasicServiceList(basicServiceList))
|
d.Set("items", flattenBasicServiceList(basicServiceList))
|
||||||
|
d.Set("entry_count", basicServiceList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -208,6 +239,10 @@ func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,5 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
|||||||
|
|
||||||
rgId := uint64(d.Get("rg_id").(int))
|
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"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := bservice.ListRequest{}
|
req := bservice.ListDeletedRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := bservice.ListRequest{}
|
req := bservice.ListRequest{}
|
||||||
|
|
||||||
@@ -59,6 +59,30 @@ func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.Resourc
|
|||||||
req.Size = uint64(size.(int))
|
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")
|
log.Debugf("utilityBasicServiceListCheckPresence")
|
||||||
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
|
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -50,12 +50,43 @@ func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenDiskList(diskList))
|
d.Set("items", flattenDiskList(diskList))
|
||||||
|
d.Set("entry_count", diskList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -434,6 +465,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,13 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, typeListDetailed := range tld {
|
for _, typeListDetailed := range tld.Data {
|
||||||
toMap := typeListDetailed.(map[string]interface{})
|
toMap := typeListDetailed.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceDat
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenDiskListUnattached(diskListUnattached))
|
d.Set("items", flattenDiskListUnattached(diskListUnattached))
|
||||||
|
d.Set("entry_count", diskListUnattached.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -71,12 +72,46 @@ func DataSourceDiskListUnattached() *schema.Resource {
|
|||||||
|
|
||||||
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "ID of the account the disks belong to",
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -401,6 +436,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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 {
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -50,10 +51,424 @@ func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData,
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenDiskList(diskList))
|
d.Set("items", flattenDiskList(diskList))
|
||||||
|
d.Set("entry_count", diskList.EntryCount)
|
||||||
|
|
||||||
return nil
|
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 {
|
func DataSourceDiskListDeleted() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
@@ -64,6 +479,6 @@ func DataSourceDiskListDeleted() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
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)
|
d.Set("snap_set_time", snapshot.SnapSetTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interface{} {
|
func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, unattachedDisk := range ul {
|
for _, unattachedDisk := range ul.Data {
|
||||||
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
|
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
|
||||||
tmp := map[string]interface{}{
|
tmp := map[string]interface{}{
|
||||||
"_ckey": unattachedDisk.CKey,
|
"_ckey": unattachedDisk.CKey,
|
||||||
@@ -136,9 +136,9 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenDiskList(dl disks.ListDisks) []map[string]interface{} {
|
func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, disk := range dl {
|
for _, disk := range dl.Data {
|
||||||
diskAcl, _ := json.Marshal(disk.ACL)
|
diskAcl, _ := json.Marshal(disk.ACL)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": disk.AccountID,
|
"account_id": disk.AccountID,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
return false, err
|
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) {
|
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 false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(locationList.FilterByGID(gid)) != 0, nil
|
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := disks.ListRequest{}
|
req := disks.ListRequest{}
|
||||||
|
|
||||||
@@ -59,6 +59,24 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
if accountId, ok := d.GetOk("accountId"); ok {
|
if accountId, ok := d.GetOk("accountId"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
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 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)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
||||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
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,31 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := disks.ListUnattachedRequest{}
|
req := disks.ListUnattachedRequest{}
|
||||||
|
|
||||||
|
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 accountId, ok := d.GetOk("accountId"); ok {
|
if accountId, ok := d.GetOk("accountId"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
||||||
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := disks.ListTypesRequest{
|
req := disks.ListTypesRequest{
|
||||||
Detailed: true,
|
Detailed: true,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := disks.ListTypesRequest{
|
req := disks.ListTypesRequest{
|
||||||
Detailed: false,
|
Detailed: false,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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",
|
Description: "meta",
|
||||||
},
|
},
|
||||||
"check__ips": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"check_ips": {
|
"check_ips": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenExtnetList(extnetList))
|
d.Set("items", flattenExtnetList(extnetList))
|
||||||
|
d.Set("entry_count", extnetList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,36 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
|||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
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": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -91,6 +121,10 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import (
|
|||||||
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
||||||
d.Set("ckey", e.CKey)
|
d.Set("ckey", e.CKey)
|
||||||
d.Set("meta", flattens.FlattenMeta(e.Meta))
|
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", e.Default)
|
||||||
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
|
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
|
||||||
d.Set("desc", e.Description)
|
d.Set("desc", e.Description)
|
||||||
@@ -106,9 +105,9 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]interface{} {
|
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, ec := range ecl {
|
for _, ec := range ecl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": ec.AccountID,
|
"account_id": ec.AccountID,
|
||||||
"account_name": ec.AccountName,
|
"account_name": ec.AccountName,
|
||||||
@@ -123,9 +122,9 @@ func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]inter
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetList(el extnet.ListExtNets) []map[string]interface{} {
|
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, e := range el {
|
for _, e := range el.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"net_id": e.ID,
|
"net_id": e.ID,
|
||||||
"ipcidr": e.IPCIDR,
|
"ipcidr": e.IPCIDR,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := extnet.ListComputesRequest{
|
req := extnet.ListComputesRequest{
|
||||||
AccountID: uint64(d.Get("account_id").(int)),
|
AccountID: uint64(d.Get("account_id").(int)),
|
||||||
|
|||||||
@@ -42,13 +42,31 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := extnet.ListRequest{}
|
req := extnet.ListRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
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 {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
152
internal/service/cloudapi/flipgroup/data_source_flipgroup.go
Normal file
152
internal/service/cloudapi/flipgroup/data_source_flipgroup.go
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
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 flipgroup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"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 dataSourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenFlipgroup(d, fg)
|
||||||
|
d.SetId(fmt.Sprint(fg.ID))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"flipgroup_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Flipgroupd ID",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"client_ids": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"client_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceFlipgroup() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceFlipgroupRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout180s,
|
||||||
|
Default: &constants.Timeout180s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceFlipgroupSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
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 flipgroup
|
||||||
|
|
||||||
|
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 dataSourceFlipgroupList(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
fg_list, err := utilityFlipgroupListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
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,
|
||||||
|
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{
|
||||||
|
"flipgroup_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"client_ids": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"client_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceFlipGroupList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceFlipgroupList,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout180s,
|
||||||
|
Default: &constants.Timeout180s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceFlipgroupListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
85
internal/service/cloudapi/flipgroup/flattens.go
Normal file
85
internal/service/cloudapi/flipgroup/flattens.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
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 flipgroup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
||||||
|
d.Set("account_id", fg.AccountID)
|
||||||
|
d.Set("client_ids", fg.ClientIDs)
|
||||||
|
d.Set("client_type", fg.ClientType)
|
||||||
|
d.Set("conn_id", fg.ConnID)
|
||||||
|
d.Set("conn_type", fg.ConnType)
|
||||||
|
d.Set("default_gw", fg.DefaultGW)
|
||||||
|
d.Set("desc", fg.Description)
|
||||||
|
d.Set("gid", fg.GID)
|
||||||
|
d.Set("guid", fg.GUID)
|
||||||
|
d.Set("flipgroup_id", fg.ID)
|
||||||
|
d.Set("ip", fg.IP)
|
||||||
|
d.Set("milestones", fg.Milestones)
|
||||||
|
d.Set("name", fg.Name)
|
||||||
|
d.Set("net_id", fg.NetID)
|
||||||
|
d.Set("net_type", fg.NetType)
|
||||||
|
d.Set("status", fg.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, fg := range fg_list.Data {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"account_id": fg.AccountID,
|
||||||
|
"client_ids": fg.ClientIDs,
|
||||||
|
"client_type": fg.ClientType,
|
||||||
|
"conn_id": fg.ConnID,
|
||||||
|
"conn_type": fg.ConnType,
|
||||||
|
"default_gw": fg.DefaultGW,
|
||||||
|
"desc": fg.Description,
|
||||||
|
"gid": fg.GID,
|
||||||
|
"guid": fg.GUID,
|
||||||
|
"flipgroup_id": fg.ID,
|
||||||
|
"ip": fg.IP,
|
||||||
|
"milestones": fg.Milestones,
|
||||||
|
"name": fg.Name,
|
||||||
|
"net_id": fg.NetID,
|
||||||
|
"net_type": fg.NetType,
|
||||||
|
"status": fg.Status,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
270
internal/service/cloudapi/flipgroup/resource_flipgroup.go
Normal file
270
internal/service/cloudapi/flipgroup/resource_flipgroup.go
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
/*
|
||||||
|
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 flipgroup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceFlipgroupCreate called with name: %s, accountID %v", d.Get("name").(string), d.Get("account_id").(int))
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
req := flipgroup.CreateRequest{
|
||||||
|
AccountID: uint64(d.Get("account_id").(int)),
|
||||||
|
Name: d.Get("name").(string),
|
||||||
|
NetType: d.Get("net_type").(string),
|
||||||
|
NetID: uint64(d.Get("net_id").(int)),
|
||||||
|
ClientType: d.Get("client_type").(string),
|
||||||
|
IP: d.Get("ip").(string),
|
||||||
|
Description: d.Get("desc").(string),
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(fmt.Sprint(resp.ID))
|
||||||
|
|
||||||
|
var warnings dc.Warnings
|
||||||
|
|
||||||
|
if client_ids, ok := d.GetOk("client_ids"); ok {
|
||||||
|
casted := client_ids.([]interface{})
|
||||||
|
addComputesAfterCreation(ctx, &warnings, c, casted, resp.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resourceFlipgroupRead(ctx, d, m)
|
||||||
|
return warnings.Get()
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenFlipgroup(d, fg)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceFlipgroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceFlipgroupUpdate called with id: %v", d.Get("flipgroup_id").(int))
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var warnings dc.Warnings
|
||||||
|
basicUpdate := false
|
||||||
|
req := flipgroup.EditRequest{FLIPGroupID: fg.ID}
|
||||||
|
|
||||||
|
if d.HasChange("desc") {
|
||||||
|
req.Description = d.Get("desc").(string)
|
||||||
|
basicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("name") {
|
||||||
|
req.Name = d.Get("name").(string)
|
||||||
|
basicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if basicUpdate {
|
||||||
|
_, err := c.CloudAPI().FLIPGroup().Edit(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("client_ids") {
|
||||||
|
handleClientIDsUpdate(ctx, d, c, fg, &warnings)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resourceFlipgroupRead(ctx, d, m)
|
||||||
|
return warnings.Get()
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceFlipgroupDelete called with id: %v", d.Get("flipgroup_id").(int))
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := flipgroup.DeleteRequest{
|
||||||
|
FLIPGroupID: fg.ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().FLIPGroup().Delete(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Account ID",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Flipgroup name",
|
||||||
|
},
|
||||||
|
"net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "EXTNET or ViNS ID",
|
||||||
|
},
|
||||||
|
"net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, true),
|
||||||
|
Description: "Network type, EXTNET or VINS",
|
||||||
|
},
|
||||||
|
"client_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Type of client, 'compute' ('vins' will be later)",
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"compute"}, true),
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP address to associate with this group. If empty, the platform will autoselect IP address",
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Text description of this Flipgroup instance",
|
||||||
|
},
|
||||||
|
"client_ids": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "List of clients attached to this Flipgroup instance",
|
||||||
|
},
|
||||||
|
"flipgroup_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceFlipgroup() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
CreateContext: resourceFlipgroupCreate,
|
||||||
|
ReadContext: resourceFlipgroupRead,
|
||||||
|
UpdateContext: resourceFlipgroupUpdate,
|
||||||
|
DeleteContext: resourceFlipgroupDelete,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout300s,
|
||||||
|
Read: &constants.Timeout300s,
|
||||||
|
Update: &constants.Timeout300s,
|
||||||
|
Delete: &constants.Timeout300s,
|
||||||
|
Default: &constants.Timeout300s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: resourceFlipgroupSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
195
internal/service/cloudapi/flipgroup/utility_flipgroup.go
Normal file
195
internal/service/cloudapi/flipgroup/utility_flipgroup.go
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
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 flipgroup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
old_set, new_set := d.GetChange("client_ids")
|
||||||
|
oldSlice := old_set.([]interface{})
|
||||||
|
newSlice := new_set.([]interface{})
|
||||||
|
|
||||||
|
for _, oldElem := range oldSlice {
|
||||||
|
if !containsClient(newSlice, oldElem) {
|
||||||
|
removedClients = append(removedClients, oldElem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, newElem := range newSlice {
|
||||||
|
if !containsClient(oldSlice, newElem) {
|
||||||
|
addedClients = append(addedClients, newElem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Found client_ids change with %v deletion(s) and %v addition(s) [flipgroupID=%v]", len(removedClients), len(addedClients), fg.ID)
|
||||||
|
|
||||||
|
if len(addedClients) > 0 {
|
||||||
|
for _, id := range addedClients {
|
||||||
|
req := flipgroup.ComputeAddRequest{
|
||||||
|
FLIPGroupID: fg.ID,
|
||||||
|
ComputeID: uint64(id.(int)),
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req); err != nil {
|
||||||
|
warn.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(removedClients) > 0 {
|
||||||
|
for _, id := range removedClients {
|
||||||
|
req := flipgroup.ComputeRemoveRequest{
|
||||||
|
FLIPGroupID: fg.ID,
|
||||||
|
ComputeID: uint64(id.(int)),
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := c.CloudAPI().FLIPGroup().ComputeRemove(ctx, req); err != nil {
|
||||||
|
warn.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func containsClient(set []interface{}, check interface{}) bool {
|
||||||
|
for _, elem := range set {
|
||||||
|
elemConv := elem.(int)
|
||||||
|
checkConv := check.(int)
|
||||||
|
if elemConv == checkConv {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func addComputesAfterCreation(ctx context.Context, warnings *dc.Warnings, c *controller.ControllerCfg, compute_ids []interface{}, flipgroupID uint64) {
|
||||||
|
if len(compute_ids) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Adding %v computes to flipgroup [id=%v]...", len(compute_ids), flipgroupID)
|
||||||
|
|
||||||
|
for _, elem := range compute_ids {
|
||||||
|
compute_id := uint64(elem.(int))
|
||||||
|
req := flipgroup.ComputeAddRequest{
|
||||||
|
FLIPGroupID: flipgroupID,
|
||||||
|
ComputeID: compute_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.RecordFLIPGroup, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
req := flipgroup.GetRequest{}
|
||||||
|
|
||||||
|
if d.Id() == "" {
|
||||||
|
req.FLIPGroupID = uint64(d.Get("flipgroup_id").(int))
|
||||||
|
} else {
|
||||||
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
|
req.FLIPGroupID = id
|
||||||
|
}
|
||||||
|
|
||||||
|
fg, err := c.CloudAPI().FLIPGroup().Get(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fg, err
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
fg_list, err := c.CloudAPI().FLIPGroup().List(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fg_list, err
|
||||||
|
}
|
||||||
@@ -49,16 +49,72 @@ func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenImageList(imageList))
|
d.Set("items", flattenImageList(imageList))
|
||||||
|
d.Set("entry_count", imageList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"account_id": {
|
"sep_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
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": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -78,6 +134,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: dataSourceImageSchemaMake(),
|
Schema: dataSourceImageSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return rets
|
return rets
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
|||||||
d.Set("version", img.Version)
|
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)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, img := range il {
|
for _, img := range il.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": img.AccountID,
|
"account_id": img.AccountID,
|
||||||
"architecture": img.Architecture,
|
"architecture": img.Architecture,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
return false, err
|
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) {
|
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 false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(locationList.FilterByGID(gid)) != 0, nil
|
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,56 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListRequest{}
|
req := image.ListRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if sep_id, ok := d.GetOk("sep_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
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 {
|
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>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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{}
|
curK8s := k8s.ItemK8SCluster{}
|
||||||
for _, k8sCluster := range k8sList {
|
for _, k8sCluster := range k8sList.Data {
|
||||||
if k8sCluster.ID == cluster.ID {
|
if k8sCluster.ID == cluster.ID {
|
||||||
curK8s = k8sCluster
|
curK8s = k8sCluster
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,46 @@ func k8sWorkersGroupsSchemaMake() map[string]*schema.Schema {
|
|||||||
|
|
||||||
func createK8sListSchema() map[string]*schema.Schema {
|
func createK8sListSchema() map[string]*schema.Schema {
|
||||||
return 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": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -276,6 +316,10 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,38 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
|
|||||||
package k8s
|
package k8s
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
"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"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func flattenK8CIItems(list *k8ci.ListK8CI) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
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) {
|
func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
||||||
d.Set("k8s_id", cluster.ID)
|
d.Set("k8s_id", cluster.ID)
|
||||||
d.Set("masters", flattenMasterComputes(cluster))
|
d.Set("masters", flattenMasterComputes(cluster))
|
||||||
@@ -168,6 +195,14 @@ func flattenMasterGroup(mastersGroup k8s.MasterGroup, masters []compute.RecordCo
|
|||||||
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
|
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, k8sGroup := range k8SGroupList {
|
for _, k8sGroup := range k8SGroupList {
|
||||||
|
labels := make([]string, 0)
|
||||||
|
for _, label := range k8sGroup.Labels {
|
||||||
|
if strings.HasPrefix(label, "workersGroupName") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
labels = append(labels, label)
|
||||||
|
}
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"annotations": k8sGroup.Annotations,
|
"annotations": k8sGroup.Annotations,
|
||||||
"cpu": k8sGroup.CPU,
|
"cpu": k8sGroup.CPU,
|
||||||
@@ -175,7 +210,7 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
|
|||||||
"disk": k8sGroup.Disk,
|
"disk": k8sGroup.Disk,
|
||||||
"guid": k8sGroup.GUID,
|
"guid": k8sGroup.GUID,
|
||||||
"id": k8sGroup.ID,
|
"id": k8sGroup.ID,
|
||||||
"labels": k8sGroup.Labels,
|
"labels": labels,
|
||||||
"name": k8sGroup.Name,
|
"name": k8sGroup.Name,
|
||||||
"num": k8sGroup.Num,
|
"num": k8sGroup.Num,
|
||||||
"ram": k8sGroup.RAM,
|
"ram": k8sGroup.RAM,
|
||||||
@@ -252,9 +287,9 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenK8sItems(k8sItems k8s.ListK8SClusters) []map[string]interface{} {
|
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, item := range k8sItems {
|
for _, item := range k8sItems.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": item.AccountID,
|
"account_id": item.AccountID,
|
||||||
"account_name": item.Name,
|
"account_name": item.Name,
|
||||||
@@ -289,8 +324,46 @@ func flattenK8sItems(k8sItems k8s.ListK8SClusters) []map[string]interface{} {
|
|||||||
return res
|
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("items", flattenK8sItems(k8sItems))
|
||||||
|
d.Set("entry_count", k8sItems.EntryCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenResourceK8sCP(d *schema.ResourceData, k8s k8s.RecordK8S, masters []compute.RecordCompute) {
|
||||||
|
d.Set("acl", flattenAcl(k8s.ACL))
|
||||||
|
d.Set("account_id", k8s.AccountID)
|
||||||
|
d.Set("account_name", k8s.AccountName)
|
||||||
|
d.Set("k8sci_id", k8s.CIID)
|
||||||
|
d.Set("bservice_id", k8s.BServiceID)
|
||||||
|
d.Set("created_by", k8s.CreatedBy)
|
||||||
|
d.Set("created_time", k8s.CreatedTime)
|
||||||
|
d.Set("deleted_by", k8s.DeletedBy)
|
||||||
|
d.Set("deleted_time", k8s.DeletedTime)
|
||||||
|
d.Set("k8s_ci_name", k8s.K8CIName)
|
||||||
|
d.Set("with_lb", k8s.LBID != 0)
|
||||||
|
d.Set("lb_id", k8s.LBID)
|
||||||
|
d.Set("k8s_id", k8s.ID)
|
||||||
|
d.Set("name", k8s.Name)
|
||||||
|
d.Set("rg_id", k8s.RGID)
|
||||||
|
d.Set("rg_name", k8s.RGName)
|
||||||
|
d.Set("status", k8s.Status)
|
||||||
|
d.Set("tech_status", k8s.TechStatus)
|
||||||
|
d.Set("updated_by", k8s.UpdatedBy)
|
||||||
|
d.Set("updated_time", k8s.UpdatedTime)
|
||||||
|
d.Set("network_plugin", k8s.NetworkPlugin)
|
||||||
|
|
||||||
|
flattenCPParams(d, k8s.K8SGroups.Masters, masters)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenCPParams(d *schema.ResourceData, mastersGroup k8s.MasterGroup, masters []compute.RecordCompute) {
|
||||||
|
d.Set("cpu", mastersGroup.CPU)
|
||||||
|
d.Set("detailed_info", flattenDetailedInfo(mastersGroup.DetailedInfo, masters))
|
||||||
|
d.Set("disk", mastersGroup.Disk)
|
||||||
|
d.Set("master_id", mastersGroup.ID)
|
||||||
|
d.Set("master_name", mastersGroup.Name)
|
||||||
|
d.Set("num", mastersGroup.Num)
|
||||||
|
d.Set("ram", mastersGroup.RAM)
|
||||||
|
d.Set("master_id", mastersGroup.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
|
func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
|
||||||
@@ -323,12 +396,21 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
|
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
|
||||||
|
labels := make([]string, 0)
|
||||||
|
for _, label := range wg.Labels {
|
||||||
|
if strings.HasPrefix(label, "workersGroupName") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
labels = append(labels, label)
|
||||||
|
}
|
||||||
|
|
||||||
d.Set("annotations", wg.Annotations)
|
d.Set("annotations", wg.Annotations)
|
||||||
d.Set("cpu", wg.CPU)
|
d.Set("cpu", wg.CPU)
|
||||||
d.Set("detailed_info", flattenDetailedInfo(wg.DetailedInfo, computes))
|
d.Set("detailed_info", flattenDetailedInfo(wg.DetailedInfo, computes))
|
||||||
d.Set("disk", wg.Disk)
|
d.Set("disk", wg.Disk)
|
||||||
d.Set("guid", wg.GUID)
|
d.Set("guid", wg.GUID)
|
||||||
d.Set("labels", wg.Labels)
|
d.Set("labels", labels)
|
||||||
d.Set("name", wg.Name)
|
d.Set("name", wg.Name)
|
||||||
d.Set("num", wg.Num)
|
d.Set("num", wg.Num)
|
||||||
d.Set("ram", wg.RAM)
|
d.Set("ram", wg.RAM)
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
|
|||||||
|
|
||||||
package k8s
|
package k8s
|
||||||
|
|
||||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
func nodeMasterDefault() K8sNodeRecord {
|
func nodeMasterDefault() K8sNodeRecord {
|
||||||
return K8sNodeRecord{
|
return K8sNodeRecord{
|
||||||
@@ -68,9 +71,10 @@ func parseDefaultNode(nodeList []interface{}) K8sNodeRecord {
|
|||||||
func mastersSchemaMake() map[string]*schema.Schema {
|
func mastersSchemaMake() map[string]*schema.Schema {
|
||||||
masters := masterGroupSchemaMake()
|
masters := masterGroupSchemaMake()
|
||||||
masters["num"] = &schema.Schema{
|
masters["num"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Number of nodes to create.",
|
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||||
|
Description: "Number of nodes to create. Can be either 1 or 3",
|
||||||
}
|
}
|
||||||
masters["sep_id"] = &schema.Schema{
|
masters["sep_id"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func existK8sID(ctx context.Context, d *schema.ResourceData, m interface{}) (boo
|
|||||||
return false, err
|
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) {
|
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 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) {
|
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 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) {
|
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 false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(extNetList.FilterByID(extNetID)) != 0, nil
|
return len(extNetList.FilterByID(extNetID).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,9 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
if labels, ok := d.GetOk("labels"); ok {
|
if labels, ok := d.GetOk("labels"); ok {
|
||||||
labels := labels.([]interface{})
|
labels := labels.([]interface{})
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
createReq.Labels = append(createReq.Labels, label.(string))
|
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||||
|
createReq.Labels = append(createReq.Labels, label.(string))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,11 +143,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if withLB, ok := d.GetOk("with_lb"); ok {
|
createReq.WithLB = d.Get("with_lb").(bool)
|
||||||
createReq.WithLB = withLB.(bool)
|
|
||||||
} else {
|
|
||||||
createReq.WithLB = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||||
createReq.ExtNetID = uint64(extNet.(int))
|
createReq.ExtNetID = uint64(extNet.(int))
|
||||||
@@ -269,7 +267,7 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
curK8s := k8s.ItemK8SCluster{}
|
curK8s := k8s.ItemK8SCluster{}
|
||||||
for _, k8sCluster := range k8sList {
|
for _, k8sCluster := range k8sList.Data {
|
||||||
if k8sCluster.ID == cluster.ID {
|
if k8sCluster.ID == cluster.ID {
|
||||||
curK8s = k8sCluster
|
curK8s = k8sCluster
|
||||||
}
|
}
|
||||||
@@ -301,17 +299,19 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
|
|
||||||
flattenResourceK8s(d, *cluster, masterComputeList, workersComputeList)
|
flattenResourceK8s(d, *cluster, masterComputeList, workersComputeList)
|
||||||
|
|
||||||
lbGetReq := lb.GetRequest{
|
if d.Get("with_lb").(bool) || cluster.LBID != 0 {
|
||||||
LBID: cluster.LBID,
|
lbGetReq := lb.GetRequest{
|
||||||
}
|
LBID: cluster.LBID,
|
||||||
|
}
|
||||||
|
|
||||||
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
lb, err := c.CloudAPI().LB().Get(ctx, lbGetReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("extnet_id", lb.ExtNetID)
|
d.Set("extnet_id", lb.ExtNetID)
|
||||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||||
|
}
|
||||||
|
|
||||||
kubeconfigReq := k8s.GetConfigRequest{
|
kubeconfigReq := k8s.GetConfigRequest{
|
||||||
K8SID: cluster.ID,
|
K8SID: cluster.ID,
|
||||||
@@ -408,13 +408,21 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("name") {
|
updateReq := k8s.UpdateRequest{K8SID: cluster.ID}
|
||||||
req := k8s.UpdateRequest{
|
doBasicUpdate := false
|
||||||
K8SID: cluster.ID,
|
|
||||||
Name: d.Get("name").(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().K8S().Update(ctx, req)
|
if d.HasChange("name") {
|
||||||
|
updateReq.Name = d.Get("name").(string)
|
||||||
|
doBasicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("desc") {
|
||||||
|
updateReq.Description = d.Get("desc").(string)
|
||||||
|
doBasicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if doBasicUpdate {
|
||||||
|
_, err := c.CloudAPI().K8S().Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|||||||
713
internal/service/cloudapi/k8s/resource_k8s_cp.go
Normal file
713
internal/service/cloudapi/k8s/resource_k8s_cp.go
Normal file
@@ -0,0 +1,713 @@
|
|||||||
|
/*
|
||||||
|
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"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
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/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceK8sControlPlaneCreate: called with name %s, rg %d", d.Get("name").(string), d.Get("rg_id").(int))
|
||||||
|
|
||||||
|
haveRGID, err := existRGID(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveRGID {
|
||||||
|
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
haveK8sciID, err := existK8sCIID(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveK8sciID {
|
||||||
|
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because K8sCIID %d is not allowed or does not exist", d.Get("k8sci_id").(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := d.GetOk("extnet_id"); ok {
|
||||||
|
haveExtNetID, err := existExtNetID(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveExtNetID {
|
||||||
|
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because ExtNetID %d is not allowed or does not exist", d.Get("extnet_id").(int))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
createReq := k8s.CreateRequest{}
|
||||||
|
|
||||||
|
createReq.Name = d.Get("name").(string)
|
||||||
|
createReq.RGID = uint64(d.Get("rg_id").(int))
|
||||||
|
createReq.K8SCIID = uint64(d.Get("k8sci_id").(int))
|
||||||
|
createReq.WorkerGroupName = "temp"
|
||||||
|
createReq.NetworkPlugin = d.Get("network_plugin").(string)
|
||||||
|
|
||||||
|
if num, ok := d.GetOk("num"); ok {
|
||||||
|
createReq.MasterNum = uint(num.(int))
|
||||||
|
} else {
|
||||||
|
createReq.MasterNum = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if cpu, ok := d.GetOk("cpu"); ok {
|
||||||
|
createReq.MasterCPU = uint(cpu.(int))
|
||||||
|
} else {
|
||||||
|
createReq.MasterCPU = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
if ram, ok := d.GetOk("ram"); ok {
|
||||||
|
createReq.MasterRAM = uint(ram.(int))
|
||||||
|
} else {
|
||||||
|
createReq.MasterRAM = 2048
|
||||||
|
}
|
||||||
|
|
||||||
|
if disk, ok := d.GetOk("disk"); ok {
|
||||||
|
createReq.MasterDisk = uint(disk.(int))
|
||||||
|
} else {
|
||||||
|
createReq.MasterDisk = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
|
createReq.MasterSEPID = uint64(sepId.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
if sepPool, ok := d.GetOk("sep_pool"); ok {
|
||||||
|
createReq.MasterSEPPool = sepPool.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
createReq.WithLB = d.Get("with_lb").(bool)
|
||||||
|
|
||||||
|
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||||
|
createReq.ExtNetID = uint64(extNet.(int))
|
||||||
|
} else {
|
||||||
|
createReq.ExtNetID = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
|
createReq.Description = desc.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.CloudAPI().K8S().Create(ctx, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
taskReq := tasks.GetRequest{
|
||||||
|
AuditID: strings.Trim(resp, `"`),
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
task, err := c.CloudAPI().Tasks().Get(ctx, taskReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("resourceK8sControlPlaneCreate: instance creating - %s", task.Stage)
|
||||||
|
|
||||||
|
if task.Completed {
|
||||||
|
if task.Error != "" {
|
||||||
|
return diag.FromErr(fmt.Errorf("cannot create k8s instance: %v", task.Error))
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(int(task.Result)))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
delWGReq := k8s.WorkersGroupDeleteRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
WorkersGroupID: cluster.K8SGroups.Workers[0].ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().K8S().WorkersGroupDelete(ctx, delWGReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resourceK8sCPRead(ctx, d, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
hasChanged := false
|
||||||
|
|
||||||
|
switch cluster.Status {
|
||||||
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The k8s cluster is in status: %s, please, contact support for more information", cluster.Status)
|
||||||
|
case status.Creating:
|
||||||
|
case status.Created:
|
||||||
|
case status.Deleting:
|
||||||
|
case status.Deleted:
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
enableReq := k8s.DisableEnableRequest{
|
||||||
|
K8SID: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
case status.Enabling:
|
||||||
|
case status.Enabled:
|
||||||
|
case status.Disabling:
|
||||||
|
case status.Disabled:
|
||||||
|
log.Debugf("The k8s cluster is in status: %s, troubles may occur with update. Please, enable compute first.", cluster.Status)
|
||||||
|
case status.Restoring:
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasChanged {
|
||||||
|
cluster, err = utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if cluster == nil {
|
||||||
|
d.SetId("")
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Get("start").(bool) {
|
||||||
|
if cluster.TechStatus == "STOPPED" {
|
||||||
|
req := k8s.StartRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().K8S().Start(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
curK8s := k8s.ItemK8SCluster{}
|
||||||
|
for _, k8sCluster := range k8sList.Data {
|
||||||
|
if k8sCluster.ID == cluster.ID {
|
||||||
|
curK8s = k8sCluster
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if curK8s.ID == 0 {
|
||||||
|
return diag.Errorf("Cluster with id %d not found", cluster.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("vins_id", curK8s.VINSID)
|
||||||
|
|
||||||
|
masterComputeList := make([]compute.RecordCompute, 0, len(cluster.K8SGroups.Masters.DetailedInfo))
|
||||||
|
for _, masterNode := range cluster.K8SGroups.Masters.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, masterNode.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
masterComputeList = append(masterComputeList, *compute)
|
||||||
|
}
|
||||||
|
|
||||||
|
var warnings dc.Warnings
|
||||||
|
|
||||||
|
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)
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenResourceK8sCP(d, *cluster, masterComputeList)
|
||||||
|
|
||||||
|
lbGetReq := lb.GetRequest{
|
||||||
|
LBID: cluster.LBID,
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeconfigReq := k8s.GetConfigRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
kubeconfig, err := c.CloudAPI().K8S().GetConfig(ctx, kubeconfigReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("could not get kubeconfig: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("kubeconfig", kubeconfig)
|
||||||
|
|
||||||
|
return warnings.Get()
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceK8sControlPlaneUpdate: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
haveRGID, err := existRGID(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveRGID {
|
||||||
|
return diag.Errorf("resourceK8sUpdate: can't update k8s cluster because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
haveK8sciID, err := existK8sCIID(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !haveK8sciID {
|
||||||
|
return diag.Errorf("resourceK8sUpdate: can't update k8s cluster because K8sCIID %d is not allowed or does not exist", d.Get("k8sci_id").(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChanged := false
|
||||||
|
|
||||||
|
switch cluster.Status {
|
||||||
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The k8s cluster is in status: %s, please, contact support for more information", cluster.Status)
|
||||||
|
case status.Creating:
|
||||||
|
case status.Created:
|
||||||
|
case status.Deleting:
|
||||||
|
case status.Deleted:
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
enableReq := k8s.DisableEnableRequest{
|
||||||
|
K8SID: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
case status.Enabling:
|
||||||
|
case status.Enabled:
|
||||||
|
case status.Disabling:
|
||||||
|
case status.Disabled:
|
||||||
|
log.Debugf("The k8s cluster is in status: %s, troubles may occur with update. Please, enable compute first.", cluster.Status)
|
||||||
|
case status.Restoring:
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasChanged {
|
||||||
|
cluster, err = utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if cluster == nil {
|
||||||
|
d.SetId("")
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateReq := k8s.UpdateRequest{K8SID: cluster.ID}
|
||||||
|
doBasicUpdate := false
|
||||||
|
|
||||||
|
if d.HasChange("name") {
|
||||||
|
updateReq.Name = d.Get("name").(string)
|
||||||
|
doBasicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("desc") {
|
||||||
|
updateReq.Description = d.Get("desc").(string)
|
||||||
|
doBasicUpdate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if doBasicUpdate {
|
||||||
|
_, err := c.CloudAPI().K8S().Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("start") {
|
||||||
|
if d.Get("start").(bool) {
|
||||||
|
if cluster.TechStatus == "STOPPED" {
|
||||||
|
req := k8s.StartRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().K8S().Start(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if cluster.TechStatus == "STARTED" {
|
||||||
|
req := k8s.StopRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().K8S().Stop(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("num") {
|
||||||
|
oldVal, newVal := d.GetChange("num")
|
||||||
|
|
||||||
|
if oldVal.(int) > newVal.(int) {
|
||||||
|
ids := make([]string, 0)
|
||||||
|
for i := oldVal.(int) - 1; i >= newVal.(int); i-- {
|
||||||
|
id := cluster.K8SGroups.Masters.DetailedInfo[i].ID
|
||||||
|
ids = append(ids, strconv.FormatUint(id, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
req := k8s.DeleteMasterFromGroupRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
MasterGroupID: cluster.K8SGroups.Masters.ID,
|
||||||
|
MasterIDs: ids,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().K8S().DeleteMasterFromGroup(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceK8sControlPlaneDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
|
||||||
|
|
||||||
|
cluster, err := utilityK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
req := k8s.DeleteRequest{
|
||||||
|
K8SID: cluster.ID,
|
||||||
|
Permanently: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().K8S().Delete(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Name of the cluster.",
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Resource group ID that this instance belongs to.",
|
||||||
|
},
|
||||||
|
"k8sci_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "ID of the k8s catalog item to base this instance on.",
|
||||||
|
},
|
||||||
|
"network_plugin": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Network plugin to be used",
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true),
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||||
|
Description: "Number of VMs to create. Can be either 1 or 3",
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node CPU count.",
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node RAM in MB.",
|
||||||
|
},
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node boot disk size in GB.",
|
||||||
|
},
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Storage Endpoint ID",
|
||||||
|
},
|
||||||
|
"sep_pool": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Storage Endpoint Pool",
|
||||||
|
},
|
||||||
|
"with_lb": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
Description: "Create k8s with load balancer if true.",
|
||||||
|
},
|
||||||
|
"extnet_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Text description of this instance.",
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
Description: "Start k8s cluster.",
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"master_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Master group ID.",
|
||||||
|
},
|
||||||
|
"master_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Master group name.",
|
||||||
|
},
|
||||||
|
"acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: aclGroupSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"bservice_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_ci_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP address of default load balancer.",
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"kubeconfig": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Kubeconfig for cluster access.",
|
||||||
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of default vins for this instace.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceK8sCP() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceK8sCPCreate,
|
||||||
|
ReadContext: resourceK8sCPRead,
|
||||||
|
UpdateContext: resourceK8sCPUpdate,
|
||||||
|
DeleteContext: resourceK8sCPDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout30m,
|
||||||
|
Read: &constants.Timeout600s,
|
||||||
|
Update: &constants.Timeout600s,
|
||||||
|
Delete: &constants.Timeout600s,
|
||||||
|
Default: &constants.Timeout600s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: resourceK8sCPSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !haveK8sID {
|
if !haveK8sID {
|
||||||
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
|
return diag.Errorf("resourceK8sWgCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
@@ -71,7 +71,9 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
labels, _ := d.Get("labels").([]interface{})
|
labels, _ := d.Get("labels").([]interface{})
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
req.Labels = append(req.Labels, label.(string))
|
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||||
|
req.Labels = append(req.Labels, label.(string))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations, _ := d.Get("annotations").([]interface{})
|
annotations, _ := d.Get("annotations").([]interface{})
|
||||||
@@ -317,11 +319,11 @@ func ResourceK8sWg() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout20m,
|
||||||
Read: &constants.Timeout600s,
|
Read: &constants.Timeout20m,
|
||||||
Update: &constants.Timeout600s,
|
Update: &constants.Timeout20m,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout20m,
|
||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout20m,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceK8sWgSchemaMake(),
|
Schema: resourceK8sWgSchemaMake(),
|
||||||
|
|||||||
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
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@ package k8s
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||||
@@ -148,7 +149,9 @@ func addWGs(ctx context.Context, c *controller.ControllerCfg, cluster *k8s.Recor
|
|||||||
|
|
||||||
labels, _ := found_wg["labels"].([]interface{})
|
labels, _ := found_wg["labels"].([]interface{})
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
req.Labels = append(req.Labels, label.(string))
|
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||||
|
req.Labels = append(req.Labels, label.(string))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations, _ := found_wg["annotations"].([]interface{})
|
annotations, _ := found_wg["annotations"].([]interface{})
|
||||||
@@ -220,12 +223,44 @@ func utilityDataK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
return k8s, nil
|
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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := k8s.ListRequest{
|
req := k8s.ListRequest{
|
||||||
IncludeDeleted: false,
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -234,10 +269,42 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
return k8sList, nil
|
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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := k8s.ListDeletedRequest{}
|
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 status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||||
|
req.TechStatus = tech_status.(string)
|
||||||
|
}
|
||||||
|
|
||||||
k8sList, err := c.CloudAPI().K8S().ListDeleted(ctx, req)
|
k8sList, err := c.CloudAPI().K8S().ListDeleted(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ func computeSnapshotsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"reference_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"res_id": {
|
"res_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -633,22 +637,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"custom_fields": {
|
// "custom_fields": {
|
||||||
Type: schema.TypeList,
|
// Type: schema.TypeString,
|
||||||
Computed: true,
|
// Computed: true,
|
||||||
Elem: &schema.Resource{
|
// },
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"key": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"val": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
"deleted_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -827,6 +819,14 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"stateless_sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"stateless_sep_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,17 @@ func dataSourceComputeListRead(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
return diag.FromErr(err)
|
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()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenComputeList(computeList))
|
d.Set("items", flattenComputeList(result))
|
||||||
|
d.Set("entry_count", computeList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,10 +154,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"custom_fields": { //NEED
|
// "custom_fields": { //NEED
|
||||||
Type: schema.TypeString,
|
// Type: schema.TypeString,
|
||||||
Computed: true,
|
// Computed: true,
|
||||||
},
|
// },
|
||||||
"deleted_by": {
|
"deleted_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -325,8 +333,58 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceCompputeListSchemaMake() map[string]*schema.Schema {
|
func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -339,7 +397,12 @@ func dataSourceCompputeListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -347,6 +410,10 @@ func dataSourceCompputeListSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: itemComputeSchemaMake(),
|
Schema: itemComputeSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@@ -362,6 +429,6 @@ func DataSourceComputeList() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceCompputeListSchemaMake(),
|
Schema: dataSourceComputeListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -147,10 +148,10 @@ func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenComputeList(computes compute.ListComputes) []map[string]interface{} {
|
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, compute := range computes {
|
for _, compute := range computes.Data {
|
||||||
customFields, _ := json.Marshal(compute.CustomFields)
|
// customFields, _ := json.Marshal(compute.CustomFields)
|
||||||
devices, _ := json.Marshal(compute.Devices)
|
devices, _ := json.Marshal(compute.Devices)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"acl": flattenListACL(compute.ACL),
|
"acl": flattenListACL(compute.ACL),
|
||||||
@@ -169,44 +170,44 @@ func flattenComputeList(computes compute.ListComputes) []map[string]interface{}
|
|||||||
"cpus": compute.CPU,
|
"cpus": compute.CPU,
|
||||||
"created_by": compute.CreatedBy,
|
"created_by": compute.CreatedBy,
|
||||||
"created_time": compute.CreatedTime,
|
"created_time": compute.CreatedTime,
|
||||||
"custom_fields": string(customFields),
|
// "custom_fields": string(customFields),
|
||||||
"deleted_by": compute.DeletedBy,
|
"deleted_by": compute.DeletedBy,
|
||||||
"deleted_time": compute.DeletedTime,
|
"deleted_time": compute.DeletedTime,
|
||||||
"desc": compute.Description,
|
"desc": compute.Description,
|
||||||
"devices": string(devices),
|
"devices": string(devices),
|
||||||
"disks": flattenDisks(compute.Disks),
|
"disks": flattenDisks(compute.Disks),
|
||||||
"driver": compute.Driver,
|
"driver": compute.Driver,
|
||||||
"gid": compute.GID,
|
"gid": compute.GID,
|
||||||
"guid": compute.GUID,
|
"guid": compute.GUID,
|
||||||
"compute_id": compute.ID,
|
"compute_id": compute.ID,
|
||||||
"image_id": compute.ImageID,
|
"image_id": compute.ImageID,
|
||||||
"interfaces": flattenInterfaces(compute.Interfaces),
|
"interfaces": flattenInterfaces(compute.Interfaces),
|
||||||
"lock_status": compute.LockStatus,
|
"lock_status": compute.LockStatus,
|
||||||
"manager_id": compute.ManagerID,
|
"manager_id": compute.ManagerID,
|
||||||
"manager_type": compute.ManagerType,
|
"manager_type": compute.ManagerType,
|
||||||
"migrationjob": compute.MigrationJob,
|
"migrationjob": compute.MigrationJob,
|
||||||
"milestones": compute.Milestones,
|
"milestones": compute.Milestones,
|
||||||
"name": compute.Name,
|
"name": compute.Name,
|
||||||
"pinned": compute.Pinned,
|
"pinned": compute.Pinned,
|
||||||
"ram": compute.RAM,
|
"ram": compute.RAM,
|
||||||
"reference_id": compute.ReferenceID,
|
"reference_id": compute.ReferenceID,
|
||||||
"registered": compute.Registered,
|
"registered": compute.Registered,
|
||||||
"res_name": compute.ResName,
|
"res_name": compute.ResName,
|
||||||
"rg_id": compute.RGID,
|
"rg_id": compute.RGID,
|
||||||
"rg_name": compute.RGName,
|
"rg_name": compute.RGName,
|
||||||
"snap_sets": flattenSnapSets(compute.SnapSets),
|
"snap_sets": flattenSnapSets(compute.SnapSets),
|
||||||
"stateless_sep_id": compute.StatelessSepID,
|
"stateless_sep_id": compute.StatelessSepID,
|
||||||
"stateless_sep_type": compute.StatelessSepType,
|
"stateless_sep_type": compute.StatelessSepType,
|
||||||
"status": compute.Status,
|
"status": compute.Status,
|
||||||
"tags": flattenTags(compute.Tags),
|
"tags": flattenTags(compute.Tags),
|
||||||
"tech_status": compute.TechStatus,
|
"tech_status": compute.TechStatus,
|
||||||
"total_disk_size": compute.TotalDiskSize,
|
"total_disk_size": compute.TotalDiskSize,
|
||||||
"updated_by": compute.UpdatedBy,
|
"updated_by": compute.UpdatedBy,
|
||||||
"updated_time": compute.UpdatedTime,
|
"updated_time": compute.UpdatedTime,
|
||||||
"user_managed": compute.UserManaged,
|
"user_managed": compute.UserManaged,
|
||||||
"vgpus": compute.VGPUs,
|
"vgpus": compute.VGPUs,
|
||||||
"vins_connected": compute.VINSConnected,
|
"vins_connected": compute.VINSConnected,
|
||||||
"virtual_image_id": compute.VirtualImageID,
|
"virtual_image_id": compute.VirtualImageID,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
@@ -239,7 +240,7 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
|||||||
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []interface{}) []map[string]interface{} {
|
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []interface{}) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(disksList))
|
res := make([]map[string]interface{}, 0, len(disksList))
|
||||||
for _, disk := range disksList {
|
for _, disk := range disksList {
|
||||||
if disk.Name == "bootdisk" || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
|
if strings.Contains(disk.Name, "bootdisk") || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -265,7 +266,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []in
|
|||||||
|
|
||||||
func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{} {
|
func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||||
//index := 0
|
|
||||||
for _, network := range interfaces {
|
for _, network := range interfaces {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"net_id": network.NetID,
|
"net_id": network.NetID,
|
||||||
@@ -280,7 +281,7 @@ func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{}
|
|||||||
|
|
||||||
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
|
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
|
||||||
for _, disk := range disks {
|
for _, disk := range disks {
|
||||||
if disk.Name == "bootdisk" {
|
if strings.Contains(disk.Name, "bootdisk") {
|
||||||
return &disk
|
return &disk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,7 +297,6 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
|||||||
log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID)
|
log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID)
|
||||||
|
|
||||||
devices, _ := json.Marshal(computeRec.Devices)
|
devices, _ := json.Marshal(computeRec.Devices)
|
||||||
userdata, _ := json.Marshal(computeRec.Userdata)
|
|
||||||
bootDisk := findBootDisk(computeRec.Disks)
|
bootDisk := findBootDisk(computeRec.Disks)
|
||||||
|
|
||||||
//check extraDisks, ipa_type, is,
|
//check extraDisks, ipa_type, is,
|
||||||
@@ -307,20 +307,16 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
|||||||
d.Set("affinity_weight", computeRec.AffinityWeight)
|
d.Set("affinity_weight", computeRec.AffinityWeight)
|
||||||
d.Set("arch", computeRec.Architecture)
|
d.Set("arch", computeRec.Architecture)
|
||||||
d.Set("boot_order", computeRec.BootOrder)
|
d.Set("boot_order", computeRec.BootOrder)
|
||||||
d.Set("boot_disk_size", computeRec.BootDiskSize)
|
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||||
d.Set("boot_disk", flattenBootDisk(bootDisk))
|
d.Set("boot_disk", flattenBootDisk(bootDisk))
|
||||||
d.Set("boot_disk_id", bootDisk.ID)
|
d.Set("boot_disk_id", bootDisk.ID)
|
||||||
d.Set("sep_id", bootDisk.SepID)
|
d.Set("sep_id", bootDisk.SepID)
|
||||||
d.Set("pool", bootDisk.Pool)
|
d.Set("pool", bootDisk.Pool)
|
||||||
d.Set("clone_reference", computeRec.CloneReference)
|
d.Set("clone_reference", computeRec.CloneReference)
|
||||||
d.Set("clones", computeRec.Clones)
|
d.Set("clones", computeRec.Clones)
|
||||||
if string(userdata) != "{}" {
|
|
||||||
d.Set("cloud_init", string(userdata))
|
|
||||||
}
|
|
||||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||||
d.Set("created_by", computeRec.CreatedBy)
|
d.Set("created_by", computeRec.CreatedBy)
|
||||||
d.Set("created_time", computeRec.CreatedTime)
|
d.Set("created_time", computeRec.CreatedTime)
|
||||||
d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
|
|
||||||
d.Set("deleted_by", computeRec.DeletedBy)
|
d.Set("deleted_by", computeRec.DeletedBy)
|
||||||
d.Set("deleted_time", computeRec.DeletedTime)
|
d.Set("deleted_time", computeRec.DeletedTime)
|
||||||
d.Set("description", computeRec.Description)
|
d.Set("description", computeRec.Description)
|
||||||
@@ -446,6 +442,7 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
|
|||||||
"guid": snapshot.GUID,
|
"guid": snapshot.GUID,
|
||||||
"label": snapshot.Label,
|
"label": snapshot.Label,
|
||||||
"res_id": snapshot.ResID,
|
"res_id": snapshot.ResID,
|
||||||
|
"reference_id": snapshot.ReferenceID,
|
||||||
"snap_set_guid": snapshot.SnapSetGUID,
|
"snap_set_guid": snapshot.SnapSetGUID,
|
||||||
"snap_set_time": snapshot.SnapSetTime,
|
"snap_set_time": snapshot.SnapSetTime,
|
||||||
"timestamp": snapshot.TimeStamp,
|
"timestamp": snapshot.TimeStamp,
|
||||||
@@ -507,18 +504,11 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenCustomFields(customFileds map[string]interface{}) []map[string]interface{} {
|
func flattenCustomFields(customFields map[string]interface{}) string {
|
||||||
res := make([]map[string]interface{}, 0)
|
encoded, _ := json.Marshal(customFields)
|
||||||
for key, val := range customFileds {
|
return string(encoded)
|
||||||
value, _ := json.Marshal(val)
|
|
||||||
temp := map[string]interface{}{
|
|
||||||
"key": key,
|
|
||||||
"val": string(value),
|
|
||||||
}
|
|
||||||
res = append(res, temp)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenOsUsers(osUsers compute.ListOSUser) []map[string]interface{} {
|
func flattenOsUsers(osUsers compute.ListOSUser) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, user := range osUsers {
|
for _, user := range osUsers {
|
||||||
@@ -552,7 +542,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
|||||||
d.Set("cpus", computeRec.CPU)
|
d.Set("cpus", computeRec.CPU)
|
||||||
d.Set("created_by", computeRec.CreatedBy)
|
d.Set("created_by", computeRec.CreatedBy)
|
||||||
d.Set("created_time", computeRec.CreatedTime)
|
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_by", computeRec.DeletedBy)
|
||||||
d.Set("deleted_time", computeRec.DeletedTime)
|
d.Set("deleted_time", computeRec.DeletedTime)
|
||||||
d.Set("desc", computeRec.Description)
|
d.Set("desc", computeRec.Description)
|
||||||
@@ -613,9 +603,9 @@ func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interfa
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenPfwList(computePfws compute.ListPFWs) []map[string]interface{} {
|
func flattenPfwList(computePfws *compute.ListPFWs) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, computePfw := range computePfws {
|
for _, computePfw := range computePfws.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"pfw_id": computePfw.ID,
|
"pfw_id": computePfw.ID,
|
||||||
"local_ip": computePfw.LocalIP,
|
"local_ip": computePfw.LocalIP,
|
||||||
@@ -630,10 +620,10 @@ func flattenPfwList(computePfws compute.ListPFWs) []map[string]interface{} {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenUserList(d *schema.ResourceData, userList compute.RecordACL) {
|
func flattenUserList(d *schema.ResourceData, userList *compute.ListUsers) {
|
||||||
d.Set("account_acl", flattenListACL(userList.AccountACL))
|
d.Set("account_acl", flattenListACL(userList.Data.AccountACL))
|
||||||
d.Set("compute_acl", flattenListACL(userList.ComputeACL))
|
d.Set("compute_acl", flattenListACL(userList.Data.ComputeACL))
|
||||||
d.Set("rg_acl", flattenListACL(userList.RGACL))
|
d.Set("rg_acl", flattenListACL(userList.Data.RGACL))
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string]interface{} {
|
func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string]interface{} {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -36,8 +37,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"hash/fnv"
|
"hash/fnv"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
||||||
|
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -36,6 +37,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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/extnet"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||||
@@ -55,7 +57,7 @@ func existRgID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
|||||||
return false, err
|
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) {
|
func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
@@ -68,11 +70,11 @@ func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) (b
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(imageList.FilterByID(imageId)) != 0, nil
|
return len(imageList.FilterByID(imageId).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func existVinsIdInList(vinsId uint64, vinsList vins.ListVINS) bool {
|
func existVinsIdInList(vinsId uint64, vinsList *vins.ListVINS) bool {
|
||||||
for _, vins := range vinsList {
|
for _, vins := range vinsList.Data {
|
||||||
if vinsId == vins.ID {
|
if vinsId == vins.ID {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -81,8 +83,8 @@ func existVinsIdInList(vinsId uint64, vinsList vins.ListVINS) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func existExtNetIdInList(extId uint64, extList extnet.ListExtNets) bool {
|
func existExtNetIdInList(extId uint64, extList *extnet.ListExtNets) bool {
|
||||||
for _, ext := range extList {
|
for _, ext := range extList.Data {
|
||||||
if extId == ext.ID {
|
if extId == ext.ID {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -91,43 +93,35 @@ func existExtNetIdInList(extId uint64, extList extnet.ListExtNets) bool {
|
|||||||
return false
|
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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := vins.ListRequest{IncludeDeleted: false}
|
req := vins.ListRequest{IncludeDeleted: false}
|
||||||
|
|
||||||
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
|
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debugf("Unable to retrieve ViNS list, %s", err)
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
networks := d.Get("network").(*schema.Set).List()
|
if !existVinsIdInList(uint64(id), vinsList) {
|
||||||
|
return id, false
|
||||||
for _, networkInterface := range networks {
|
|
||||||
networkItem := networkInterface.(map[string]interface{})
|
|
||||||
if !existVinsIdInList(uint64(networkItem["net_id"].(int)), vinsList) {
|
|
||||||
return networkItem["net_id"].(int), false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, true
|
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)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := extnet.ListRequest{}
|
req := extnet.ListRequest{}
|
||||||
|
|
||||||
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debugf("Unable to retrieve extnet list, %s", err)
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
networks := d.Get("network").(*schema.Set).List()
|
if !existExtNetIdInList(uint64(id), extNetList) {
|
||||||
|
return id, false
|
||||||
for _, networkInterface := range networks {
|
|
||||||
networkItem := networkInterface.(map[string]interface{})
|
|
||||||
if !existExtNetIdInList(uint64(networkItem["net_id"].(int)), extNetList) {
|
|
||||||
return networkItem["net_id"].(int), false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, true
|
return 0, true
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Authors:
|
|||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
Tim Tkachev, <tvkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -35,6 +36,7 @@ package kvmvm
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||||
@@ -76,14 +78,22 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if network, ok := d.GetOk("network"); ok {
|
if network, ok := d.GetOk("network"); ok {
|
||||||
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
networkList := network.(*schema.Set).List()
|
||||||
if networkData["net_type"].(string) == "VINS" {
|
for _, elem := range networkList {
|
||||||
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
networkData := elem.(map[string]interface{})
|
||||||
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
|
|
||||||
}
|
switch networkData["net_type"].(string) {
|
||||||
} else if networkData["net_type"].(string) == "EXTNET" {
|
case "VINS":
|
||||||
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
if vinsId, ok := existVinsId(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)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,23 +128,32 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
createReqPPC.IS = IS.(string)
|
createReqPPC.IS = IS.(string)
|
||||||
createReqX86.IS = IS.(string)
|
createReqX86.IS = IS.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.Get("with_default_vins").(bool) {
|
||||||
|
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||||
|
}
|
||||||
|
|
||||||
if networks, ok := d.GetOk("network"); ok {
|
if networks, ok := d.GetOk("network"); ok {
|
||||||
if networks.(*schema.Set).Len() > 0 {
|
if networks.(*schema.Set).Len() > 0 {
|
||||||
ns := networks.(*schema.Set).List()
|
ns := networks.(*schema.Set).List()
|
||||||
defaultNetwork := ns[0].(map[string]interface{})
|
|
||||||
|
|
||||||
createReqPPC.NetType = defaultNetwork["net_type"].(string)
|
interfaces := make([]kvmx86.Interface, 0)
|
||||||
createReqPPC.NetID = uint64(defaultNetwork["net_id"].(int))
|
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)
|
ipaddr, ipSet := netInterfaceVal["ip_address"]
|
||||||
createReqX86.NetID = uint64(defaultNetwork["net_id"].(int))
|
if ipSet {
|
||||||
|
reqInterface.IPAddr = ipaddr.(string)
|
||||||
|
}
|
||||||
|
|
||||||
ipaddr, ipSet := defaultNetwork["ip_address"] // "ip_address" key is optional
|
interfaces = append(interfaces, reqInterface)
|
||||||
if ipSet {
|
|
||||||
createReqPPC.IPAddr = ipaddr.(string)
|
|
||||||
createReqX86.IPAddr = ipaddr.(string)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createReqX86.Interfaces = interfaces
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,8 +161,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if ok {
|
if ok {
|
||||||
userdata := argVal.(string)
|
userdata := argVal.(string)
|
||||||
if userdata != "" && userdata != "applied" {
|
if userdata != "" && userdata != "applied" {
|
||||||
createReqPPC.Userdata = userdata
|
createReqPPC.Userdata = strings.TrimSpace(userdata)
|
||||||
createReqX86.Userdata = userdata
|
createReqX86.Userdata = strings.TrimSpace(userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +190,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
createReqX86.RAM = uint64(d.Get("ram").(int))
|
createReqX86.RAM = uint64(d.Get("ram").(int))
|
||||||
createReqX86.ImageID = uint64(d.Get("image_id").(int))
|
createReqX86.ImageID = uint64(d.Get("image_id").(int))
|
||||||
|
|
||||||
|
createReqX86.Driver = driver
|
||||||
|
|
||||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||||
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -212,16 +233,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
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)
|
|
||||||
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),
|
// 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
|
// now we need to start it before we report the sequence complete
|
||||||
@@ -556,14 +567,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if network, ok := d.GetOk("network"); ok {
|
if network, ok := d.GetOk("network"); ok {
|
||||||
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
networkList := network.(*schema.Set).List()
|
||||||
if networkData["net_type"].(string) == "VINS" {
|
for _, elem := range networkList {
|
||||||
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
networkData := elem.(map[string]interface{})
|
||||||
return diag.Errorf("resourceComputeUpdate: can't create update because vins ID %d is not allowed or does not exist", vinsId)
|
|
||||||
}
|
switch networkData["net_type"].(string) {
|
||||||
} else if networkData["net_type"].(string) == "EXTNET" {
|
case "VINS":
|
||||||
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||||
return diag.Errorf("resourceComputeUpdate: can't create update because extnet ID %d is not allowed or does not exist", extNetId)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -592,7 +611,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Debugf("resourceComputeUpdate: enable=%t Compute ID %s after completing its resource configuration", d.Id(), enabled)
|
log.Debugf("resourceComputeUpdate: enable=%s Compute ID %v after completing its resource configuration", d.Id(), enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check compute statuses
|
// check compute statuses
|
||||||
@@ -693,16 +712,21 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = utilityComputeNetworksConfigure(ctx, d, m, true, false) // pass do_delta = true to apply changes, if any
|
if d.HasChange("network") {
|
||||||
if err != nil {
|
err = utilityComputeNetworksConfigure(ctx, d, m, true, false, computeRec.ID) // pass do_delta = true to apply changes, if any
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("description") || d.HasChange("name") {
|
if d.HasChange("description") || d.HasChange("name") {
|
||||||
req := compute.UpdateRequest{
|
req := compute.UpdateRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
Description: d.Get("desc").(string),
|
}
|
||||||
|
|
||||||
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
|
req.Description = desc.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
||||||
@@ -748,7 +772,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
for _, disk := range deletedDisks {
|
for _, disk := range deletedDisks {
|
||||||
diskConv := disk.(map[string]interface{})
|
diskConv := disk.(map[string]interface{})
|
||||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,7 +800,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if len(addedDisks) > 0 {
|
if len(addedDisks) > 0 {
|
||||||
for _, disk := range addedDisks {
|
for _, disk := range addedDisks {
|
||||||
diskConv := disk.(map[string]interface{})
|
diskConv := disk.(map[string]interface{})
|
||||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
req := compute.DiskAddRequest{
|
req := compute.DiskAddRequest{
|
||||||
@@ -808,7 +832,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if len(updatedDisks) > 0 {
|
if len(updatedDisks) > 0 {
|
||||||
for _, disk := range updatedDisks {
|
for _, disk := range updatedDisks {
|
||||||
diskConv := disk.(map[string]interface{})
|
diskConv := disk.(map[string]interface{})
|
||||||
if diskConv["disk_name"].(string) == "bootdisk" {
|
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
req := compute.DiskResizeRequest{
|
req := compute.DiskResizeRequest{
|
||||||
@@ -1529,10 +1553,8 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
|
||||||
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
|
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
@@ -1540,50 +1562,43 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
ValidateFunc: validation.IntAtLeast(1),
|
ValidateFunc: validation.IntAtLeast(1),
|
||||||
Description: "ID of the resource group where this compute should be deployed.",
|
Description: "ID of the resource group where this compute should be deployed.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"driver": {
|
"driver": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
StateFunc: statefuncs.StateFuncToUpper,
|
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.",
|
Description: "Hardware architecture of this compute instance.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"cpu": {
|
"cpu": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
|
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
|
||||||
Description: "Number of CPUs to allocate to this compute instance.",
|
Description: "Number of CPUs to allocate to this compute instance.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"ram": {
|
"ram": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
|
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
|
||||||
Description: "Amount of RAM in MB to allocate to this compute instance.",
|
Description: "Amount of RAM in MB to allocate to this compute instance.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"image_id": {
|
"image_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true, //REDEPLOY
|
//ForceNew: true, //REDEPLOY
|
||||||
Description: "ID of the OS image to base this compute instance on.",
|
Description: "ID of the OS image to base this compute instance on.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"boot_disk_size": {
|
"boot_disk_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"affinity_label": {
|
"affinity_label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Set affinity label for compute",
|
Description: "Set affinity label for compute",
|
||||||
},
|
},
|
||||||
|
|
||||||
"affinity_rules": {
|
"affinity_rules": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -1620,7 +1635,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"anti_affinity_rules": {
|
"anti_affinity_rules": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -1657,7 +1671,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"disks": {
|
"disks": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -1665,6 +1678,18 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: disksSubresourceSchemaMake(),
|
Schema: disksSubresourceSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"stateless": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
|
||||||
|
},
|
||||||
|
"with_default_vins": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
Description: "Create compute with default resgroup ViNS (true) or without any interfaces (false). This parameter is ignored if network block is specified",
|
||||||
|
},
|
||||||
"boot_disk": {
|
"boot_disk": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -1699,7 +1724,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
|
|
||||||
"network": {
|
"network": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Computed: true,
|
|
||||||
Optional: true,
|
Optional: true,
|
||||||
MinItems: 1,
|
MinItems: 1,
|
||||||
MaxItems: constants.MaxNetworksPerCompute,
|
MaxItems: constants.MaxNetworksPerCompute,
|
||||||
@@ -1709,18 +1733,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.",
|
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": {
|
"tags": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -1830,7 +1842,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
"started": {
|
"started": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Default: true,
|
||||||
Description: "Is compute started.",
|
Description: "Is compute started.",
|
||||||
},
|
},
|
||||||
"detach_disks": {
|
"detach_disks": {
|
||||||
@@ -1853,7 +1865,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "compute purpose",
|
Description: "compute purpose",
|
||||||
},
|
},
|
||||||
|
|
||||||
// The rest are Compute properties, which are "computed" once it is created
|
// The rest are Compute properties, which are "computed" once it is created
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -1908,22 +1919,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
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": {
|
"deleted_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ package kvmvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -43,6 +44,16 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func matchComputes(computeList *compute.ListComputes) *compute.ListComputes {
|
||||||
|
matched, _ := regexp.Compile("[a-zA-Z]+\\d+-[a-zA-Z]+\\d+-[a-zA-Z]+\\d+")
|
||||||
|
result := computeList.FilterFunc(func(ic compute.ItemCompute) bool {
|
||||||
|
res := matched.Match([]byte(ic.Name))
|
||||||
|
return !res
|
||||||
|
})
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool) error {
|
func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool) error {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
@@ -144,11 +155,21 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool, skip_zero bool) error {
|
func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool, skip_zero bool, computeID uint64) error {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
old_set, new_set := d.GetChange("network")
|
old_set, new_set := d.GetChange("network")
|
||||||
|
|
||||||
|
req := compute.StopRequest{
|
||||||
|
ComputeID: computeID,
|
||||||
|
Force: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Compute().Stop(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
apiErrCount := 0
|
apiErrCount := 0
|
||||||
var lastSavedError error
|
var lastSavedError error
|
||||||
|
|
||||||
@@ -232,6 +253,14 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startReq := compute.StartRequest{ComputeID: computeID}
|
||||||
|
|
||||||
|
_, err = c.CloudAPI().Compute().Start(ctx, startReq)
|
||||||
|
if err != nil {
|
||||||
|
apiErrCount++
|
||||||
|
lastSavedError = err
|
||||||
|
}
|
||||||
|
|
||||||
if apiErrCount > 0 {
|
if apiErrCount > 0 {
|
||||||
log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s",
|
log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s",
|
||||||
apiErrCount, d.Id(), lastSavedError)
|
apiErrCount, d.Id(), lastSavedError)
|
||||||
|
|||||||
@@ -40,10 +40,40 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (compute.ListComputes, error) {
|
func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListComputes, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := compute.ListRequest{}
|
req := compute.ListRequest{}
|
||||||
|
|
||||||
|
if byId, ok := d.GetOk("by_id"); ok {
|
||||||
|
req.ByID = uint64(byId.(int))
|
||||||
|
}
|
||||||
|
if name, ok := d.GetOk("name"); ok {
|
||||||
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
|
req.AccountID = uint64(accountId.(int))
|
||||||
|
}
|
||||||
|
if rgName, ok := d.GetOk("rg_name"); ok {
|
||||||
|
req.RGName = rgName.(string)
|
||||||
|
}
|
||||||
|
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||||
|
req.RGID = uint64(rgId.(int))
|
||||||
|
}
|
||||||
|
if techStatus, ok := d.GetOk("tech_status"); ok {
|
||||||
|
req.TechStatus = techStatus.(string)
|
||||||
|
}
|
||||||
|
if status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
if ipAddress, ok := d.GetOk("ip_address"); ok {
|
||||||
|
req.IPAddress = ipAddress.(string)
|
||||||
|
}
|
||||||
|
if extNetName, ok := d.GetOk("extnet_name"); ok {
|
||||||
|
req.ExtNetName = extNetName.(string)
|
||||||
|
}
|
||||||
|
if extnetId, ok := d.GetOk("extnet_id"); ok {
|
||||||
|
req.ExtNetID = uint64(extnetId.(int))
|
||||||
|
}
|
||||||
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
|
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
|
||||||
req.IncludeDeleted = includeDeleted.(bool)
|
req.IncludeDeleted = includeDeleted.(bool)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityComputePfwListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (compute.ListPFWs, error) {
|
func utilityComputePfwListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListPFWs, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := compute.PFWListRequest{
|
req := compute.PFWListRequest{
|
||||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityComputeUserListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (compute.RecordACL, error) {
|
func utilityComputeUserListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListUsers, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := compute.UserListRequest{
|
req := compute.UserListRequest{
|
||||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||||
@@ -48,8 +48,8 @@ func utilityComputeUserListCheckPresence(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
computeUserList, err := c.CloudAPI().Compute().UserList(ctx, req)
|
computeUserList, err := c.CloudAPI().Compute().UserList(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *computeUserList, err
|
return computeUserList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *computeUserList, err
|
return computeUserList, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenLBList(lbList))
|
d.Set("items", flattenLBList(lbList))
|
||||||
|
d.Set("entry_count", lbList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenLBList(lbList))
|
d.Set("items", flattenLBList(lbList))
|
||||||
|
d.Set("entry_count", lbList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,9 +241,9 @@ func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} {
|
|||||||
return temp
|
return temp
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenLBList(lbl lb.ListLB) []map[string]interface{} {
|
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(lbl))
|
res := make([]map[string]interface{}, 0, len(lbl.Data))
|
||||||
for _, lb := range lbl {
|
for _, lb := range lbl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ha_mode": lb.HAMode,
|
"ha_mode": lb.HAMode,
|
||||||
"backends": flattenLBBackends(lb.Backends),
|
"backends": flattenLBBackends(lb.Backends),
|
||||||
|
|||||||
@@ -45,6 +45,41 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
|||||||
|
|
||||||
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
return 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",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by Account ID",
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by RG ID",
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by TechStatus",
|
||||||
|
},
|
||||||
|
"front_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by FrontIP",
|
||||||
|
},
|
||||||
|
"back_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by BackIP",
|
||||||
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -62,11 +97,55 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: dsLBItemSchemaMake(),
|
Schema: dsLBItemSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dsLBListSchemaMake() map[string]*schema.Schema {
|
func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||||
return 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",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by Account ID",
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by RG ID",
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by TechStatus",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by Status",
|
||||||
|
},
|
||||||
|
"front_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by FrontIP",
|
||||||
|
},
|
||||||
|
"back_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by BackIP",
|
||||||
|
},
|
||||||
"includedeleted": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -89,6 +168,10 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: dsLBItemSchemaMake(),
|
Schema: dsLBItemSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func existLBID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(lbList.FilterByID(lbId)) != 0, nil
|
return len(lbList.FilterByID(lbId).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
@@ -36,7 +36,7 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
|||||||
return false, err
|
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) {
|
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
@@ -50,7 +50,7 @@ func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(extNetList.FilterByID(extNetID)) != 0, nil
|
return len(extNetList.FilterByID(extNetID).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
@@ -64,5 +64,5 @@ func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bo
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(vinsList.FilterByID(vinsID)) != 0, nil
|
return len(vinsList.FilterByID(vinsID).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,8 +198,6 @@ func resourceLBBackendUpdate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: перенести servers сюда
|
|
||||||
|
|
||||||
return resourceLBBackendRead(ctx, d, m)
|
return resourceLBBackendRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData,
|
|||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.BackendServerDeleteRequest{
|
req := lb.BackendServerDeleteRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
BackendName: d.Get("name").(string),
|
BackendName: d.Get("backend_name").(string),
|
||||||
ServerName: d.Get("backend_name").(string),
|
ServerName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
||||||
|
|||||||
@@ -120,9 +120,6 @@ func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
|
||||||
//TODO: перенести bindings сюда
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,42 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (lb.ListLB, error) {
|
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*lb.ListLB, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.ListRequest{}
|
req := lb.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_id, ok := d.GetOk("account_id"); ok {
|
||||||
|
req.AccountID = uint64(account_id.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
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 status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if front_ip, ok := d.GetOk("front_ip"); ok {
|
||||||
|
req.FrontIP = front_ip.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if back_ip, ok := d.GetOk("back_ip"); ok {
|
||||||
|
req.BackIP = back_ip.(string)
|
||||||
|
}
|
||||||
|
|
||||||
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||||
req.IncludeDeleted = includedeleted.(bool)
|
req.IncludeDeleted = includedeleted.(bool)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,38 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (lb.ListLB, error) {
|
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*lb.ListLB, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.ListDeletedRequest{}
|
req := lb.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 account_id, ok := d.GetOk("account_id"); ok {
|
||||||
|
req.AccountID = uint64(account_id.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
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 front_ip, ok := d.GetOk("front_ip"); ok {
|
||||||
|
req.FrontIP = front_ip.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if back_ip, ok := d.GetOk("back_ip"); ok {
|
||||||
|
req.BackIP = back_ip.(string)
|
||||||
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenLocationsList(ll locations.ListLocations) []map[string]interface{} {
|
func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, l := range ll {
|
for _, l := range ll.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ckey": l.CKey,
|
"ckey": l.CKey,
|
||||||
"meta": flattens.FlattenMeta(l.Meta),
|
"meta": flattens.FlattenMeta(l.Meta),
|
||||||
@@ -72,12 +72,33 @@ func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
|
|
||||||
d.Set("items", flattenLocationsList(locations))
|
d.Set("items", flattenLocationsList(locations))
|
||||||
|
d.Set("entry_count", locations.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
|
"flag": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by flag",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by name",
|
||||||
|
},
|
||||||
|
"by_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by ID",
|
||||||
|
},
|
||||||
|
"location_code": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by location code",
|
||||||
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -137,6 +158,10 @@ func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,17 +42,34 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityLocationsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (locations.ListLocations, error) {
|
func utilityLocationsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*locations.ListLocations, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := locations.ListRequest{}
|
req := locations.ListRequest{}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
|
req.ByID = uint64(by_id.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
if flag, ok := d.GetOk("flag"); ok {
|
||||||
|
req.Flag = flag.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if name, ok := d.GetOk("name"); ok {
|
||||||
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if location_code, ok := d.GetOk("location_code"); ok {
|
||||||
|
req.LocationCode = location_code.(string)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityLocationsListCheckPresence: load locations list")
|
log.Debugf("utilityLocationsListCheckPresence: load locations list")
|
||||||
locationsList, err := c.CloudAPI().Locations().List(ctx, req)
|
locationsList, err := c.CloudAPI().Locations().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func utilityPfwCheckPresence(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pfw := range pfws {
|
for _, pfw := range pfws.Data {
|
||||||
if pfw.ID == uint64(id) {
|
if pfw.ID == uint64(id) {
|
||||||
return &pfw, nil
|
return &pfw, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func resourcesSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"disk_size_max": {
|
"disk_size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"extips": {
|
"extips": {
|
||||||
@@ -223,6 +223,10 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"cu_dm": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -254,14 +258,6 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"resources": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: resourcesSchemaMake(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -50,12 +50,53 @@ func dataSourceRgListRead(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenRgList(rgList))
|
d.Set("items", flattenRgList(rgList))
|
||||||
|
d.Set("entry_count", rgList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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 account ID",
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find by account name",
|
||||||
|
},
|
||||||
|
"created_after": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find RGs created after specific time (unix timestamp)",
|
||||||
|
},
|
||||||
|
"created_before": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find RGs created before specific time (unix timestamp)",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find by status",
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find by lock status",
|
||||||
|
},
|
||||||
"includedeleted": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -222,6 +263,10 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ func dataSourceRgListComputesRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenRgListComputes(listComputes))
|
d.Set("items", flattenRgListComputes(listComputes))
|
||||||
|
d.Set("entry_count", listComputes.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,12 +94,56 @@ func dataSourceRgListComputesSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the RG",
|
Description: "ID of the RG",
|
||||||
},
|
},
|
||||||
"reason": {
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by compute ID",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "reason for action",
|
Description: "Filter by name",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by account ID",
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by tech. status",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by 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": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -204,6 +250,10 @@ func dataSourceRgListComputesSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -50,12 +50,48 @@ func dataSourceRgListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenRgList(rgList))
|
d.Set("items", flattenRgList(rgList))
|
||||||
|
d.Set("entry_count", rgList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
res := 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",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by account ID",
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by account name",
|
||||||
|
},
|
||||||
|
"created_after": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter RGs created after certain point in time (unix timestamp)",
|
||||||
|
},
|
||||||
|
"created_before": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter RGs created before certain point in time (unix timestamp)",
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by lock status",
|
||||||
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -66,7 +102,6 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page size",
|
Description: "Page size",
|
||||||
},
|
},
|
||||||
|
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -208,6 +243,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ func dataSourceRgListLbRead(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
|
|
||||||
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
|
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
|
||||||
d.Set("items", flattenRgListLb(listLb))
|
d.Set("items", flattenRgListLb(listLb))
|
||||||
|
d.Set("entry_count", listLb.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +246,51 @@ func dataSourceRgListLbSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the RG",
|
Description: "ID of the RG",
|
||||||
},
|
},
|
||||||
|
"by_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by ID",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by name",
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by account ID",
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by tech. status",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by status",
|
||||||
|
},
|
||||||
|
"front_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by frontend IP",
|
||||||
|
},
|
||||||
|
"back_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by backend IP",
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -368,6 +414,10 @@ func dataSourceRgListLbSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user