Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f49d9f8860 | |||
| 20050bc169 | |||
| e2ee45ee14 | |||
|
|
294680282e | ||
|
|
2bc0fbae9a | ||
|
|
2453a32d01 | ||
|
|
0602a4b693 | ||
|
|
28b60de115 | ||
|
|
b705ce4aab | ||
|
|
83ca627cea | ||
|
|
739289fbb8 | ||
|
|
c89574c3e6 | ||
|
|
a1e61674c8 | ||
|
|
cb9ff26bb0 | ||
|
|
6932f9d305 | ||
|
|
712f8edf9e | ||
|
|
805ffe1f29 | ||
|
|
bf8d3fb437 | ||
| d7a7eb9cb3 | |||
|
|
b60f32c570 | ||
| 272e385318 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ examples/
|
|||||||
url_scrapping/
|
url_scrapping/
|
||||||
terraform-provider-decort*
|
terraform-provider-decort*
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
|||||||
40
CHANGELOG.md
40
CHANGELOG.md
@@ -1,6 +1,36 @@
|
|||||||
## Version 4.2.4
|
## Version 4.5.2
|
||||||
|
|
||||||
## Bug Fixes
|
### Bugfix
|
||||||
- Fixed incorrect network validation in decort_kvmvm resource
|
- Added resource_limits.cu_dm string field for account, account_consumed_units and account_reserved_units data sources in cloudapi/account
|
||||||
- Fixed inability to remove all networks at once in decort_kvmvm resource
|
- Fixed restore of account resource in cloudapi/account, it happens if restore parameter is set to true
|
||||||
- Deleted "check__ips" (duplicate) field in decort_extnet data source
|
- Fixed restore of bservice resource in cloudapi/bservice, it happens if restore parameter is set to true and only once
|
||||||
|
- Fixed enable of bservice resource in cloudapi/bservice, it happens if enable parameter is set to true
|
||||||
|
- Fixed terraform state update for bservice resource update in cloudapi/bservice
|
||||||
|
- Fixed terraform state update for bservice_group resource update in cloudapi/bservice
|
||||||
|
- Added entry_count field for bservice_snapshot_list data source in cloudapi/bservice
|
||||||
|
- Added items.shareable boolean field for disk_list_unattached data source in cloudapi/disks
|
||||||
|
- Added items.status string field for extnet_list data source in cloudapi/extnet
|
||||||
|
- Fixed multiple minor typos in samples/cloudapi
|
||||||
|
- Added account_name string, created_by string, created_time int, deleted_by string, deleted_time int, network string, rg_id int, rg_name string, updated_by string, updated_by int fields for flipgroup data source and resource in cloudapi/flipgroup
|
||||||
|
- Removed net_mask string, ckey string fields for flipgroup data source and resource in cloudapi/flipgroup
|
||||||
|
- Add meta list field for flipgroup_list data source in cloudapi/flipgroup
|
||||||
|
- Fixed net_mask string field for fligroup_list data source in cloudapi/flipgroup
|
||||||
|
- Fixed id string field for image data source in cloudapi/image
|
||||||
|
- Fix account_name string field for k8s_list data source in cloudapi/k8s
|
||||||
|
- Add network_plugin string field for k8s and k8s_list data sources in cloudapi/k8s
|
||||||
|
- Fixed terraform state update for k8s, k8_cp and k8s_wg resources update in cloudapi/k8s
|
||||||
|
- Add image_name string, interfaces.enabled boolean fields for compute data source in cloudapi/kvmvm
|
||||||
|
- Add the interfaces field to the creation request in cloudapi/kvmvm
|
||||||
|
- Fixed restore of kvmvm resource in cloudapi/kvmvm, it happens if restore parameter is set to true
|
||||||
|
- The logic of network connection has been changed, only the first network connects to the kvmvm in the stopped status, the subsequent ones connect without stopping
|
||||||
|
- Token receipt has been removed from the controller
|
||||||
|
- Add start/stop function after create for lb in cloudapi/lb
|
||||||
|
- Fixed restore of lb resource in cloudapi/lb, it happens if restore parameter is set to true
|
||||||
|
- Add field auth_broker in data source location list in cloudapi/location
|
||||||
|
- Add fields cpu_allocation_parameter and cpu_allocation_ratio in data source rg list lb deleted in cloudapi/rg
|
||||||
|
- Add fields backend_haip and frontend_haip in data source rg list in cloudapi/rg
|
||||||
|
- Change type field Ram QuotaRecord struct in cloudapi/rg/models
|
||||||
|
- Add state upgrader for rg in cloudapi/rg
|
||||||
|
- Add field owner to the creation request in cloudapi/rg
|
||||||
|
- Fixed restore of rg resource in cloudapi/rg, it happens if restore parameter is set to true
|
||||||
|
- Add fields enabled and routesroutes in data source vins in cloudapi/vins
|
||||||
26
Makefile
26
Makefile
@@ -1,30 +1,29 @@
|
|||||||
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.2.4
|
VERSION=4.5.2
|
||||||
#OS_ARCH=darwin_amd64
|
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||||
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 +49,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,17 +59,19 @@ $(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}
|
||||||
|
|||||||
222
README.md
222
README.md
@@ -6,7 +6,10 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
| Версия DECORT API | Версия провайдера Terraform |
|
| Версия DECORT API | Версия провайдера Terraform |
|
||||||
| ------ | ------ |
|
| ------ | ------ |
|
||||||
| 3.8.6 | 4.x.x |
|
| 3.8.9 | 4.5.x |
|
||||||
|
| 3.8.8 | 4.4.x |
|
||||||
|
| 3.8.7 | 4.3.x |
|
||||||
|
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
||||||
| 3.8.5 | 3.4.x |
|
| 3.8.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 |
|
||||||
@@ -24,118 +27,162 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
## Возможности провайдера
|
## Возможности провайдера
|
||||||
|
|
||||||
- Работа с Compute instances,
|
- Режим пользователя:
|
||||||
- Работа с disks,
|
- Работа с accounts,
|
||||||
- Работа с k8s,
|
- Работа с bservice,
|
||||||
- Работа с image,
|
- Работа с disks,
|
||||||
- Работа с reource groups,
|
- Работа с extnets,
|
||||||
- Работа с VINS,
|
- Работа с flipgroups,
|
||||||
- Работа с pfw,
|
- Работа с image,
|
||||||
- Работа с accounts,
|
- Работа с k8s,
|
||||||
- Работа с snapshots,
|
- Работа с Compute instances,
|
||||||
- Работа с pcidevice,
|
- Работа с load balancer,
|
||||||
- Работа с sep,
|
- Работа с locations,
|
||||||
- Работа с vgpu,
|
- Работа с pfw,
|
||||||
- Работа с bservice,
|
- Работа с resource groups,
|
||||||
- Работа с extnets,
|
- Работа с snapshots,
|
||||||
- Работа с locations,
|
- Работа с stacks,
|
||||||
- Работа с load balancer.
|
- Работа с VINS.
|
||||||
|
|
||||||
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
- Режим администратора:
|
||||||
|
- Работа с accounts,
|
||||||
|
- Работа с audits,
|
||||||
|
- Работа с disks,
|
||||||
|
- Работа с extnets,
|
||||||
|
- Работа с flipgroups,
|
||||||
|
- Работа с grids,
|
||||||
|
- Работа с images,
|
||||||
|
- Работа с k8ci,
|
||||||
|
- Работа с k8s,
|
||||||
|
- Работа с Compute instances,
|
||||||
|
- Работа с load balancer,
|
||||||
|
- Работа с pci device,
|
||||||
|
- Работа с resource groups,
|
||||||
|
- Работа с seps,
|
||||||
|
- Работа с stacks,
|
||||||
|
- Работа с VINS.
|
||||||
|
|
||||||
## Начало
|
Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
|
||||||
Старт возможен по двум путям:
|
## Установка
|
||||||
|
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
||||||
1. Установка через собранные пакеты.
|
Чтобы выполнить установку, необходимо:
|
||||||
2. Ручная установка.
|
1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
|
||||||
|
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
|
||||||
### Установка через собранные пакеты.
|
3. Скачать архив.
|
||||||
|
4. Распаковать архив.
|
||||||
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
5. Выполнить скрипт установщика, `install.sh` или `install.bat` для Windows.<br/>
|
||||||
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
*Для запуска `install.sh` не забудьте изменить права доступа к файлу*
|
||||||
|
```bash
|
||||||
|
chmod u+x install.sh
|
||||||
|
```
|
||||||
|
6. Дождаться сообщения об успешной установке. Установщик выведет актуальный блок конфигурации провайдера, скопируйте его
|
||||||
|
```bash
|
||||||
|
DECORT provider version 4.3.0 has been successfully installed
|
||||||
|
|
||||||
|
Copy this provider configuration to main.tf file:
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "4.3.0"
|
||||||
|
source = "basis/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
7. После этого, создайте файл `main.tf` в рабочей директории, которая может находится в любом удобном для пользователя месте.
|
||||||
|
В данном примере, рабочая директория с файлом main.tf находится по пути:
|
||||||
|
```bash
|
||||||
|
~/work/tfdir/main.tf
|
||||||
|
```
|
||||||
|
8. Вставьте в `main.tf` блок конфигурации провайдера, который был выведен на экран установщиком:
|
||||||
|
```terraform
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "4.3.0"
|
||||||
|
source = "basis/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
9. Добавьте в файл блок с инициализацией провайдера.
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "oauth2"
|
authenticator = "decs3o"
|
||||||
#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 +190,24 @@ terraform {
|
|||||||
${host_name}/${namespace}/${type}
|
${host_name}/${namespace}/${type}
|
||||||
```
|
```
|
||||||
|
|
||||||
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
**ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
|
||||||
|
|
||||||
8. В консоле выполнить команду
|
8. Добавьте в файл блок с инициализацией провайдера.
|
||||||
|
```terraform
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "decs3o"
|
||||||
|
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 +216,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`
|
|
||||||
|
|
||||||
Хорошей работы!
|
Хорошей работы!
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Two ways for starting:
|
|||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "oauth2"
|
authenticator = "decs3o"
|
||||||
#controller_url = <DECORT_CONTROLLER_URL>
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
controller_url = "https://ds1.digitalenergy.online"
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
#oauth2_url = <DECORT_SSO_URL>
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
|||||||
20
go.mod
20
go.mod
@@ -3,13 +3,12 @@ module repository.basistech.ru/BASIS/terraform-provider-decort
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.3
|
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
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.16.0
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.7
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -21,10 +20,11 @@ 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.15.4 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.3 // 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
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
@@ -48,7 +48,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,12 +66,12 @@ 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.15.0 // indirect
|
||||||
golang.org/x/sys v0.4.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
golang.org/x/text v0.6.0 // indirect
|
golang.org/x/text v0.14.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
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
49
go.sum
49
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,18 +55,16 @@ 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.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
|
||||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
|
||||||
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
@@ -152,8 +152,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 +191,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 +208,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 +247,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.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||||
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 +263,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.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
|
||||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
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 +291,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.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
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 +302,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.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
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=
|
||||||
@@ -315,8 +320,8 @@ google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U=
|
|||||||
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
|
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -332,5 +337,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.7 h1:1lHhvOsMX5iFQ4z2qmVT7cORbCr+hTeEH9Lk1E2liYE=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3 h1:NtvW72WsAezk0XYKE5+ag+xauIgKWKcbKLy7YTp5Fuc=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.7/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3/go.mod h1:7fj8sgGZFiiExewQeqckCS4WxwOmU0oP6BO6mi1Lpkw=
|
||||||
|
|||||||
@@ -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"
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
@@ -21,18 +21,14 @@ limitations under the License.
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
// "time"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
@@ -41,31 +37,37 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
|
|
||||||
jwt "github.com/golang-jwt/jwt/v4"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// enumerated constants that define authentication modes
|
// enumerated constants that define authentication modes
|
||||||
const (
|
const (
|
||||||
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
||||||
MODE_LEGACY = iota
|
MODE_LEGACY
|
||||||
MODE_OAUTH2 = iota
|
MODE_DECS3O
|
||||||
MODE_JWT = iota
|
MODE_JWT
|
||||||
|
MODE_BVS
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControllerCfg struct {
|
type ControllerCfg struct {
|
||||||
controller_url string // always required
|
controller_url string // always required
|
||||||
auth_mode_code int // always required
|
auth_mode_code int // always required
|
||||||
auth_mode_txt string // always required, it is a text representation of auth mode
|
auth_mode_txt string // always required, it is a text representation of auth mode
|
||||||
|
bvs_user string // required for bvs mode
|
||||||
|
bvs_password string // required for bvs mode
|
||||||
|
domain string // required for bvs mode
|
||||||
|
token config.Token // obtained from BVS provider on successful login in bvs mode
|
||||||
|
path_cfg string // the path of the configuration file entry
|
||||||
|
path_token string // the path of the token file entry
|
||||||
|
time_to_refresh int64 // the number of minutes before the expiration of the token, a refresh will be made
|
||||||
legacy_user string // required for legacy mode
|
legacy_user string // required for legacy mode
|
||||||
legacy_password string // required for legacy mode
|
legacy_password string // required for legacy mode
|
||||||
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
||||||
jwt string // obtained from Outh2 provider on successful login in oauth2 mode, required in jwt mode
|
jwt string // obtained from Outh2 provider on successful login in decs3o mode, required in jwt mode
|
||||||
app_id string // required for oauth2 mode
|
app_id string // required for decs3o and bvs mode
|
||||||
app_secret string // required for oauth2 mode
|
app_secret string // required for decs3o and bvs mode
|
||||||
oauth2_url string // always required
|
oauth2_url string // required for decs3o and bvs mode
|
||||||
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (oauth2 mode) upon successful verification
|
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (decs3o mode) upon successful verification
|
||||||
cc_client *http.Client // assigned when all initial checks successfully passed
|
cc_client *http.Client // assigned when all initial checks successfully passed
|
||||||
caller interfaces.Caller
|
caller interfaces.Caller
|
||||||
}
|
}
|
||||||
@@ -88,17 +90,24 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
legacy_user: d.Get("user").(string),
|
legacy_user: d.Get("user").(string),
|
||||||
legacy_password: d.Get("password").(string),
|
legacy_password: d.Get("password").(string),
|
||||||
legacy_sid: "",
|
legacy_sid: "",
|
||||||
|
bvs_user: d.Get("bvs_user").(string),
|
||||||
|
bvs_password: d.Get("bvs_password").(string),
|
||||||
|
domain: d.Get("domain").(string),
|
||||||
jwt: d.Get("jwt").(string),
|
jwt: d.Get("jwt").(string),
|
||||||
app_id: d.Get("app_id").(string),
|
app_id: d.Get("app_id").(string),
|
||||||
app_secret: d.Get("app_secret").(string),
|
app_secret: d.Get("app_secret").(string),
|
||||||
oauth2_url: d.Get("oauth2_url").(string),
|
oauth2_url: d.Get("oauth2_url").(string),
|
||||||
decort_username: "",
|
decort_username: "",
|
||||||
|
token: config.Token{},
|
||||||
|
path_cfg: d.Get("path_cfg").(string),
|
||||||
|
path_token: d.Get("path_token").(string),
|
||||||
|
time_to_refresh: int64(d.Get("time_to_refresh").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
||||||
|
|
||||||
if ret_config.controller_url == "" {
|
if ret_config.controller_url == "" {
|
||||||
return nil, fmt.Errorf("Empty DECORT cloud controller URL provided.")
|
return nil, fmt.Errorf("empty DECORT cloud controller URL provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
||||||
@@ -107,33 +116,53 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
switch ret_config.auth_mode_txt {
|
switch ret_config.auth_mode_txt {
|
||||||
case "jwt":
|
case "jwt":
|
||||||
if ret_config.jwt == "" {
|
if ret_config.jwt == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'jwt' specified but no JWT provided.")
|
return nil, fmt.Errorf("authenticator mode 'jwt' specified but no JWT provided")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_JWT
|
ret_config.auth_mode_code = MODE_JWT
|
||||||
case "oauth2":
|
case "decs3o":
|
||||||
if ret_config.oauth2_url == "" {
|
if ret_config.oauth2_url == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no OAuth2 URL provided.")
|
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no OAuth2 URL provided")
|
||||||
}
|
}
|
||||||
if ret_config.app_id == "" {
|
if ret_config.app_id == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Application ID provided.")
|
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Application ID provided")
|
||||||
}
|
}
|
||||||
if ret_config.app_secret == "" {
|
if ret_config.app_secret == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Secret ID provided.")
|
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Secret ID provided")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_OAUTH2
|
ret_config.auth_mode_code = MODE_DECS3O
|
||||||
case "legacy":
|
case "legacy":
|
||||||
//
|
//
|
||||||
ret_config.legacy_user = d.Get("user").(string)
|
ret_config.legacy_user = d.Get("user").(string)
|
||||||
if ret_config.legacy_user == "" {
|
if ret_config.legacy_user == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no user provided.")
|
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no user provided")
|
||||||
}
|
}
|
||||||
ret_config.legacy_password = d.Get("password").(string)
|
ret_config.legacy_password = d.Get("password").(string)
|
||||||
if ret_config.legacy_password == "" {
|
if ret_config.legacy_password == "" {
|
||||||
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no password provided.")
|
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no password provided")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_LEGACY
|
ret_config.auth_mode_code = MODE_LEGACY
|
||||||
|
case "bvs":
|
||||||
|
if ret_config.bvs_user == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no user provided")
|
||||||
|
}
|
||||||
|
if ret_config.bvs_password == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no password provided")
|
||||||
|
}
|
||||||
|
if ret_config.oauth2_url == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no bvs URL provided")
|
||||||
|
}
|
||||||
|
if ret_config.app_id == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Application ID provided")
|
||||||
|
}
|
||||||
|
if ret_config.app_secret == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Secret ID provided")
|
||||||
|
}
|
||||||
|
if ret_config.domain == "" {
|
||||||
|
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Domain provided")
|
||||||
|
}
|
||||||
|
ret_config.auth_mode_code = MODE_BVS
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unknown authenticator mode %q provided.", ret_config.auth_mode_txt)
|
return nil, fmt.Errorf("unknown authenticator mode %q provided", ret_config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if allow_unverified_ssl {
|
if allow_unverified_ssl {
|
||||||
@@ -169,30 +198,30 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case MODE_OAUTH2:
|
case MODE_DECS3O:
|
||||||
// on success getOAuth2JWT will set config.jwt to the obtained JWT, so there is no
|
// on success getDECS3OJWT will set config.jwt to the obtained JWT, so there is no
|
||||||
// need to set it once again here
|
// need to set it once again here
|
||||||
_, err := ret_config.getOAuth2JWT()
|
// _, err := ret_config.getDECS3OJWT()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
// we are not verifying the JWT when parsing because actual verification is done on the
|
// we are not verifying the JWT when parsing because actual verification is done on the
|
||||||
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
||||||
// and JWT issuer name (claim "iss")
|
// and JWT issuer name (claim "iss")
|
||||||
parser := jwt.Parser{}
|
// parser := jwt.Parser{}
|
||||||
token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
// if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
||||||
var tbuf bytes.Buffer
|
// var tbuf bytes.Buffer
|
||||||
tbuf.WriteString(claims["username"].(string))
|
// tbuf.WriteString(claims["username"].(string))
|
||||||
tbuf.WriteString("@")
|
// tbuf.WriteString("@")
|
||||||
tbuf.WriteString(claims["iss"].(string))
|
// tbuf.WriteString(claims["iss"].(string))
|
||||||
ret_config.decort_username = tbuf.String()
|
// ret_config.decort_username = tbuf.String()
|
||||||
} else {
|
// } else {
|
||||||
return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.")
|
// return nil, fmt.Errorf("failed to extract user and iss fields from JWT token in oauth2 mode")
|
||||||
}
|
// }
|
||||||
|
|
||||||
sdkConf := config.Config{
|
sdkConf := config.Config{
|
||||||
AppID: ret_config.app_id,
|
AppID: ret_config.app_id,
|
||||||
@@ -203,10 +232,27 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_config.caller = decort.New(sdkConf)
|
ret_config.caller = decort.New(sdkConf)
|
||||||
|
case MODE_BVS:
|
||||||
|
|
||||||
|
sdkConf := config.BVSConfig{
|
||||||
|
AppID: ret_config.app_id,
|
||||||
|
AppSecret: ret_config.app_secret,
|
||||||
|
SSOURL: ret_config.oauth2_url,
|
||||||
|
DecortURL: ret_config.controller_url,
|
||||||
|
SSLSkipVerify: allow_unverified_ssl,
|
||||||
|
Username: ret_config.bvs_user,
|
||||||
|
Password: ret_config.bvs_password,
|
||||||
|
Domain: ret_config.domain,
|
||||||
|
Token: ret_config.token,
|
||||||
|
PathCfg: ret_config.path_cfg,
|
||||||
|
PathToken: ret_config.path_token,
|
||||||
|
TimeToRefresh: ret_config.time_to_refresh,
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_config.caller = decort.NewBVS(sdkConf)
|
||||||
default:
|
default:
|
||||||
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
||||||
return nil, fmt.Errorf("Unknown authenticator mode code %d provided.", ret_config.auth_mode_code)
|
return nil, fmt.Errorf("unknown authenticator mode code %d provided", ret_config.auth_mode_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
||||||
@@ -214,57 +260,57 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
return ret_config, nil
|
return ret_config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) GetDecortUsername() string {
|
// func (config *ControllerCfg) GetDecortUsername() string {
|
||||||
return config.decort_username
|
// return config.decort_username
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (config *ControllerCfg) getOAuth2JWT() (string, error) {
|
// func (config *ControllerCfg) getDECS3OJWT() (string, error) {
|
||||||
// Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
||||||
if config.auth_mode_code == MODE_UNDEF {
|
// if config.auth_mode_code == MODE_UNDEF {
|
||||||
return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.")
|
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode")
|
||||||
}
|
// }
|
||||||
if config.auth_mode_code != MODE_OAUTH2 {
|
// if config.auth_mode_code != MODE_DECS3O {
|
||||||
return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q", config.auth_mode_txt)
|
||||||
}
|
// }
|
||||||
|
|
||||||
params := url.Values{}
|
// params := url.Values{}
|
||||||
params.Add("grant_type", "client_credentials")
|
// params.Add("grant_type", "client_credentials")
|
||||||
params.Add("client_id", config.app_id)
|
// params.Add("client_id", config.app_id)
|
||||||
params.Add("client_secret", config.app_secret)
|
// params.Add("client_secret", config.app_secret)
|
||||||
params.Add("response_type", "id_token")
|
// params.Add("response_type", "id_token")
|
||||||
params.Add("validity", "3600")
|
// params.Add("validity", "3600")
|
||||||
params_str := params.Encode()
|
// params_str := params.Encode()
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str))
|
// req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return "", err
|
// return "", err
|
||||||
}
|
// }
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
// req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
|
// req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
|
||||||
|
|
||||||
resp, err := config.cc_client.Do(req)
|
// resp, err := config.cc_client.Do(req)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return "", err
|
// return "", err
|
||||||
}
|
// }
|
||||||
if resp.StatusCode != http.StatusOK {
|
// if resp.StatusCode != http.StatusOK {
|
||||||
// fmt.Println("response Status:", resp.Status)
|
// // fmt.Println("response Status:", resp.Status)
|
||||||
// fmt.Println("response Headers:", resp.Header)
|
// // fmt.Println("response Headers:", resp.Header)
|
||||||
// fmt.Println("response Headers:", req.URL)
|
// // fmt.Println("response Headers:", req.URL)
|
||||||
return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q",
|
// return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q",
|
||||||
resp.StatusCode, req.URL, config.app_id, params_str)
|
// resp.StatusCode, req.URL, config.app_id, params_str)
|
||||||
}
|
// }
|
||||||
defer resp.Body.Close()
|
// defer resp.Body.Close()
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(resp.Body)
|
// responseData, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return "", err
|
// return "", err
|
||||||
}
|
// }
|
||||||
|
|
||||||
// validation successful - store JWT in the corresponding field of the ControllerCfg structure
|
// // validation successful - store JWT in the corresponding field of the ControllerCfg structure
|
||||||
config.jwt = strings.TrimSpace(string(responseData))
|
// config.jwt = strings.TrimSpace(string(responseData))
|
||||||
|
|
||||||
return config.jwt, nil
|
// return config.jwt, nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
||||||
/*
|
/*
|
||||||
@@ -275,13 +321,13 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
*/
|
*/
|
||||||
if jwt == "" {
|
if jwt == "" {
|
||||||
if config.jwt == "" {
|
if config.jwt == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided.")
|
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided")
|
||||||
}
|
}
|
||||||
jwt = config.jwt
|
jwt = config.jwt
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.oauth2_url == "" {
|
if config.oauth2_url == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided.")
|
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
||||||
@@ -298,7 +344,7 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q.",
|
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q",
|
||||||
resp.StatusCode, req.URL)
|
resp.StatusCode, req.URL)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@@ -314,10 +360,10 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
reason, the method will return false and error.
|
reason, the method will return false and error.
|
||||||
*/
|
*/
|
||||||
if config.auth_mode_code == MODE_UNDEF {
|
if config.auth_mode_code == MODE_UNDEF {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode.")
|
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode")
|
||||||
}
|
}
|
||||||
if config.auth_mode_code != MODE_LEGACY {
|
if config.auth_mode_code != MODE_LEGACY {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q", config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
@@ -338,12 +384,12 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q.",
|
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q",
|
||||||
resp.StatusCode, config.legacy_user, config.controller_url)
|
resp.StatusCode, config.legacy_user, config.controller_url)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(resp.Body)
|
responseData, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -355,100 +401,32 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
||||||
if config.auth_mode_code == MODE_LEGACY {
|
switch config.auth_mode_code {
|
||||||
|
case MODE_LEGACY:
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudAPI()
|
return client.CloudAPI()
|
||||||
|
case MODE_DECS3O:
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudAPI()
|
||||||
|
case MODE_BVS:
|
||||||
|
client, _ := config.caller.(*decort.BVSDecortClient)
|
||||||
|
return client.CloudAPI()
|
||||||
|
default:
|
||||||
|
return &cloudapi.CloudAPI{}
|
||||||
}
|
}
|
||||||
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudAPI()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
||||||
if config.auth_mode_code == MODE_LEGACY {
|
switch config.auth_mode_code {
|
||||||
|
case MODE_LEGACY:
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudBroker()
|
return client.CloudBroker()
|
||||||
|
case MODE_DECS3O:
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudBroker()
|
||||||
|
case MODE_BVS:
|
||||||
|
client, _ := config.caller.(*decort.BVSDecortClient)
|
||||||
|
return client.CloudBroker()
|
||||||
|
default:
|
||||||
|
return &cloudbroker.CloudBroker{}
|
||||||
}
|
}
|
||||||
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudBroker()
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
|
||||||
Authors:
|
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>
|
||||||
|
Nikita Sorokin, <nesorokin@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.
|
||||||
@@ -29,8 +33,33 @@ builds seamlessly.
|
|||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package pfw
|
package dc
|
||||||
|
|
||||||
const ComputePfwListAPI = "/restmachine/cloudbroker/compute/pfwList"
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
const ComputePfwAddAPI = "/restmachine/cloudbroker/compute/pfwAdd"
|
|
||||||
const ComputePfwDelAPI = "/restmachine/cloudbroker/compute/pfwDel"
|
func ErrorsToDiagnostics(errs []error) diag.Diagnostics {
|
||||||
|
if len(errs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
diags := diag.Diagnostics{}
|
||||||
|
|
||||||
|
for _, err := range errs {
|
||||||
|
diags = append(diags, diag.Diagnostic{
|
||||||
|
Severity: diag.Error,
|
||||||
|
Summary: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return diags
|
||||||
|
}
|
||||||
|
|
||||||
|
func ErrorsToWarnings(errs []error) Warnings {
|
||||||
|
w := Warnings{}
|
||||||
|
|
||||||
|
for _, err := range errs {
|
||||||
|
w.Add(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,121 +34,221 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
|
cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
|
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
||||||
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
|
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
|
||||||
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
|
|
||||||
|
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
||||||
|
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
||||||
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDataSourcesMap() map[string]*schema.Resource {
|
func newDataSourcesMap() map[string]*schema.Resource {
|
||||||
return map[string]*schema.Resource{
|
return map[string]*schema.Resource{
|
||||||
"decort_account": account.DataSourceAccount(),
|
"decort_account": account.DataSourceAccount(),
|
||||||
"decort_resgroup": rg.DataSourceResgroup(),
|
"decort_resgroup": rg.DataSourceResgroup(),
|
||||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
"decort_k8s": k8s.DataSourceK8s(),
|
"decort_k8s": k8s.DataSourceK8s(),
|
||||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||||
"decort_disk": disks.DataSourceDisk(),
|
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||||
"decort_disk_list": disks.DataSourceDiskList(),
|
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||||
"decort_rg_list": rg.DataSourceRgList(),
|
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
"decort_disk": disks.DataSourceDisk(),
|
||||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
"decort_disk_list": disks.DataSourceDiskList(),
|
||||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
"decort_rg_list": rg.DataSourceRgList(),
|
||||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||||
"decort_account_list": account.DataSourceAccountList(),
|
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
"decort_account_list": account.DataSourceAccountList(),
|
||||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||||
"decort_bservice": bservice.DataSourceBasicService(),
|
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
"decort_bservice": bservice.DataSourceBasicService(),
|
||||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||||
"decort_extnet": extnet.DataSourceExtnet(),
|
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
"decort_extnet": extnet.DataSourceExtnet(),
|
||||||
"decort_image_list": image.DataSourceImageList(),
|
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||||
"decort_image": image.DataSourceImage(),
|
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||||
"decort_lb": lb.DataSourceLB(),
|
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||||
"decort_lb_list": lb.DataSourceLBList(),
|
"decort_image_list": image.DataSourceImageList(),
|
||||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
"decort_image": image.DataSourceImage(),
|
||||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
"decort_lb": lb.DataSourceLB(),
|
||||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
"decort_lb_list": lb.DataSourceLBList(),
|
||||||
|
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||||
|
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||||
|
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||||
|
"decort_stack": stack.DataSourceStack(),
|
||||||
|
"decort_stack_list": stack.DataSourceStackList(),
|
||||||
|
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||||
|
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||||
|
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||||
|
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||||
|
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
|
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||||
|
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||||
|
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||||
|
|
||||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||||
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
||||||
"decort_cb_account_deleted_list": cb_account.DataSourceAccountDeletedList(),
|
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
|
||||||
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
||||||
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
|
||||||
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
|
||||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
||||||
"decort_cb_image": cb_image.DataSourceImage(),
|
"decort_cb_audit": cb_audit.DataSourceAudit(),
|
||||||
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
|
||||||
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
|
||||||
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
||||||
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
||||||
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
||||||
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
|
||||||
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
|
||||||
"decort_cb_sep": cb_sep.DataSourceSep(),
|
"decort_cb_image": cb_image.DataSourceImage(),
|
||||||
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
||||||
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
|
||||||
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
|
||||||
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
|
||||||
"decort_cb_vgpu": cb_vgpu.DataSourceVGPU(),
|
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
|
||||||
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
||||||
|
"decort_cb_grid_list_emails": cb_grid.DataSourceGridListEmails(),
|
||||||
|
"decort_cb_grid_list_consumption": cb_grid.DataSourceGridListConsumption(),
|
||||||
|
"decort_cb_grid_get_consumption": cb_grid.DataSourceGridGetConsumption(),
|
||||||
|
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
||||||
|
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
||||||
|
"decort_cb_kvmvm": cb_kvmvm.DataSourceCompute(),
|
||||||
|
"decort_cb_kvmvm_affinity_relations": cb_kvmvm.DataSourceComputeAffinityRelations(),
|
||||||
|
"decort_cb_kvmvm_audits": cb_kvmvm.DataSourceComputeAudits(),
|
||||||
|
"decort_cb_kvmvm_boot_order_get": cb_kvmvm.DataSourceComputeBootOrderGet(),
|
||||||
|
"decort_cb_kvmvm_get_audits": cb_kvmvm.DataSourceComputeGetAudits(),
|
||||||
|
"decort_cb_kvmvm_get_console_url": cb_kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
|
"decort_cb_kvmvm_get_log": cb_kvmvm.DataSourceComputeGetLog(),
|
||||||
|
"decort_cb_kvmvm_list": cb_kvmvm.DataSourceComputeList(),
|
||||||
|
"decort_cb_kvmvm_list_deleted": cb_kvmvm.DataSourceComputeListDeleted(),
|
||||||
|
"decort_cb_kvmvm_migrate_storage_info": cb_kvmvm.DataSourceComputeMigrateStorageInfo(),
|
||||||
|
"decort_cb_kvmvm_pci_device_list": cb_kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
|
"decort_cb_kvmvm_pfw_list": cb_kvmvm.DataSourceComputePfwList(),
|
||||||
|
"decort_cb_kvmvm_snapshot_list": cb_kvmvm.DataSourceComputeSnapshotList(),
|
||||||
|
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
|
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
|
||||||
|
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
|
||||||
|
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
||||||
|
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||||
|
"decort_cb_disk_list_deleted": cb_disks.DataSourceDiskListDeleted(),
|
||||||
|
"decort_cb_disk_list_types": cb_disks.DataSourceDiskListTypes(),
|
||||||
|
"decort_cb_disk_list_types_detailed": cb_disks.DataSourceDiskListTypesDetailed(),
|
||||||
|
"decort_cb_disk_list_unattached": cb_disks.DataSourceDiskListUnattached(),
|
||||||
|
"decort_cb_disk_snapshot": cb_disks.DataSourceDiskSnapshot(),
|
||||||
|
"decort_cb_disk_snapshot_list": cb_disks.DataSourceDiskSnapshotList(),
|
||||||
|
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
||||||
|
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
||||||
|
"decort_cb_rg": cb_rg.DataSourceResgroup(),
|
||||||
|
"decort_cb_rg_affinity_group_computes": cb_rg.DataSourceRgAffinityGroupComputes(),
|
||||||
|
"decort_cb_rg_affinity_groups_get": cb_rg.DataSourceRgAffinityGroupsGet(),
|
||||||
|
"decort_cb_rg_affinity_groups_list": cb_rg.DataSourceRgAffinityGroupsList(),
|
||||||
|
"decort_cb_rg_resource_consumption_get": cb_rg.DataSourceRGResourceConsumptionGet(),
|
||||||
|
"decort_cb_rg_resource_consumption_list": cb_rg.DataSourceRGResourceConsumptionList(),
|
||||||
|
"decort_cb_rg_audits": cb_rg.DataSourceRgAudits(),
|
||||||
|
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
||||||
|
"decort_cb_rg_list_deleted": cb_rg.DataSourceRgListDeleted(),
|
||||||
|
"decort_cb_rg_list_computes": cb_rg.DataSourceRgListComputes(),
|
||||||
|
"decort_cb_rg_list_lb": cb_rg.DataSourceRgListLb(),
|
||||||
|
"decort_cb_rg_list_pfw": cb_rg.DataSourceRgListPfw(),
|
||||||
|
"decort_cb_rg_list_vins": cb_rg.DataSourceRgListVins(),
|
||||||
|
"decort_cb_rg_usage": cb_rg.DataSourceRgUsage(),
|
||||||
|
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
||||||
|
"decort_cb_sep": cb_sep.DataSourceSep(),
|
||||||
|
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
||||||
|
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
||||||
|
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
||||||
|
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
||||||
|
"decort_cb_lb": cb_lb.DataSourceLB(),
|
||||||
|
"decort_cb_lb_list": cb_lb.DataSourceLBList(),
|
||||||
|
"decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(),
|
||||||
|
"decort_cb_flipgroup_list": cb_flipgroup.DataSourceFlipgroupList(),
|
||||||
|
"decort_cb_flipgroup": cb_flipgroup.DataSourceFlipgroup(),
|
||||||
|
"decort_cb_stack_list": cb_stack.DataSourceStacksList(),
|
||||||
|
"decort_cb_stack": cb_stack.DataSourceStack(),
|
||||||
|
"decort_cb_vins": cb_vins.DataSourceVins(),
|
||||||
|
"decort_cb_vins_list": cb_vins.DataSourceVinsList(),
|
||||||
|
"decort_cb_vins_audits": cb_vins.DataSourceVinsAudits(),
|
||||||
|
"decort_cb_vins_ip_list": cb_vins.DataSourceVinsIpList(),
|
||||||
|
"decort_cb_vins_list_deleted": cb_vins.DataSourceVinsListDeleted(),
|
||||||
|
"decort_cb_vins_ext_net_list": cb_vins.DataSourceVinsExtNetList(),
|
||||||
|
"decort_cb_vins_nat_rule_list": cb_vins.DataSourceVinsNatRuleList(),
|
||||||
|
"decort_cb_vins_static_route": cb_vins.DataSourceStaticRoute(),
|
||||||
|
"decort_cb_vins_static_route_list": cb_vins.DataSourceStaticRouteList(),
|
||||||
|
"decort_cb_k8ci": cb_k8ci.DataSourceK8CI(),
|
||||||
|
"decort_cb_k8ci_list": cb_k8ci.DataSourceK8CIList(),
|
||||||
|
"decort_cb_k8ci_list_deleted": cb_k8ci.DataSourceK8CIListDeleted(),
|
||||||
|
"decort_cb_k8s": cb_k8s.DataSourceK8s(),
|
||||||
|
"decort_cb_k8s_list": cb_k8s.DataSourceK8sList(),
|
||||||
|
"decort_cb_k8s_list_deleted": cb_k8s.DataSourceK8sListDeleted(),
|
||||||
|
"decort_cb_k8s_wg": cb_k8s.DataSourceK8sWg(),
|
||||||
|
"decort_cb_k8s_wg_cloud_init": cb_k8s.DataSourceK8sWgCloudInit(),
|
||||||
|
"decort_cb_k8s_wg_list": cb_k8s.DataSourceK8sWgList(),
|
||||||
|
"decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func Provider() *schema.Provider {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating
|
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
||||||
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.",
|
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"oauth2_url": {
|
"oauth2_url": {
|
||||||
@@ -49,7 +49,7 @@ func Provider() *schema.Provider {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
||||||
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
|
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"controller_url": {
|
"controller_url": {
|
||||||
@@ -74,18 +74,39 @@ func Provider() *schema.Provider {
|
|||||||
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"bvs_user": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
||||||
|
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"bvs_password": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
||||||
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"domain": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
||||||
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
|
},
|
||||||
|
|
||||||
"app_id": {
|
"app_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
||||||
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.",
|
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_secret": {
|
"app_secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
||||||
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.",
|
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"jwt": {
|
"jwt": {
|
||||||
@@ -101,6 +122,24 @@ func Provider() *schema.Provider {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"path_cfg": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "The path of the configuration file entry",
|
||||||
|
},
|
||||||
|
|
||||||
|
"path_token": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "The path of the token file entry",
|
||||||
|
},
|
||||||
|
|
||||||
|
"time_to_refresh": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: newResourcesMap(),
|
ResourcesMap: newResourcesMap(),
|
||||||
|
|||||||
@@ -37,14 +37,16 @@ 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_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
|
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
|
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
cb_pfw "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pfw"
|
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_snapshot "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/snapshot"
|
|
||||||
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,22 +73,31 @@ func newResourcesMap() map[string]*schema.Resource {
|
|||||||
"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_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||||
|
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
||||||
|
|
||||||
"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_extnet_static_route": cb_extnet.ResourceStaticRoute(),
|
||||||
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
"decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
|
||||||
"decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
"decort_cb_image": cb_image.ResourceImage(),
|
||||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||||
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||||
"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_k8ci": cb_k8ci.ResourceK8CI(),
|
||||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
|
||||||
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||||
|
"decort_cb_vins_static_route": cb_vins.ResourceStaticRoute(),
|
||||||
|
"decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
|
||||||
|
"decort_cb_lb": cb_lb.ResourceLB(),
|
||||||
|
"decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
|
||||||
|
"decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
|
||||||
|
"decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
|
||||||
|
"decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
|
||||||
|
"decort_cb_rg": cb_rg.ResourceResgroup(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,11 @@ 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 {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +100,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,
|
||||||
@@ -268,13 +274,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,
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ func flattenAccountAuditsList(aal account.ListAudits) []map[string]interface{} {
|
|||||||
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -76,12 +76,14 @@ func flattenAccountComputesList(acl account.ListComputes) []map[string]interface
|
|||||||
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +95,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 +234,10 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import (
|
|||||||
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceD
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("cu_c", accountConsumedUnits.CUC)
|
d.Set("cu_c", accountConsumedUnits.CUC)
|
||||||
d.Set("cu_d", accountConsumedUnits.CUD)
|
d.Set("cu_d", accountConsumedUnits.CUD)
|
||||||
|
d.Set("cu_dm", accountConsumedUnits.CUDM)
|
||||||
d.Set("cu_i", accountConsumedUnits.CUI)
|
d.Set("cu_i", accountConsumedUnits.CUI)
|
||||||
d.Set("cu_m", accountConsumedUnits.CUM)
|
d.Set("cu_m", accountConsumedUnits.CUM)
|
||||||
d.Set("cu_np", accountConsumedUnits.CUNP)
|
d.Set("cu_np", accountConsumedUnits.CUNP)
|
||||||
@@ -74,6 +76,10 @@ func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"cu_dm": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import (
|
|||||||
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,24 @@ import (
|
|||||||
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +73,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,
|
||||||
@@ -62,12 +62,14 @@ func flattenAccountDisksList(adl account.ListDisks) []map[string]interface{} {
|
|||||||
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +81,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 +148,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,
|
||||||
@@ -77,12 +77,14 @@ func flattenAccountFlipGroupsList(afgl account.ListFLIPGroups) []map[string]inte
|
|||||||
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +96,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 +229,10 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
flattenResourceConsumption(d, accountResourceConsumptionRec)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"consumed": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceAccResourceSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"reserved": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceAccResourceSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"resource_limits": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceResourceLimitsSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"cu_c": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"cu_d": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"cu_dm": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"cu_i": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"cu_m": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"cu_np": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu_units": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceAccountResourceConsumptionGet() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceAccountResourceConsumptionGetRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceAccountResourceConsumptionGetSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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,
|
||||||
@@ -78,18 +78,40 @@ func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
|
|||||||
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +186,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import (
|
|||||||
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceD
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("cu_c", accountReservedUnits.CUC)
|
d.Set("cu_c", accountReservedUnits.CUC)
|
||||||
d.Set("cu_d", accountReservedUnits.CUD)
|
d.Set("cu_d", accountReservedUnits.CUD)
|
||||||
|
d.Set("cu_dm", accountReservedUnits.CUDM)
|
||||||
d.Set("cu_i", accountReservedUnits.CUI)
|
d.Set("cu_i", accountReservedUnits.CUI)
|
||||||
d.Set("cu_m", accountReservedUnits.CUM)
|
d.Set("cu_m", accountReservedUnits.CUM)
|
||||||
d.Set("cu_np", accountReservedUnits.CUNP)
|
d.Set("cu_np", accountReservedUnits.CUNP)
|
||||||
@@ -74,6 +76,10 @@ func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"cu_dm": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenAccResourceConsumption(accountResourceConsumptionList))
|
||||||
|
d.Set("entry_count", accountResourceConsumptionList.EntryCount)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"consumed": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceAccResourceSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"reserved": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceAccResourceSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceAccResourceSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_ips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_traffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dataSourceSepsSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceAccountResourceConsumptionList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceAccountResourceConsumptionListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceAccountResourceConsumptionListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,9 +42,9 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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),
|
||||||
@@ -119,12 +119,14 @@ func flattenAccRGResources(argr account.RGResources) []map[string]interface{} {
|
|||||||
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +138,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 +348,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, len(atl.Data))
|
||||||
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,
|
||||||
@@ -66,13 +66,14 @@ func flattenAccountTemplatesList(atl account.ListTemplates) []map[string]interfa
|
|||||||
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
||||||
|
d.Set("entry_count", accountTemplatesList.EntryCount)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +84,35 @@ 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,
|
||||||
|
},
|
||||||
|
"image_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Find by image id",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by name",
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by type",
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -132,6 +162,10 @@ func dataSourceAccountTemplatesListSchemaMake() 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 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,
|
||||||
@@ -73,12 +73,14 @@ func flattenAccountVinsList(avl account.ListVINS) []map[string]interface{} {
|
|||||||
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +92,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 +199,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)
|
||||||
@@ -21,7 +21,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
|||||||
d.Set("guid", acc.GUID)
|
d.Set("guid", acc.GUID)
|
||||||
d.Set("account_id", acc.ID)
|
d.Set("account_id", acc.ID)
|
||||||
d.Set("account_name", acc.Name)
|
d.Set("account_name", acc.Name)
|
||||||
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
|
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||||
d.Set("send_access_emails", acc.SendAccessEmails)
|
d.Set("send_access_emails", acc.SendAccessEmails)
|
||||||
d.Set("status", acc.Status)
|
d.Set("status", acc.Status)
|
||||||
d.Set("updated_time", acc.UpdatedTime)
|
d.Set("updated_time", acc.UpdatedTime)
|
||||||
@@ -79,11 +79,19 @@ func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
|
func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
|
||||||
|
d.Set("account_id", acc.AccountID)
|
||||||
|
d.Set("consumed", flattenAccResource(acc.Consumed))
|
||||||
|
d.Set("reserved", flattenAccResource(acc.Reserved))
|
||||||
|
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"cu_c": rl.CUC,
|
"cu_c": rl.CUC,
|
||||||
"cu_d": rl.CUD,
|
"cu_d": rl.CUD,
|
||||||
|
"cu_dm": rl.CUDM,
|
||||||
"cu_i": rl.CUI,
|
"cu_i": rl.CUI,
|
||||||
"cu_m": rl.CUM,
|
"cu_m": rl.CUM,
|
||||||
"cu_np": rl.CUNP,
|
"cu_np": rl.CUNP,
|
||||||
@@ -95,15 +103,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)
|
||||||
@@ -124,14 +132,28 @@ func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[stri
|
|||||||
func flattenAccResource(r account.Resource) []map[string]interface{} {
|
func flattenAccResource(r account.Resource) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"cpu": r.CPU,
|
"cpu": r.CPU,
|
||||||
"disksize": r.DiskSize,
|
"disk_size": r.DiskSize,
|
||||||
"extips": r.ExtIPs,
|
"disk_size_max": r.DiskSizeMax,
|
||||||
"exttraffic": r.ExtTraffic,
|
"ext_ips": r.ExtIPs,
|
||||||
"gpu": r.GPU,
|
"ext_traffic": r.ExtTraffic,
|
||||||
"ram": r.RAM,
|
"gpu": r.GPU,
|
||||||
"seps": flattenAccountSeps(r.SEPs),
|
"ram": r.RAM,
|
||||||
|
"seps": flattenAccountSeps(r.SEPs),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0, len(lrc.Data))
|
||||||
|
for _, rc := range lrc.Data {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"consumed": flattenAccResource(rc.Consumed),
|
||||||
|
"reserved": flattenAccResource(rc.Reserved),
|
||||||
|
"account_id": rc.AccountID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,135 +47,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
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 {
|
||||||
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
|
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
// c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -188,22 +67,23 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
switch acc.Status {
|
switch acc.Status {
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceAccountCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceAccountCreate(ctx, d, m)
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
|
|
||||||
req := account.RestoreRequest{
|
// req := account.RestoreRequest{
|
||||||
AccountID: id,
|
// AccountID: id,
|
||||||
}
|
// }
|
||||||
|
|
||||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
// _, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return diag.FromErr(err)
|
// return diag.FromErr(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
hasChanged = true
|
// hasChanged = true
|
||||||
case status.Disabled:
|
case status.Disabled:
|
||||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||||
case status.Confirmed:
|
case status.Confirmed:
|
||||||
@@ -263,21 +143,23 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
switch acc.Status {
|
switch acc.Status {
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceAccountCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceAccountCreate(ctx, d, m)
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
|
if d.Get("restore").(bool) {
|
||||||
|
req := account.RestoreRequest{
|
||||||
|
AccountID: accountId,
|
||||||
|
}
|
||||||
|
|
||||||
req := account.RestoreRequest{
|
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||||
AccountID: accountId,
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hasChanged = true
|
|
||||||
case status.Disabled:
|
case status.Disabled:
|
||||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||||
case status.Confirmed:
|
case status.Confirmed:
|
||||||
@@ -303,14 +185,14 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Account().Disable(ctx, reqSwitch)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
_, err := c.CloudAPI().Account().Disable(ctx, reqSwitch)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,15 +281,13 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
if d.HasChange("restore") {
|
if d.HasChange("restore") {
|
||||||
restore := d.Get("restore").(bool)
|
restore := d.Get("restore").(bool)
|
||||||
if restore {
|
if restore && acc.Status == "DELETED" {
|
||||||
if acc.Status == "DELETED" {
|
req := account.RestoreRequest{
|
||||||
req := account.RestoreRequest{
|
AccountID: accountId,
|
||||||
AccountID: accountId,
|
}
|
||||||
}
|
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -629,13 +509,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 {
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
id := uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
|
req:= account.GetResourceConsumptionRequest {
|
||||||
|
AccountID: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
|
||||||
|
accountResourceConsumptionRec, err := c.CloudAPI().Account().GetResourceConsumption(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountResourceConsumptionRec, nil
|
||||||
|
}
|
||||||
@@ -42,23 +42,31 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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")
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityAccountResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListResourceConsumption, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
log.Debugf("utilityAccountResourceConsumptionListCheckPresence: load")
|
||||||
|
accountResourceConsumptionList, err := c.CloudAPI().Account().ListResourceConsumption(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountResourceConsumptionList, nil
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"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,16 +42,34 @@ 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
|
|
||||||
|
|
||||||
id = uint64(d.Get("account_id").(int))
|
id := uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListTemplatesRequest{
|
req := account.ListTemplatesRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
||||||
|
req.IncludeDeleted = include_deleted.(bool)
|
||||||
|
}
|
||||||
|
if imageId, ok := d.GetOk("image_id"); ok {
|
||||||
|
req.ImageID = uint64(imageId.(int))
|
||||||
|
}
|
||||||
|
if name, ok := d.GetOk("name"); ok {
|
||||||
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
|
if typeTemplates, ok := d.GetOk("type"); ok {
|
||||||
|
req.Type = typeTemplates.(string)
|
||||||
|
}
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
req.Page = uint64(page.(int))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
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 {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import (
|
|||||||
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"disk_total": {
|
"disk_total": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
@@ -185,13 +186,13 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"groups_name": {
|
// "groups_name": {
|
||||||
Type: schema.TypeList,
|
// Type: schema.TypeList,
|
||||||
Computed: true,
|
// Computed: true,
|
||||||
Elem: &schema.Schema{
|
// Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
// Type: schema.TypeString,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -44,16 +44,31 @@ import (
|
|||||||
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +80,6 @@ func DataSourceBasicServiceDeletedList() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceBasicServiceListSchemaMake(),
|
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import (
|
|||||||
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -77,18 +77,50 @@ func flattenBasicServiceList(bsl bservice.ListBasicServices) []map[string]interf
|
|||||||
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +240,10 @@ func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,14 @@ import (
|
|||||||
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList))
|
d.Set("items", flattenBasicServiceSnapshotsList(basicServiceSnapshotList))
|
||||||
|
d.Set("entry_count", basicServiceSnapshotList.EntryCount)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +86,10 @@ func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.Reco
|
|||||||
d.Set("rg_name", bsg.RGName)
|
d.Set("rg_name", bsg.RGName)
|
||||||
d.Set("role", bsg.Role)
|
d.Set("role", bsg.Role)
|
||||||
d.Set("sep_id", bsg.SEPID)
|
d.Set("sep_id", bsg.SEPID)
|
||||||
|
d.Set("sep_pool", bsg.PoolName)
|
||||||
d.Set("seq_no", bsg.SeqNo)
|
d.Set("seq_no", bsg.SeqNo)
|
||||||
d.Set("status", bsg.Status)
|
d.Set("status", bsg.Status)
|
||||||
d.Set("tech_status", bsg.TechStatus)
|
d.Set("tech_status", bsg.TechStatus)
|
||||||
@@ -110,7 +111,7 @@ func flattenBasicServiceComputes(bscs bservice.ListComputes) []map[string]interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(bsrvss))
|
||||||
for _, bsrvs := range bsrvss {
|
for _, bsrvs := range bsrvss {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"guid": bsrvs.GUID,
|
"guid": bsrvs.GUID,
|
||||||
@@ -122,3 +123,17 @@ func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]in
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenBasicServiceSnapshotsList(bsrvss *bservice.ListInfoSnapshots) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0, len(bsrvss.Data))
|
||||||
|
for _, bsrvs := range bsrvss.Data {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"guid": bsrvs.GUID,
|
||||||
|
"label": bsrvs.Label,
|
||||||
|
"timestamp": bsrvs.Timestamp,
|
||||||
|
"valid": bsrvs.Valid,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,13 +77,49 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
d.SetId(strconv.FormatUint(serviceId, 10))
|
d.SetId(strconv.FormatUint(serviceId, 10))
|
||||||
d.Set("service_id", serviceId)
|
d.Set("service_id", serviceId)
|
||||||
|
|
||||||
|
service, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
|
||||||
|
log.Debugf("trying to enable bservice %v", serviceId)
|
||||||
|
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||||
|
ServiceID: serviceId,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if d.Get("start").(bool) && d.Get("enable").(bool) {
|
||||||
|
log.Debugf("trying to enable bservice %v", serviceId)
|
||||||
|
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||||
|
ServiceID: serviceId,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("trying to start bservice %v", serviceId)
|
||||||
|
_, err = c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
|
||||||
|
ServiceID: serviceId,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resourceBasicServiceRead(ctx, d, m)
|
return resourceBasicServiceRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceBasicServiceRead")
|
log.Debugf("resourceBasicServiceRead")
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
// c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -104,29 +140,30 @@ func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
case status.Disabling:
|
case status.Disabling:
|
||||||
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
restoreReq := bservice.RestoreRequest{
|
// restoreReq := bservice.RestoreRequest{
|
||||||
ServiceID: id,
|
// ServiceID: id,
|
||||||
}
|
// }
|
||||||
enableReq := bservice.EnableRequest{
|
// enableReq := bservice.EnableRequest{
|
||||||
ServiceID: id,
|
// ServiceID: id,
|
||||||
}
|
// }
|
||||||
|
|
||||||
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
// _, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return diag.FromErr(err)
|
// return diag.FromErr(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
// _, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return diag.FromErr(err)
|
// return diag.FromErr(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
hasChanged = true
|
// hasChanged = true
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceBasicServiceCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceBasicServiceCreate(ctx, d, m)
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||||
case status.Restoring:
|
case status.Restoring:
|
||||||
@@ -203,28 +240,50 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
restoreReq := bservice.RestoreRequest{
|
|
||||||
ServiceID: id,
|
if restore, ok := d.GetOk("restore"); ok {
|
||||||
}
|
if restore.(bool) {
|
||||||
enableReq := bservice.EnableRequest{
|
restoreReq := bservice.RestoreRequest{
|
||||||
ServiceID: id,
|
ServiceID: id,
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hasChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
if err != nil {
|
if enable.(bool) {
|
||||||
return diag.FromErr(err)
|
enableReq := bservice.EnableRequest{
|
||||||
|
ServiceID: id,
|
||||||
|
}
|
||||||
|
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
hasChanged = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
if start, ok := d.GetOk("start"); ok {
|
||||||
if err != nil {
|
if start.(bool) {
|
||||||
return diag.FromErr(err)
|
startReq := bservice.StartRequest{
|
||||||
|
ServiceID: id,
|
||||||
|
}
|
||||||
|
_, err = c.CloudAPI().BService().Start(ctx, startReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
hasChanged = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged = true
|
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceBasicServiceCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceBasicServiceCreate(ctx, d, m)
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||||
case status.Restoring:
|
case status.Restoring:
|
||||||
@@ -262,19 +321,6 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("restore") {
|
|
||||||
restore := d.Get("restore").(bool)
|
|
||||||
if restore {
|
|
||||||
req := bservice.RestoreRequest{
|
|
||||||
ServiceID: uint64(d.Get("service_id").(int)),
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().BService().Restore(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("start") {
|
if d.HasChange("start") {
|
||||||
start := d.Get("start").(bool)
|
start := d.Get("start").(bool)
|
||||||
if start {
|
if start {
|
||||||
@@ -365,10 +411,9 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return resourceBasicServiceRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainsSnapshot(els []interface{}, el interface{}) bool {
|
func isContainsSnapshot(els []interface{}, el interface{}) bool {
|
||||||
@@ -533,7 +578,7 @@ func resourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"disk_total": {
|
"disk_total": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
|
|||||||
@@ -68,6 +68,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
|
|||||||
req.TimeoutStart = uint64(timeoutStart.(int))
|
req.TimeoutStart = uint64(timeoutStart.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///4.4.0
|
||||||
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
|
req.SEPID = uint64(sepId.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
if sepPool, ok := d.GetOk("sep_pool"); ok {
|
||||||
|
req.SEPPool = sepPool.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||||
|
req.UserData = cloudInit.(string)
|
||||||
|
}
|
||||||
|
///
|
||||||
|
|
||||||
if vinses, ok := d.GetOk("vinses"); ok {
|
if vinses, ok := d.GetOk("vinses"); ok {
|
||||||
res := []uint64{}
|
res := []uint64{}
|
||||||
for _, vins := range vinses.([]interface{}) {
|
for _, vins := range vinses.([]interface{}) {
|
||||||
@@ -93,6 +107,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
|
|||||||
d.SetId(strconv.FormatUint(compgroupId, 10))
|
d.SetId(strconv.FormatUint(compgroupId, 10))
|
||||||
d.Set("compgroup_id", compgroupId)
|
d.Set("compgroup_id", compgroupId)
|
||||||
|
|
||||||
|
serviceId := uint64(d.Get("service_id").(int))
|
||||||
|
|
||||||
|
if d.Get("start").(bool) {
|
||||||
|
log.Debugf("trying to start bservice group %v", compgroupId)
|
||||||
|
_, err := c.CloudAPI().BService().GroupStart(ctx, bservice.GroupStartRequest{
|
||||||
|
ServiceID: serviceId,
|
||||||
|
CompGroupID: compgroupId,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resourceBasicServiceGroupRead(ctx, d, m)
|
return resourceBasicServiceGroupRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +143,7 @@ func resourceBasicServiceGroupDelete(ctx context.Context, d *schema.ResourceData
|
|||||||
|
|
||||||
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +335,7 @@ func resourceBasicServiceGroupUpdate(ctx context.Context, d *schema.ResourceData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return resourceBasicServiceGroupRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainsParent(els []interface{}, el interface{}) bool {
|
func isContainsParent(els []interface{}, el interface{}) bool {
|
||||||
@@ -362,6 +391,25 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "compute driver like a KVM_X86, KVM_PPC, etc.",
|
Description: "compute driver like a KVM_X86, KVM_PPC, etc.",
|
||||||
},
|
},
|
||||||
|
///4.4.0
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "storage endpoint provider ID",
|
||||||
|
},
|
||||||
|
"sep_pool": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "pool to use if sepId is set, can be also empty if needed to be chosen by system",
|
||||||
|
},
|
||||||
|
"cloud_init": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
|
||||||
|
},
|
||||||
|
///
|
||||||
"role": {
|
"role": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -524,10 +572,6 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seq_no": {
|
"seq_no": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListSnapshots, error) {
|
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListInfoSnapshots, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import (
|
|||||||
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,18 +44,50 @@ import (
|
|||||||
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
@@ -66,6 +98,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "type of the disks",
|
Description: "type of the disks",
|
||||||
},
|
},
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "find by sep ID",
|
||||||
|
},
|
||||||
|
"pool_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "find by pool name",
|
||||||
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -434,6 +476,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,17 +44,29 @@ import (
|
|||||||
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("types", listTypes)
|
d.Set("types", listTypes.Data)
|
||||||
|
d.Set("entry_count", listTypes.EntryCount)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"types": {
|
"types": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -63,6 +75,10 @@ func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,16 +38,18 @@ 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{})),
|
||||||
"sep_id": toMap["sepId"].(float64),
|
"sep_id": toMap["sepId"].(float64),
|
||||||
|
"sep_name": toMap["sepName"].(string),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
@@ -59,8 +61,9 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
for _, pool := range pools {
|
for _, pool := range pools {
|
||||||
toMap := pool.(map[string]interface{})
|
toMap := pool.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"name": toMap["name"].(string),
|
"name": toMap["name"].(string),
|
||||||
"types": toMap["types"].([]interface{}),
|
"system": toMap["system"].(string),
|
||||||
|
"types": toMap["types"].([]interface{}),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
@@ -71,17 +74,29 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
|
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
|
||||||
|
d.Set("entry_count", listTypesDetailed.EntryCount)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -97,6 +112,10 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Pool name",
|
Description: "Pool name",
|
||||||
},
|
},
|
||||||
|
"system": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"types": {
|
"types": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -113,9 +132,17 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
|
"sep_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ import (
|
|||||||
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +73,56 @@ 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",
|
||||||
},
|
},
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "find by sep ID",
|
||||||
|
},
|
||||||
|
"pool_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "find by pool name",
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "type of the disks",
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -330,6 +376,11 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
Description: "shareable",
|
||||||
|
},
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -401,6 +452,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import (
|
|||||||
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import (
|
|||||||
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,18 +43,433 @@ 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 {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", 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 +480,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, len(ul.Data))
|
||||||
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,
|
||||||
@@ -56,6 +56,7 @@ func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interf
|
|||||||
"res_name": unattachedDisk.ResName,
|
"res_name": unattachedDisk.ResName,
|
||||||
"role": unattachedDisk.Role,
|
"role": unattachedDisk.Role,
|
||||||
"sep_id": unattachedDisk.SEPID,
|
"sep_id": unattachedDisk.SEPID,
|
||||||
|
"shareable": unattachedDisk.Shareable,
|
||||||
"size_max": unattachedDisk.SizeMax,
|
"size_max": unattachedDisk.SizeMax,
|
||||||
"size_used": unattachedDisk.SizeUsed,
|
"size_used": unattachedDisk.SizeUsed,
|
||||||
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
||||||
@@ -120,7 +121,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||||
res := make([]interface{}, 0)
|
res := make([]interface{}, 0, len(sl))
|
||||||
for _, snapshot := range sl {
|
for _, snapshot := range sl {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"guid": snapshot.GUID,
|
"guid": snapshot.GUID,
|
||||||
@@ -136,9 +137,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, len(dl.Data))
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
c := m.(*controller.ControllerCfg)
|
// c := m.(*controller.ControllerCfg)
|
||||||
warnings := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
@@ -157,23 +158,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
case status.Destroyed, status.Purged:
|
case status.Destroyed, status.Purged:
|
||||||
d.Set("disk_id", 0)
|
d.Set("disk_id", 0)
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceDiskCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceDiskCreate(ctx, d, m)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
hasChangeState = true
|
// hasChangeState = true
|
||||||
req := disks.RestoreRequest{
|
// req := disks.RestoreRequest{
|
||||||
DiskID: disk.ID,
|
// DiskID: disk.ID,
|
||||||
}
|
// }
|
||||||
|
|
||||||
if reason, ok := d.GetOk("reason"); ok {
|
// if reason, ok := d.GetOk("reason"); ok {
|
||||||
req.Reason = reason.(string)
|
// req.Reason = reason.(string)
|
||||||
} else {
|
// } else {
|
||||||
req.Reason = "Terraform automatic restore"
|
// req.Reason = "Terraform automatic restore"
|
||||||
}
|
// }
|
||||||
|
|
||||||
_, err := c.CloudAPI().Disks().Restore(ctx, req)
|
// _, err := c.CloudAPI().Disks().Restore(ctx, req)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
warnings.Add(err)
|
// warnings.Add(err)
|
||||||
}
|
// }
|
||||||
case status.Assigned:
|
case status.Assigned:
|
||||||
case status.Modeled:
|
case status.Modeled:
|
||||||
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
|
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
|
||||||
@@ -218,6 +220,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +230,8 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
case status.Destroyed, status.Purged:
|
case status.Destroyed, status.Purged:
|
||||||
d.Set("disk_id", 0)
|
d.Set("disk_id", 0)
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceDiskCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceDiskCreate(ctx, d, m)
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
hasChangeState = true
|
hasChangeState = true
|
||||||
req := disks.RestoreRequest{
|
req := disks.RestoreRequest{
|
||||||
@@ -271,7 +275,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
Size: uint64(newSize.(int)),
|
Size: uint64(newSize.(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().Disks().Resize(ctx, req)
|
_, err := c.CloudAPI().Disks().Resize2(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -375,9 +379,9 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"disk_name": {
|
"disk_name": {
|
||||||
@@ -391,9 +395,9 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Size in GB",
|
Description: "Size in GB",
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "ID of the grid (platform)",
|
Description: "ID of the grid (platform)",
|
||||||
},
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,15 +170,15 @@ func resourceDiskSnapshotDelete(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"label": {
|
"label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "Name of the snapshot",
|
Description: "Name of the snapshot",
|
||||||
},
|
},
|
||||||
"rollback": {
|
"rollback": {
|
||||||
|
|||||||
@@ -43,22 +43,46 @@ 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{}
|
||||||
|
|
||||||
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
|
req.ByID = uint64(by_id.(int))
|
||||||
|
}
|
||||||
|
if name, ok := d.GetOk("name"); ok {
|
||||||
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
|
if account_name, ok := d.GetOk("account_name"); ok {
|
||||||
|
req.AccountName = account_name.(string)
|
||||||
|
}
|
||||||
|
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||||
|
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||||
|
}
|
||||||
|
if status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
if shared, ok := d.GetOk("shared"); ok {
|
||||||
|
req.Shared = shared.(bool)
|
||||||
|
}
|
||||||
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
|
req.AccountID = uint64(accountId.(int))
|
||||||
|
}
|
||||||
|
if diskType, ok := d.GetOk("type"); ok {
|
||||||
|
req.Type = strings.ToUpper(diskType.(string))
|
||||||
|
}
|
||||||
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
|
req.AccountID = uint64(sepId.(int))
|
||||||
|
}
|
||||||
|
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||||
|
req.Pool = pool_name.(string)
|
||||||
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
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 diskType, ok := d.GetOk("type"); ok {
|
|
||||||
req.Type = strings.ToUpper(diskType.(string))
|
|
||||||
}
|
|
||||||
if accountId, ok := d.GetOk("accountId"); ok {
|
|
||||||
req.AccountID = uint64(accountId.(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
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,40 @@ 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 accountId, ok := d.GetOk("accountId"); ok {
|
|
||||||
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
|
req.ByID = uint64(by_id.(int))
|
||||||
|
}
|
||||||
|
if account_name, ok := d.GetOk("account_name"); ok {
|
||||||
|
req.AccountName = account_name.(string)
|
||||||
|
}
|
||||||
|
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||||
|
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||||
|
}
|
||||||
|
if status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
if diskType, ok := d.GetOk("type"); ok {
|
||||||
|
req.Type = diskType.(string)
|
||||||
|
}
|
||||||
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
|
req.AccountID = uint64(sepId.(int))
|
||||||
|
}
|
||||||
|
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||||
|
req.Pool = pool_name.(string)
|
||||||
|
}
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
req.Page = uint64(page.(int))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
||||||
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
||||||
|
|||||||
@@ -41,12 +41,19 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
req.Page = uint64(page.(int))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
|
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
|
||||||
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -41,12 +41,19 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
req.Page = uint64(page.(int))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
|
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
|
||||||
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import (
|
|||||||
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,14 @@ import (
|
|||||||
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
||||||
|
d.Set("entry_count", extnetComputesList.EntryCount)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +62,26 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "filter by account ID",
|
Description: "filter by account ID",
|
||||||
},
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by RG ID",
|
||||||
|
},
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Filter by compute ID",
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -117,6 +138,10 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import (
|
|||||||
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ import (
|
|||||||
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +61,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,
|
||||||
@@ -88,9 +119,17 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +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("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)
|
||||||
@@ -35,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(ex))
|
||||||
for _, item := range ex {
|
for _, item := range ex {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"client_type": item.ClientType,
|
"client_type": item.ClientType,
|
||||||
@@ -51,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
|
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(ers))
|
||||||
for _, er := range ers {
|
for _, er := range ers {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"client_type": er.ClientType,
|
"client_type": er.ClientType,
|
||||||
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(ecs))
|
||||||
for _, ec := range ecs {
|
for _, ec := range ecs {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"net_id": ec.ID,
|
"net_id": ec.ID,
|
||||||
@@ -105,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, len(ecl.Data))
|
||||||
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,
|
||||||
@@ -122,13 +122,14 @@ 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, len(el.Data))
|
||||||
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,
|
||||||
"name": e.Name,
|
"name": e.Name,
|
||||||
|
"status": e.Status,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,26 @@ 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)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||||
|
req.RGID = uint64(rg_id.(int))
|
||||||
|
}
|
||||||
|
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||||
|
req.ComputeID = uint64(compute_id.(int))
|
||||||
|
}
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
req.Page = uint64(page.(int))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||||
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,13 +77,6 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"client_names": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"client_type": {
|
"client_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -53,12 +53,48 @@ func dataSourceFlipgroupList(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
|
|
||||||
d.Set("items", flattenFlipgroupList(fg_list))
|
d.Set("items", flattenFlipgroupList(fg_list))
|
||||||
|
d.Set("entry_count", fg_list.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
func dataSourceFlipgroupListSchemaMake() 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",
|
||||||
|
},
|
||||||
|
"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": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -82,10 +118,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"client_ids": {
|
"client_ids": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -93,13 +125,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"client_names": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"client_type": {
|
"client_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -112,26 +137,10 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
"default_gw": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
"desc": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -164,33 +173,32 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
"net_mask": {
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ package flipgroup
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.ItemFLIPGroup) {
|
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
||||||
d.Set("account_id", fg.AccountID)
|
d.Set("account_id", fg.AccountID)
|
||||||
d.Set("account_name", fg.AccountName)
|
d.Set("account_name", fg.AccountName)
|
||||||
d.Set("client_ids", fg.ClientIDs)
|
d.Set("client_ids", fg.ClientIDs)
|
||||||
d.Set("client_names", fg.ClientNames)
|
|
||||||
d.Set("client_type", fg.ClientType)
|
d.Set("client_type", fg.ClientType)
|
||||||
d.Set("conn_id", fg.ConnID)
|
d.Set("conn_id", fg.ConnID)
|
||||||
d.Set("conn_type", fg.ConnType)
|
d.Set("conn_type", fg.ConnType)
|
||||||
@@ -68,22 +68,18 @@ func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.ItemFLIPGroup) {
|
|||||||
d.Set("updated_time", fg.UpdatedTime)
|
d.Set("updated_time", fg.UpdatedTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenFlipgroupList(fg_list flipgroup.ListFLIPGroups) []map[string]interface{} {
|
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, fg := range fg_list {
|
for _, fg := range fg_list.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
|
"ckey": fg.CKey,
|
||||||
|
"meta": flattens.FlattenMeta(fg.Meta),
|
||||||
"account_id": fg.AccountID,
|
"account_id": fg.AccountID,
|
||||||
"account_name": fg.AccountName,
|
|
||||||
"client_ids": fg.ClientIDs,
|
"client_ids": fg.ClientIDs,
|
||||||
"client_names": fg.ClientNames,
|
|
||||||
"client_type": fg.ClientType,
|
"client_type": fg.ClientType,
|
||||||
"conn_id": fg.ConnID,
|
"conn_id": fg.ConnID,
|
||||||
"conn_type": fg.ConnType,
|
"conn_type": fg.ConnType,
|
||||||
"created_by": fg.CreatedBy,
|
|
||||||
"created_time": fg.CreatedTime,
|
|
||||||
"default_gw": fg.DefaultGW,
|
"default_gw": fg.DefaultGW,
|
||||||
"deleted_by": fg.DeletedBy,
|
|
||||||
"deleted_time": fg.DeletedTime,
|
|
||||||
"desc": fg.Description,
|
"desc": fg.Description,
|
||||||
"gid": fg.GID,
|
"gid": fg.GID,
|
||||||
"guid": fg.GUID,
|
"guid": fg.GUID,
|
||||||
@@ -93,12 +89,8 @@ func flattenFlipgroupList(fg_list flipgroup.ListFLIPGroups) []map[string]interfa
|
|||||||
"name": fg.Name,
|
"name": fg.Name,
|
||||||
"net_id": fg.NetID,
|
"net_id": fg.NetID,
|
||||||
"net_type": fg.NetType,
|
"net_type": fg.NetType,
|
||||||
"network": fg.Network,
|
"net_mask": fg.NetMask,
|
||||||
"rg_id": fg.RGID,
|
|
||||||
"rg_name": fg.RGName,
|
|
||||||
"status": fg.Status,
|
"status": fg.Status,
|
||||||
"updated_by": fg.UpdatedBy,
|
|
||||||
"updated_time": fg.UpdatedTime,
|
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +137,7 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +150,8 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,13 +213,6 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"client_names": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"conn_id": {
|
"conn_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -256,6 +253,10 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"network": {
|
"network": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -268,10 +269,6 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
"updated_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.ItemFLIPGroup, warn *dc.Warnings) {
|
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.RecordFLIPGroup, warn *dc.Warnings) {
|
||||||
addedClients := make([]interface{}, 0)
|
addedClients := make([]interface{}, 0)
|
||||||
removedClients := make([]interface{}, 0)
|
removedClients := make([]interface{}, 0)
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ func addComputesAfterCreation(ctx context.Context, warnings *dc.Warnings, c *con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ItemFLIPGroup, error) {
|
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.RecordFLIPGroup, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := flipgroup.GetRequest{}
|
req := flipgroup.GetRequest{}
|
||||||
|
|
||||||
@@ -146,10 +146,38 @@ func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData,
|
|||||||
return fg, err
|
return fg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (flipgroup.ListFLIPGroups, error) {
|
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ListFLIPGroups, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := flipgroup.ListRequest{}
|
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 {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ package image
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
@@ -44,12 +44,11 @@ import (
|
|||||||
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
image, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
d.SetId(strconv.Itoa(int(image.ID)))
|
||||||
d.SetId(id.String())
|
|
||||||
|
|
||||||
flattenImage(d, image)
|
flattenImage(d, image)
|
||||||
|
|
||||||
|
|||||||
@@ -44,21 +44,78 @@ import (
|
|||||||
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
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 +135,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
|||||||
Schema: dataSourceImageSchemaMake(),
|
Schema: dataSourceImageSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return rets
|
return rets
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package image
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenHistory(history []image.History) []map[string]interface{} {
|
func flattenHistory(history []image.History) []map[string]interface{} {
|
||||||
@@ -23,7 +24,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
|||||||
d.Set("unc_path", img.UNCPath)
|
d.Set("unc_path", img.UNCPath)
|
||||||
d.Set("ckey", img.CKey)
|
d.Set("ckey", img.CKey)
|
||||||
d.Set("account_id", img.AccountID)
|
d.Set("account_id", img.AccountID)
|
||||||
d.Set("acl", img.ACL)
|
d.Set("acl", FlattenACL(img.ACL))
|
||||||
d.Set("architecture", img.Architecture)
|
d.Set("architecture", img.Architecture)
|
||||||
d.Set("boot_type", img.BootType)
|
d.Set("boot_type", img.BootType)
|
||||||
d.Set("bootable", img.Bootable)
|
d.Set("bootable", img.Bootable)
|
||||||
@@ -58,9 +59,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,
|
||||||
@@ -85,3 +86,18 @@ func flattenImageList(il image.ListImages) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FlattenACL(acl interface{}) string {
|
||||||
|
switch d := acl.(type) {
|
||||||
|
case string:
|
||||||
|
return d
|
||||||
|
case int:
|
||||||
|
return strconv.Itoa(d)
|
||||||
|
case int64:
|
||||||
|
return strconv.FormatInt(d, 10)
|
||||||
|
case float64:
|
||||||
|
return strconv.FormatInt(int64(d), 10)
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +145,8 @@ func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
case status.Created:
|
case status.Created:
|
||||||
case status.Destroyed, status.Purged:
|
case status.Destroyed, status.Purged:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceImageCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceImageCreate(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
flattenImage(d, img)
|
flattenImage(d, img)
|
||||||
@@ -157,6 +159,7 @@ func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
_, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +236,8 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
case status.Created:
|
case status.Created:
|
||||||
case status.Destroyed, status.Purged:
|
case status.Destroyed, status.Purged:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return resourceImageCreate(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceImageCreate(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("name") {
|
if d.HasChange("name") {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.CreateVirtualRequest{
|
req := image.CreateVirtualRequest{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
TargetID: uint64(d.Get("target_id").(int)),
|
TargetID: uint64(d.Get("link_to").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
|
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -49,6 +50,7 @@ import (
|
|||||||
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
||||||
@@ -60,7 +62,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
|
||||||
}
|
}
|
||||||
@@ -398,6 +400,10 @@ func dataSourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"network_plugin": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ func computesSchemaMake() map[string]*schema.Schema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func workerComputesSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceK8sComputesSchemaMake() map[string]*schema.Schema {
|
func dataSourceK8sComputesSchemaMake() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"k8s_id": {
|
"k8s_id": {
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -231,6 +271,10 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"network_plugin": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -276,6 +320,10 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"entry_count": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ func dataSourceK8sListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
k8sListDeleted := createK8sListSchema()
|
k8sListDeleted := createK8sListSchema()
|
||||||
delete(k8sListDeleted, "includedeleted")
|
delete(k8sListDeleted, "includedeleted")
|
||||||
|
delete(k8sListDeleted, "status")
|
||||||
return k8sListDeleted
|
return k8sListDeleted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func dataSourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("dataSourceK8sWgCloudInitRead: called with k8s id %d and wg id %d", d.Get("k8s_id").(int), d.Get("wg_id").(int))
|
||||||
|
|
||||||
|
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("cloud_init", metaData)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sWgCloudInitSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Kubernetes cluster ID",
|
||||||
|
},
|
||||||
|
"wg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of the workers compute group",
|
||||||
|
},
|
||||||
|
"cloud_init": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Worker group Cloud init",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8sWgCloudInit() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sWgCloudInitRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sWgCloudInitSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@ import (
|
|||||||
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,34 @@ import (
|
|||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/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, len(list.Data))
|
||||||
|
for _, item := range list.Data {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"k8ci_id": item.ID,
|
||||||
|
"name": item.Name,
|
||||||
|
"lb_image_id": item.LBImageID,
|
||||||
|
"network_plugins": item.NetworkPlugins,
|
||||||
|
"status": item.Status,
|
||||||
|
"desc": item.Description,
|
||||||
|
"created_time": item.CreatedTime,
|
||||||
|
"version": item.Version,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8CIList(d *schema.ResourceData, list *k8ci.ListK8CI) {
|
||||||
|
d.Set("items", flattenK8CIItems(list))
|
||||||
|
}
|
||||||
|
|
||||||
func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
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))
|
||||||
@@ -47,7 +72,7 @@ func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Masters.DetailedInfo))
|
||||||
for _, comp := range cluster.K8SGroups.Masters.DetailedInfo {
|
for _, comp := range cluster.K8SGroups.Masters.DetailedInfo {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"id": comp.ID,
|
"id": comp.ID,
|
||||||
@@ -63,7 +88,7 @@ func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Workers))
|
||||||
for _, wg := range cluster.K8SGroups.Workers {
|
for _, wg := range cluster.K8SGroups.Workers {
|
||||||
for _, comp := range wg.DetailedInfo {
|
for _, comp := range wg.DetailedInfo {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -81,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(aclList))
|
||||||
for _, acl := range aclList {
|
for _, acl := range aclList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"explicit": acl.Explicit,
|
"explicit": acl.Explicit,
|
||||||
@@ -109,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||||
for _, interfaceCompute := range interfaces {
|
for _, interfaceCompute := range interfaces {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"def_gw": interfaceCompute.DefGW,
|
"def_gw": interfaceCompute.DefGW,
|
||||||
@@ -122,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(detailedInfoList))
|
||||||
if computes != nil {
|
if computes != nil {
|
||||||
for i, detailedInfo := range detailedInfoList {
|
for i, detailedInfo := range detailedInfoList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -168,7 +193,7 @@ 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, len(k8SGroupList))
|
||||||
for _, k8sGroup := range k8SGroupList {
|
for _, k8sGroup := range k8SGroupList {
|
||||||
labels := make([]string, 0)
|
labels := make([]string, 0)
|
||||||
for _, label := range k8sGroup.Labels {
|
for _, label := range k8sGroup.Labels {
|
||||||
@@ -197,15 +222,15 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []map[string]interface{} {
|
// func flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
// res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
// temp := map[string]interface{}{
|
||||||
"masters": flattenMasterGroup(k8sGroups.Masters, masters),
|
// "masters": flattenMasterGroup(k8sGroups.Masters, masters),
|
||||||
"workers": flattenK8sGroup(k8sGroups.Workers, workers),
|
// "workers": flattenK8sGroup(k8sGroups.Workers, workers),
|
||||||
}
|
// }
|
||||||
res = append(res, temp)
|
// res = append(res, temp)
|
||||||
return res
|
// return res
|
||||||
}
|
// }
|
||||||
|
|
||||||
func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
|
func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
|
||||||
d.Set("acl", flattenAcl(cluster.ACL))
|
d.Set("acl", flattenAcl(cluster.ACL))
|
||||||
@@ -222,6 +247,7 @@ func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []com
|
|||||||
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
||||||
d.Set("lb_id", cluster.LBID)
|
d.Set("lb_id", cluster.LBID)
|
||||||
d.Set("name", cluster.Name)
|
d.Set("name", cluster.Name)
|
||||||
|
d.Set("network_plugin", cluster.NetworkPlugin)
|
||||||
d.Set("rg_id", cluster.RGID)
|
d.Set("rg_id", cluster.RGID)
|
||||||
d.Set("rg_name", cluster.RGName)
|
d.Set("rg_name", cluster.RGName)
|
||||||
d.Set("status", cluster.Status)
|
d.Set("status", cluster.Status)
|
||||||
@@ -242,7 +268,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(workersGroups))
|
||||||
for _, worker := range workersGroups {
|
for _, worker := range workersGroups {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"annotations": worker.Annotations,
|
"annotations": worker.Annotations,
|
||||||
@@ -262,12 +288,12 @@ 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, len(k8sItems.Data))
|
||||||
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.AccountName,
|
||||||
"acl": item.ACL,
|
"acl": item.ACL,
|
||||||
"bservice_id": item.BServiceID,
|
"bservice_id": item.BServiceID,
|
||||||
"ci_id": item.CIID,
|
"ci_id": item.CIID,
|
||||||
@@ -283,6 +309,7 @@ func flattenK8sItems(k8sItems k8s.ListK8SClusters) []map[string]interface{} {
|
|||||||
"lb_id": item.LBID,
|
"lb_id": item.LBID,
|
||||||
"milestones": item.Milestones,
|
"milestones": item.Milestones,
|
||||||
"k8s_name": item.Name,
|
"k8s_name": item.Name,
|
||||||
|
"network_plugin": item.NetworkPlugin,
|
||||||
"rg_id": item.RGID,
|
"rg_id": item.RGID,
|
||||||
"rg_name": item.RGName,
|
"rg_name": item.RGName,
|
||||||
"service_account": flattenServiceAccount(item.ServiceAccount),
|
"service_account": flattenServiceAccount(item.ServiceAccount),
|
||||||
@@ -299,8 +326,9 @@ 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) {
|
func flattenResourceK8sCP(d *schema.ResourceData, k8s k8s.RecordK8S, masters []compute.RecordCompute) {
|
||||||
@@ -370,7 +398,7 @@ 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)
|
labels := make([]string, 0, len(wg.Labels))
|
||||||
for _, label := range wg.Labels {
|
for _, label := range wg.Labels {
|
||||||
if strings.HasPrefix(label, "workersGroupName") {
|
if strings.HasPrefix(label, "workersGroupName") {
|
||||||
continue
|
continue
|
||||||
@@ -392,7 +420,7 @@ func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWgList(wgList k8s.ListK8SGroups, computesMap map[uint64][]compute.RecordCompute) []map[string]interface{} {
|
func flattenWgList(wgList k8s.ListK8SGroups, computesMap map[uint64][]compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0, len(wgList))
|
||||||
for _, wg := range wgList {
|
for _, wg := range wgList {
|
||||||
computes := computesMap[wg.ID]
|
computes := computesMap[wg.ID]
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
|
|||||||
@@ -85,21 +85,21 @@ func mastersSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
masters["cpu"] = &schema.Schema{
|
masters["cpu"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "Node CPU count.",
|
Description: "Node CPU count.",
|
||||||
}
|
}
|
||||||
masters["ram"] = &schema.Schema{
|
masters["ram"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "Node RAM in MB.",
|
Description: "Node RAM in MB.",
|
||||||
}
|
}
|
||||||
masters["disk"] = &schema.Schema{
|
masters["disk"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
//ForceNew: true,
|
||||||
Description: "Node boot disk size in GB.",
|
Description: "Node boot disk size in GB.",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
396
internal/service/cloudapi/k8s/old_schemas.go
Normal file
396
internal/service/cloudapi/k8s/old_schemas.go
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceK8sCPSchemaV1() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Name of the cluster.",
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
//ForceNew: true,
|
||||||
|
Description: "Resource group ID that this instance belongs to.",
|
||||||
|
},
|
||||||
|
"k8sci_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
//ForceNew: true,
|
||||||
|
Description: "ID of the k8s catalog item to base this instance on.",
|
||||||
|
},
|
||||||
|
"network_plugin": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Network plugin to be used",
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true),
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||||
|
Description: "Number of VMs to create. Can be either 1 or 3",
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node CPU count.",
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node RAM in MB.",
|
||||||
|
},
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Node boot disk size in GB.",
|
||||||
|
},
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Storage Endpoint ID",
|
||||||
|
},
|
||||||
|
"sep_pool": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Storage Endpoint Pool",
|
||||||
|
},
|
||||||
|
"with_lb": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
Description: "Create k8s with load balancer if true.",
|
||||||
|
},
|
||||||
|
"extnet_only": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Use only selected ExtNet for infrastructure connections",
|
||||||
|
},
|
||||||
|
// /4.4.0
|
||||||
|
"cloud_init": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
|
||||||
|
},
|
||||||
|
"join_config": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "is used to configure the behavior and settings for joining a node to a cluster. It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting.",
|
||||||
|
},
|
||||||
|
"kube_proxy_config": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster. It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations. insert a valid JSON string with all levels of nesting.",
|
||||||
|
},
|
||||||
|
"kubelet_config": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster. It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations. insert a valid JSON string with all levels of nesting.",
|
||||||
|
},
|
||||||
|
"cluster_config": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "is used to define global settings and configurations for the entire cluster. It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations. insert a valid JSON string with all levels of nesting.",
|
||||||
|
},
|
||||||
|
"init_config": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "is used to define settings and actions that should be performed before any other component in the cluster starts. It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting.",
|
||||||
|
},
|
||||||
|
"additional_sans": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names",
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ha_mode": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Use Highly Available schema for LB deploy",
|
||||||
|
},
|
||||||
|
"lb_sysctl_params": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
|
||||||
|
},
|
||||||
|
"oidc_cert": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "insert ssl certificate in x509 pem format",
|
||||||
|
},
|
||||||
|
////
|
||||||
|
"extnet_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
//ForceNew: true,
|
||||||
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Text description of this instance.",
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
Description: "Start k8s cluster.",
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"interfaces": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"def_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"natable_vins_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"natable_vins_network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"master_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Master group ID.",
|
||||||
|
},
|
||||||
|
"master_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Master group name.",
|
||||||
|
},
|
||||||
|
"acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"account_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"explicit": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user_group_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"k8s_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"explicit": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user_group_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"rg_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"explicit": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user_group_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"bservice_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_ci_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP address of default load balancer.",
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"kubeconfig": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Kubeconfig for cluster access.",
|
||||||
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of default vins for this instace.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user