Compare commits

..

41 Commits
3.4.1 ... 4.5.2

Author SHA1 Message Date
f49d9f8860 4.5.2 2023-12-19 16:37:50 +03:00
20050bc169 4.5.1 2023-12-18 18:55:52 +03:00
e2ee45ee14 4.5.1 2023-12-18 18:36:55 +03:00
Nikita Sorokin
294680282e 4.5.0 2023-11-13 00:59:02 +03:00
Nikita Sorokin
2bc0fbae9a 4.5.0-alpha 2023-11-07 18:26:09 +03:00
Nikita Sorokin
2453a32d01 4.4.2 2023-10-18 08:30:37 +03:00
Nikita Sorokin
0602a4b693 4.4.1 2023-10-13 13:28:19 +03:00
Nikita Sorokin
28b60de115 4.4.0-static-route-updated 2023-10-09 13:15:11 +03:00
Nikita Sorokin
b705ce4aab 4.4.0 2023-09-28 19:41:26 +03:00
Nikita Sorokin
83ca627cea 4.4.0 2023-09-28 16:08:15 +03:00
Nikita Sorokin
739289fbb8 4.3.8 2023-09-27 16:17:35 +03:00
Nikita Sorokin
c89574c3e6 4.3.7 2023-09-22 12:49:22 +03:00
Nikita Sorokin
a1e61674c8 4.3.6 2023-09-04 11:15:01 +03:00
Nikita Sorokin
cb9ff26bb0 4.3.5 2023-08-29 16:26:37 +03:00
Nikita Sorokin
6932f9d305 4.3.5 2023-08-28 13:02:41 +03:00
Nikita Sorokin
712f8edf9e 4.3.4 2023-08-23 16:32:48 +03:00
Nikita Sorokin
805ffe1f29 4.3.3 2023-08-22 13:15:17 +03:00
Nikita Sorokin
bf8d3fb437 4.3.2 2023-08-17 18:18:23 +03:00
d7a7eb9cb3 4.3.1 README update 2023-08-16 16:00:00 +03:00
Nikita Sorokin
b60f32c570 v4.3.1 2023-08-10 20:22:43 +03:00
272e385318 4.3.0 2023-07-26 13:32:39 +03:00
f731cf246f 4.2.4 2023-07-07 11:54:41 +03:00
6365f63fc1 4.2.3 2023-06-29 16:02:38 +03:00
85ce76564f 4.2.2 2023-06-23 15:30:46 +03:00
928481d26f 4.2.1 2023-06-19 16:05:27 +03:00
0e64974821 4.2.0 2023-06-08 12:26:21 +03:00
371bb0d90f 4.1.1 2023-06-01 17:40:47 +03:00
caf7213bca 4.1.0 2023-05-26 17:12:03 +03:00
9cf150437d 4.0.2 2023-05-23 16:48:16 +03:00
523d96189f 4.0.1 2023-05-19 17:14:55 +03:00
KasimBaybikov
8ca233dd32 4.0.0 2023-05-04 10:08:25 +03:00
KasimBaybikov
9bad8a6947 3.6.0 2023-04-10 16:56:56 +03:00
KasimBaybikov
e3e7e7bd89 edit repository link in Readme 2023-04-05 17:06:00 +03:00
KasimBaybikov
b112c5ee22 3.5.2 2023-03-26 22:00:30 +03:00
KasimBaybikov
f2f31b939e code migration to repository.basistech.ru 2023-03-17 11:56:53 +03:00
KasimBaybikov
c781ffafaa code migration to repos.digitalenergy.online 2023-03-14 13:32:33 +03:00
KasimBaybikov
3715db2923 fix rule release for Makefile, and update links in README.md/README_EN.md 2023-03-13 15:54:30 +03:00
KasimBaybikov
f83c8e8a9a 3.5.1 2023-03-10 12:49:28 +03:00
KasimBaybikov
af82decadd 3.5.0 2023-03-10 12:42:15 +03:00
KasimBaybikov
f5e0a53364 3.4.3 2023-02-16 16:29:04 +03:00
stSolo
9d1c8eeaa7 3.4.2 2023-02-10 17:29:09 +03:00
845 changed files with 95530 additions and 32354 deletions

4
.gitignore vendored
View File

@@ -2,4 +2,6 @@ decort/vendor/
examples/ examples/
url_scrapping/ url_scrapping/
terraform-provider-decort* terraform-provider-decort*
.vscode/ .vscode/
.DS_Store

View File

@@ -1,8 +1,36 @@
### Version 3.4.1 ## Version 4.5.2
### Features ### Bugfix
- Added resource_limits.cu_dm string field for account, account_consumed_units and account_reserved_units data sources in cloudapi/account
- Add the affinity_label field into the kvmvm resource - Fixed restore of account resource in cloudapi/account, it happens if restore parameter is set to true
- Add affinity_rules blocks into the kvmvm resource - Fixed restore of bservice resource in cloudapi/bservice, it happens if restore parameter is set to true and only once
- Add anti-affinity_rules blocks into the kvmvm resource - Fixed enable of bservice resource in cloudapi/bservice, it happens if enable parameter is set to true
- Update samples for the kvmvm resource - 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

View File

@@ -1,15 +1,31 @@
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
#BINARY=terraform-provider-${NAME} BINDIR = ./bin
BINARY=${NAME}.exe ZIPDIR = ./zip
BINARY=${NAME}
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/ MAINPATH = ./cmd/decort/
VERSION=1.1 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\
${BINARY}_${VERSION}_darwin_arm64\
${BINARY}_${VERSION}_freebsd_386\
${BINARY}_${VERSION}_freebsd_amd64\
${BINARY}_${VERSION}_freebsd_arm\
${BINARY}_${VERSION}_linux_386\
${BINARY}_${VERSION}_linux_amd64\
${BINARY}_${VERSION}_linux_arm\
${BINARY}_${VERSION}_linux_arm64\
${BINARY}_${VERSION}_openbsd_386\
${BINARY}_${VERSION}_openbsd_amd64\
${BINARY}_${VERSION}_solaris_amd64\
${BINARY}_${VERSION}_windows_386.exe\
${BINARY}_${VERSION}_windows_amd64.exe\
BINS = $(addprefix bin/, $(FILES))
default: install default: install
@@ -29,27 +45,41 @@ st:
build: build:
go build -o ${BINARY} ${MAINPATH} go build -o ${BINARY} ${MAINPATH}
release: release: $(FILES)
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 $(FILES) : $(BINDIR) $(ZIPDIR) $(BINS)
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm zip -rj $(ZIPDIR)/$@.zip scripts/install.bat scripts/install.sh
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 $(BINDIR):
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm mkdir $@
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(ZIPDIR):
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 mkdir $@
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 $(BINS):
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 $(MAINPATH)
GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64 $(MAINPATH)
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 $(MAINPATH)
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 $(MAINPATH)
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm $(MAINPATH)
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 $(MAINPATH)
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 $(MAINPATH)
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm $(MAINPATH)
GOOS=linux GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_linux_arm64 ${MAINPATH}
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 $(MAINPATH)
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(MAINPATH)
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 $(MAINPATH)
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386.exe $(MAINPATH)
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64.exe $(MAINPATH)
install: build install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
test: test:
go test -i $(TEST) || exit 1 go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
testacc: testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

233
README.md
View File

@@ -6,6 +6,10 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
| Версия DECORT API | Версия провайдера Terraform | | Версия DECORT API | Версия провайдера Terraform |
| ------ | ------ | | ------ | ------ |
| 3.8.9 | 4.5.x |
| 3.8.8 | 4.4.x |
| 3.8.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 |
@@ -17,124 +21,168 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
Провайдер позволяет работать в двух режимах: Провайдер позволяет работать в двух режимах:
- Режим пользователя, - Режим пользователя,
- Режим администратора. - Режим администратора. <br>
Для переключения между режимами используйте флаг DECORT_ADMIN_MODE. Используйте ресурсы `decort_cb_` для администрирования. <br>
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
## Возможности провайдера ## Возможности провайдера
- Работа с 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://github.com/rudecs/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://github.com/rudecs/terraform-provider-decort.git
```
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` помещается путь до репозитория с версией вида:
@@ -142,27 +190,30 @@ 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
## Примеры работы ## Примеры работы
Примеры работы можно найти: Примеры работы можно найти:
- На вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki - На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
- В папке `samples` - В папке `samples`
Схемы к terraform'у доступны:
- В папке `docs`
Хорошей работы! Хорошей работы!

View File

@@ -19,7 +19,7 @@ The provider support two working modes:
- User mode, - User mode,
- Administator mode. - Administator mode.
Use flag DECORT_ADMIN_MODE for swithcing beetwen modes. Use flag DECORT_ADMIN_MODE for swithcing beetwen modes.
See user guide at https://github.com/rudecs/terraform-provider-decort/wiki See user guide at https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
## Features ## Features
@@ -42,7 +42,7 @@ The provider support two working modes:
This provider supports Import operations on pre-existing resources. This provider supports Import operations on pre-existing resources.
See user guide at https://github.com/rudecs/terraform-provider-decort/wiki See user guide at https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
## Get Started ## Get Started
@@ -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>
@@ -158,7 +158,7 @@ More details about the provider's building process: https://learn.hashicorp.com/
## Examples and Samples ## Examples and Samples
- Examples: https://github.com/rudecs/terraform-provider-decort/wiki - Examples: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
- Samples: see in repository `samples` - Samples: see in repository `samples`
Terraform schemas in: Terraform schemas in:

View File

@@ -3,6 +3,8 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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.
@@ -21,12 +23,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package main package main
@@ -37,7 +39,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin" "github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/rudecs/terraform-provider-decort/internal/provider" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/provider"
) )
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

23
go.mod
View File

@@ -1,14 +1,14 @@
module github.com/rudecs/terraform-provider-decort 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.4.0 golang.org/x/net v0.16.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3
) )
require ( require (
@@ -20,8 +20,13 @@ 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/golang/protobuf v1.5.2 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.4 // 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/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
@@ -43,6 +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.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
@@ -60,11 +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.4.0 // indirect golang.org/x/crypto v0.15.0 // indirect
golang.org/x/sys v0.3.0 // indirect golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.5.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
) )

189
go.sum
View File

@@ -1,17 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI=
github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=
github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
@@ -21,14 +14,10 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C6
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
@@ -39,33 +28,19 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= 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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 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=
@@ -75,46 +50,34 @@ github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
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/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
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.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/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.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
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.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
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.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -126,15 +89,11 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I= github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I=
github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ=
github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM=
github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
@@ -146,44 +105,29 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk=
github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI=
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go=
github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8=
github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU=
github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI=
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s=
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
github.com/hashicorp/terraform-plugin-go v0.12.0 h1:6wW9mT1dSs0Xq4LR6HXj1heQ5ovr5GxXNJwkErZzpJw=
github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M=
github.com/hashicorp/terraform-plugin-go v0.14.2 h1:rhsVEOGCnY04msNymSvbUsXfRLKh9znXZmHlf5e8mhE= github.com/hashicorp/terraform-plugin-go v0.14.2 h1:rhsVEOGCnY04msNymSvbUsXfRLKh9znXZmHlf5e8mhE=
github.com/hashicorp/terraform-plugin-go v0.14.2/go.mod h1:Q12UjumPNGiFsZffxOsA40Tlz1WVXt2Evh865Zj0+UA= github.com/hashicorp/terraform-plugin-go v0.14.2/go.mod h1:Q12UjumPNGiFsZffxOsA40Tlz1WVXt2Evh865Zj0+UA=
github.com/hashicorp/terraform-plugin-log v0.6.0 h1:/Vq78uSIdUSZ3iqDc9PESKtwt8YqNKN6u+khD+lLjuw=
github.com/hashicorp/terraform-plugin-log v0.6.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs=
github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0 h1:7gDAcfto/C4Cjtf90SdukQshsxdMxJ/P69QxiF3digI=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0/go.mod h1:/WYikYjhKB7c2j1HmXZhRsAARldRb4M38bLCLOhC3so=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U= github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A= github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
@@ -208,21 +152,19 @@ 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.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/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=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA=
github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ=
github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng=
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
@@ -232,8 +174,6 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -242,9 +182,6 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -254,8 +191,6 @@ 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/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= 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=
@@ -273,20 +208,24 @@ 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=
github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
@@ -295,62 +234,42 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
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.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
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.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
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=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
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-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
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.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
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/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/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-20181108010431-42b317875d0f/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=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -359,10 +278,7 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -371,13 +287,12 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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-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.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.3.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=
@@ -385,63 +300,28 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 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 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
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.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.5.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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
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=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200711021454-869866162049 h1:YFTFpQhgvrLrmxtiIncJxFXeCyq84ixuKWVCaCAi9Oc=
google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= 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 v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/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=
@@ -451,12 +331,11 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.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=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3 h1:NtvW72WsAezk0XYKE5+ag+xauIgKWKcbKLy7YTp5Fuc=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= repository.basistech.ru/BASIS/decort-golang-sdk v1.7.3/go.mod h1:7fj8sgGZFiiExewQeqckCS4WxwOmU0oP6BO6mi1Lpkw=

View File

@@ -1,26 +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>
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"

View File

@@ -1,8 +1,9 @@
/* /*
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>
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.
@@ -20,47 +21,55 @@ 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"
jwt "github.com/golang-jwt/jwt/v4" "repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
"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
} }
func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) { func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
@@ -81,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
@@ -100,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 {
@@ -146,39 +182,77 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
return nil, err return nil, err
} }
ret_config.decort_username = ret_config.legacy_user ret_config.decort_username = ret_config.legacy_user
sdkConf := config.LegacyConfig{
Username: ret_config.legacy_user,
Password: ret_config.legacy_password,
DecortURL: ret_config.controller_url,
SSLSkipVerify: allow_unverified_ssl,
}
ret_config.caller = decort.NewLegacy(sdkConf)
case MODE_JWT: case MODE_JWT:
// //
ok, err := ret_config.validateJWT("") ok, err := ret_config.validateJWT("")
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 {
// var tbuf bytes.Buffer
// tbuf.WriteString(claims["username"].(string))
// tbuf.WriteString("@")
// tbuf.WriteString(claims["iss"].(string))
// ret_config.decort_username = tbuf.String()
// } else {
// return nil, fmt.Errorf("failed to extract user and iss fields from JWT token in oauth2 mode")
// }
sdkConf := config.Config{
AppID: ret_config.app_id,
AppSecret: ret_config.app_secret,
SSOURL: ret_config.oauth2_url,
DecortURL: ret_config.controller_url,
SSLSkipVerify: allow_unverified_ssl,
} }
if claims, ok := token.Claims.(jwt.MapClaims); ok {
var tbuf bytes.Buffer ret_config.caller = decort.New(sdkConf)
tbuf.WriteString(claims["username"].(string)) case MODE_BVS:
tbuf.WriteString("@")
tbuf.WriteString(claims["iss"].(string)) sdkConf := config.BVSConfig{
ret_config.decort_username = tbuf.String() AppID: ret_config.app_id,
} else { AppSecret: ret_config.app_secret,
return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.") 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
@@ -186,77 +260,77 @@ 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) {
/* /*
Validate JWT against DECORT controller. JWT can be supplied as argument to this method. If empty string supplied as Validate JWT against DECORT controller. JWT can be supplied as argument to this method. If empty string supplied as
argument, JWT will be taken from config attribute. argument, JWT will be taken from config attribute.
DECORT controller URL will always be taken from the config attribute assigned at instantiation. DECORT controller URL will always be taken from the config attribute assigned at instantiation.
Validation is accomplished by attempting API call that lists accounts for the invoking user. Validation is accomplished by attempting API call that lists account for the invoking user.
*/ */
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/accounts/list", nil) req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
if err != nil { if err != nil {
return false, err return false, err
} }
@@ -270,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()
@@ -286,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{}
@@ -297,7 +371,7 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
params.Add("password", config.legacy_password) params.Add("password", config.legacy_password)
params_str := params.Encode() params_str := params.Encode()
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/users/authenticate", strings.NewReader(params_str)) req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/user/authenticate", strings.NewReader(params_str))
if err != nil { if err != nil {
return false, err return false, err
} }
@@ -310,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)
} }
@@ -326,81 +400,33 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
return true, nil return true, nil
} }
func (config *ControllerCfg) DecortAPICall(ctx context.Context, method string, api_name string, url_values *url.Values) (json_resp string, err error) { //nolint:unparam func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
// This is a convenience wrapper around standard HTTP request methods that is aware of the switch config.auth_mode_code {
// authorization mode for which the provider was initialized and compiles request accordingly. case MODE_LEGACY:
client, _ := config.caller.(*decort.LegacyDecortClient)
if config.cc_client == nil { return client.CloudAPI()
// this should never happen if ClientConfig was properly called prior to decortAPICall case MODE_DECS3O:
return "", fmt.Errorf("decortAPICall method called with unconfigured DECORT cloud controller HTTP client.") client, _ := config.caller.(*decort.DecortClient)
return client.CloudAPI()
case MODE_BVS:
client, _ := config.caller.(*decort.BVSDecortClient)
return client.CloudAPI()
default:
return &cloudapi.CloudAPI{}
}
}
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
switch config.auth_mode_code {
case MODE_LEGACY:
client, _ := config.caller.(*decort.LegacyDecortClient)
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{}
} }
// 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)
} }

View File

@@ -1,59 +1,65 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Stanislav Solovev, <spsolovev@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Kasim Baybikov, <kmbaybikov@basistech.ru>
you may not use this file except in compliance with the License. Nikita Sorokin, <nesorokin@basistech.ru>
You may obtain a copy of the License at Tim Tkachev, <tvtkachev@basistech.ru>
http://www.apache.org/licenses/LICENSE-2.0 Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software You may obtain a copy of the License at
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. http://www.apache.org/licenses/LICENSE-2.0
See the License for the specific language governing permissions and
limitations under the License. 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
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud limitations under the License.
Orchestration Technology) with Terraform by Hashicorp. */
Source code: https://github.com/rudecs/terraform-provider-decort /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Please see README.md to learn where to place source code so that it Orchestration Technology) with Terraform by Hashicorp.
builds seamlessly.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Please see README.md to learn where to place source code so that it
builds seamlessly.
package account
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" */
func dataSourceAccountAuditSchemaMake() map[string]*schema.Schema { package dc
return map[string]*schema.Schema{
"call": { import "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Type: schema.TypeString,
Computed: true, func ErrorsToDiagnostics(errs []error) diag.Diagnostics {
}, if len(errs) == 0 {
"responsetime": { return nil
Type: schema.TypeFloat, }
Computed: true,
}, diags := diag.Diagnostics{}
"statuscode": {
Type: schema.TypeInt, for _, err := range errs {
Computed: true, diags = append(diags, diag.Diagnostic{
}, Severity: diag.Error,
"timestamp": { Summary: err.Error(),
Type: schema.TypeFloat, })
Computed: true, }
},
"user": { return diags
Type: schema.TypeString, }
Computed: true,
}, func ErrorsToWarnings(errs []error) Warnings {
} w := Warnings{}
}
for _, err := range errs {
w.Add(err)
}
return w
}

View File

@@ -22,12 +22,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
//Diagnostics Collector //Diagnostics Collector

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,40 +22,32 @@ package location
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"net/url"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
) )
var DefaultGridID int var DefaultGridID int
func UtilityLocationGetDefaultGridID(ctx context.Context, m interface{}) (int, error) { func UtilityLocationGetDefaultGridID(ctx context.Context, m interface{}) (int, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := locations.ListRequest{}
urlValues := &url.Values{}
log.Debug("utilityLocationGetDefaultGridID: retrieving locations list") log.Debug("utilityLocationGetDefaultGridID: retrieving locations list")
apiResp, err := c.DecortAPICall(ctx, "POST", LocationsListAPI, urlValues) locList, err := c.CloudAPI().Locations().List(ctx, req)
if err != nil { if err != nil {
return 0, err return 0, err
} }
locList := LocationsListResp{} if len(locList.Data) == 0 {
err = json.Unmarshal([]byte(apiResp), &locList)
if err != nil {
return 0, err
}
if len(locList) == 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 = locList[0].GridID 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
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.

View File

@@ -1,96 +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>
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 cloudapi
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/account"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/bservice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/k8s"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vins"
)
func NewDataSourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
"decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_k8s": k8s.DataSourceK8s(),
"decort_k8s_list": k8s.DataSourceK8sList(),
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
"decort_k8s_wg": k8s.DataSourceK8sWg(),
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
"decort_vins": vins.DataSourceVins(),
"decort_vins_list": vins.DataSourceVinsList(),
"decort_vins_audits": vins.DataSourceVinsAudits(),
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
"decort_disk": disks.DataSourceDisk(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_rg_list": rg.DataSourceRgList(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_bservice": bservice.DataSourceBasicService(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_locations_list": locations.DataSourceLocationsList(),
"decort_location_url": locations.DataSourceLocationUrl(),
"decort_image_list": image.DataSourceImageList(),
"decort_image": image.DataSourceImage(),
"decort_lb": lb.DataSourceLB(),
"decort_lb_list": lb.DataSourceLBList(),
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
// "decort_pfw": dataSourcePfw(),
}
}

View File

@@ -1,59 +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>
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 cloudapi
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/account"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/bservice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/k8s"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/pfw"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vins"
)
func NewRersourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_resgroup": rg.ResourceResgroup(),
"decort_kvmvm": kvmvm.ResourceCompute(),
"decort_disk": disks.ResourceDisk(),
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
"decort_vins": vins.ResourceVins(),
"decort_pfw": pfw.ResourcePfw(),
"decort_k8s": k8s.ResourceK8s(),
"decort_k8s_wg": k8s.ResourceK8sWg(),
"decort_snapshot": snapshot.ResourceSnapshot(),
"decort_account": account.ResourceAccount(),
"decort_bservice": bservice.ResourceBasicService(),
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
"decort_image": image.ResourceImage(),
"decort_image_virtual": image.ResourceImageVirtual(),
"decort_lb": lb.ResourceLB(),
"decort_lb_backend": lb.ResourceLBBackend(),
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
"decort_lb_frontend": lb.ResourceLBFrontend(),
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
}
}

View File

@@ -1,65 +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>
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 cloudbroker
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/account"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/disks"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/grid"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/sep"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/vgpu"
)
func NewDataSourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_disk": disks.DataSourceDisk(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_image": image.DataSourceImage(),
"decort_grid": grid.DataSourceGrid(),
"decort_grid_list": grid.DataSourceGridList(),
"decort_image_list": image.DataSourceImageList(),
"decort_image_list_stacks": image.DataSourceImageListStacks(),
"decort_pcidevice": pcidevice.DataSourcePcidevice(),
"decort_pcidevice_list": pcidevice.DataSourcePcideviceList(),
"decort_sep_list": sep.DataSourceSepList(),
"decort_sep": sep.DataSourceSep(),
"decort_sep_consumption": sep.DataSourceSepConsumption(),
"decort_sep_disk_list": sep.DataSourceSepDiskList(),
"decort_sep_config": sep.DataSourceSepConfig(),
"decort_sep_pool": sep.DataSourceSepPool(),
"decort_vgpu": vgpu.DataSourceVGPU(),
"decort_rg_list": rg.DataSourceRgList(),
// "decort_pfw": dataSourcePfw(),
}
}

View File

@@ -1,56 +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>
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 cloudbroker
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/account"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/disks"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/k8s"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/pfw"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/sep"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/snapshot"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/vins"
)
func NewRersourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.ResourceAccount(),
"decort_disk": disks.ResourceDisk(),
"decort_image": image.ResourceImage(),
"decort_virtual_image": image.ResourceVirtualImage(),
"decort_cdrom_image": image.ResourceCDROMImage(),
"decort_delete_images": image.ResourceDeleteImages(),
"decort_pcidevice": pcidevice.ResourcePcidevice(),
"decort_sep": sep.ResourceSep(),
"decort_sep_config": sep.ResourceSepConfig(),
"decort_resgroup": rg.ResourceResgroup(),
"decort_kvmvm": kvmvm.ResourceCompute(),
"decort_vins": vins.ResourceVins(),
"decort_pfw": pfw.ResourcePfw(),
"decort_k8s": k8s.ResourceK8s(),
"decort_k8s_wg": k8s.ResourceK8sWg(),
"decort_snapshot": snapshot.ResourceSnapshot(),
}
}

View File

@@ -0,0 +1,254 @@
/*
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 provider
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
cb_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_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_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_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_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 {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
"decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
"decort_k8s": k8s.DataSourceK8s(),
"decort_k8s_list": k8s.DataSourceK8sList(),
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
"decort_k8s_wg": k8s.DataSourceK8sWg(),
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
"decort_k8ci_list": k8s.DataSourceK8CIList(),
"decort_vins": vins.DataSourceVins(),
"decort_vins_list": vins.DataSourceVinsList(),
"decort_vins_audits": vins.DataSourceVinsAudits(),
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
"decort_vins_static_route": vins.DataSourceStaticRoute(),
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
"decort_disk": disks.DataSourceDisk(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_rg_list": rg.DataSourceRgList(),
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
"decort_rg_audits": rg.DataSourceRgAudits(),
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
"decort_rg_list_lb": rg.DataSourceRgListLb(),
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
"decort_rg_list_vins": rg.DataSourceRgListVins(),
"decort_rg_usage": rg.DataSourceRgUsage(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_bservice": bservice.DataSourceBasicService(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_locations_list": locations.DataSourceLocationsList(),
"decort_location_url": locations.DataSourceLocationUrl(),
"decort_image_list": image.DataSourceImageList(),
"decort_image": image.DataSourceImage(),
"decort_lb": lb.DataSourceLB(),
"decort_lb_list": lb.DataSourceLBList(),
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
"decort_stack": stack.DataSourceStack(),
"decort_stack_list": stack.DataSourceStackList(),
"decort_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_list": cb_account.DataSourceAccountList(),
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
"decort_cb_audit": cb_audit.DataSourceAudit(),
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
"decort_cb_image": cb_image.DataSourceImage(),
"decort_cb_grid": cb_grid.DataSourceGrid(),
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
"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(),
}
}

View File

@@ -1,128 +1,168 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. See the License for the specific language governing permissions and
*/ limitations under the License.
*/
package provider
package provider
import (
"fmt" import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"golang.org/x/net/context" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"golang.org/x/net/context"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/location" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/statefuncs" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/location"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
)
func Provider() *schema.Provider {
return &schema.Provider{ func Provider() *schema.Provider {
Schema: map[string]*schema.Schema{ return &schema.Provider{
"authenticator": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "authenticator": {
Required: true, Type: schema.TypeString,
StateFunc: statefuncs.StateFuncToLower, Required: true,
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating StateFunc: statefuncs.StateFuncToLower,
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.", 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 'decs3o', 'legacy', 'jwt' or 'bvs'.",
},
"oauth2_url": {
Type: schema.TypeString, "oauth2_url": {
Optional: true, Type: schema.TypeString,
StateFunc: statefuncs.StateFuncToLower, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil), StateFunc: statefuncs.StateFuncToLower,
Description: "OAuth2 application URL in 'oauth2' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
}, Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
},
"controller_url": {
Type: schema.TypeString, "controller_url": {
Required: true, Type: schema.TypeString,
ForceNew: true, Required: true,
StateFunc: statefuncs.StateFuncToLower, ForceNew: true,
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.", StateFunc: statefuncs.StateFuncToLower,
}, Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
},
"user": {
Type: schema.TypeString, "user": {
Optional: true, Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil), Optional: true,
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
}, Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
},
"password": {
Type: schema.TypeString, "password": {
Optional: true, Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil), Optional: true,
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
}, Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
},
"app_id": {
Type: schema.TypeString, "bvs_user": {
Optional: true, Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil), Optional: true,
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
}, Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
},
"app_secret": {
Type: schema.TypeString, "bvs_password": {
Optional: true, Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil), Optional: true,
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
}, Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
},
"jwt": {
Type: schema.TypeString, "domain": {
Optional: true, Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil), Optional: true,
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.", DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
}, Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
},
"allow_unverified_ssl": {
Type: schema.TypeBool, "app_id": {
Optional: true, Type: schema.TypeString,
Default: false, Optional: true,
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!", DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
}, Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
}, },
ResourcesMap: selectSchema(false), "app_secret": {
Type: schema.TypeString,
DataSourcesMap: selectSchema(true), Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
ConfigureContextFunc: providerConfigure, Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
} },
}
"jwt": {
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { Type: schema.TypeString,
decsController, err := controller.ControllerConfigure(d) Optional: true,
if err != nil { DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
return nil, diag.FromErr(err) Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
} },
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController) "allow_unverified_ssl": {
if err != nil { Type: schema.TypeBool,
return nil, diag.FromErr(err) Optional: true,
} Default: false,
if gridId == 0 { Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0")) },
}
"path_cfg": {
return decsController, nil 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(),
DataSourcesMap: newDataSourcesMap(),
ConfigureContextFunc: providerConfigure,
}
}
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
decsController, err := controller.ControllerConfigure(d)
if err != nil {
return nil, diag.FromErr(err)
}
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController)
if err != nil {
return nil, diag.FromErr(err)
}
if gridId == 0 {
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0"))
}
return decsController, nil
}

View File

@@ -0,0 +1,103 @@
/*
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 provider
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
"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/vins"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
cb_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_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_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_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_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
)
func newResourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_resgroup": rg.ResourceResgroup(),
"decort_kvmvm": kvmvm.ResourceCompute(),
"decort_disk": disks.ResourceDisk(),
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
"decort_vins": vins.ResourceVins(),
"decort_pfw": pfw.ResourcePfw(),
"decort_k8s": k8s.ResourceK8s(),
"decort_k8s_wg": k8s.ResourceK8sWg(),
"decort_k8s_cp": k8s.ResourceK8sCP(),
"decort_snapshot": snapshot.ResourceSnapshot(),
"decort_account": account.ResourceAccount(),
"decort_bservice": bservice.ResourceBasicService(),
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
"decort_image": image.ResourceImage(),
"decort_image_virtual": image.ResourceImageVirtual(),
"decort_lb": lb.ResourceLB(),
"decort_lb_backend": lb.ResourceLBBackend(),
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
"decort_lb_frontend": lb.ResourceLBFrontend(),
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
"decort_vins_static_route": vins.ResourceStaticRoute(),
"decort_cb_account": cb_account.ResourceAccount(),
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
"decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
"decort_cb_disk": cb_disks.ResourceDisk(),
"decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
"decort_cb_image": cb_image.ResourceImage(),
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
"decort_cb_sep": cb_sep.ResourceSep(),
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
"decort_cb_vins": cb_vins.ResourceVins(),
"decort_cb_k8ci": cb_k8ci.ResourceK8CI(),
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
"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(),
}
}

View File

@@ -1,55 +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>
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 provider
import (
"os"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ca "github.com/rudecs/terraform-provider-decort/internal/provider/cloudapi"
cb "github.com/rudecs/terraform-provider-decort/internal/provider/cloudbroker"
)
func selectSchema(isDatasource bool) map[string]*schema.Resource {
adminMode, err := strconv.ParseBool(os.Getenv("DECORT_ADMIN_MODE"))
if err != nil {
adminMode = false
}
if isDatasource {
return selectDataSourceSchema(adminMode)
}
return selectResourceSchema(adminMode)
}
func selectDataSourceSchema(adminMode bool) map[string]*schema.Resource {
if adminMode {
return cb.NewDataSourcesMap()
}
return ca.NewDataSourcesMap()
}
func selectResourceSchema(adminMode bool) map[string]*schema.Resource {
if adminMode {
return cb.NewRersourcesMap()
}
return ca.NewRersourcesMap()
}

View File

@@ -1,55 +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>
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://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
const accountAddUserAPI = "/restmachine/cloudapi/account/addUser"
const accountAuditsAPI = "/restmachine/cloudapi/account/audits"
const accountCreateAPI = "/restmachine/cloudapi/account/create"
const accountDeleteAPI = "/restmachine/cloudapi/account/delete"
const accountDeleteUserAPI = "/restmachine/cloudapi/account/deleteUser"
const accountDisableAPI = "/restmachine/cloudapi/account/disable"
const accountEnableAPI = "/restmachine/cloudapi/account/enable"
const accountGetAPI = "/restmachine/cloudapi/account/get"
const accountGetConsumedUnitsAPI = "/restmachine/cloudapi/account/getConsumedAccountUnits"
const accountGetConsumedUnitsByTypeAPI = "/restmachine/cloudapi/account/getConsumedCloudUnitsByType"
const accountGetReservedUnitsAPI = "/restmachine/cloudapi/account/getReservedAccountUnits"
const accountListAPI = "/restmachine/cloudapi/account/list"
const accountListComputesAPI = "/restmachine/cloudapi/account/listComputes"
const accountListDeletedAPI = "/restmachine/cloudapi/account/listDeleted"
const accountListDisksAPI = "/restmachine/cloudapi/account/listDisks"
const accountListFlipGroupsAPI = "/restmachine/cloudapi/account/listFlipGroups"
const accountListRGAPI = "/restmachine/cloudapi/account/listRG"
const accountListTemplatesAPI = "/restmachine/cloudapi/account/listTemplates"
const accountListVinsAPI = "/restmachine/cloudapi/account/listVins"
const accountRestoreAPI = "/restmachine/cloudapi/account/restore"
const accountUpdateAPI = "/restmachine/cloudapi/account/update"
const accountUpdateUserAPI = "/restmachine/cloudapi/account/updateUser"

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,154 +22,244 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/flattens"
) )
// 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)
} }
id := uuid.New() flattenAccount(d, *acc)
d.SetId(id.String()) d.SetId(strconv.Itoa(int(acc.ID)))
d.Set("dc_location", acc.DCLocation)
d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey)
d.Set("meta", flattens.FlattenMeta(acc.Meta))
d.Set("acl", flattenAccAcl(acc.Acl))
d.Set("company", acc.Company)
d.Set("companyurl", acc.CompanyUrl)
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactiovationTime)
d.Set("deleted_by", acc.DeletedBy)
d.Set("deleted_time", acc.DeletedTime)
d.Set("displayname", acc.DisplayName)
d.Set("guid", acc.GUID)
d.Set("account_id", acc.ID)
d.Set("account_name", acc.Name)
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("service_account", acc.ServiceAccount)
d.Set("status", acc.Status)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.Vins)
d.Set("vinses", acc.Vinses)
d.Set("computes", flattenAccComputes(acc.Computes))
d.Set("machines", flattenAccMachines(acc.Machines))
return nil return nil
} }
func flattenAccComputes(acs Computes) []map[string]interface{} { func aclSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
temp := map[string]interface{}{ "can_be_deleted": {
"started": acs.Started, Type: schema.TypeBool,
"stopped": acs.Stopped, Computed: true,
},
"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,
},
} }
res = append(res, temp)
return res return res
} }
func flattenAccMachines(ams Machines) []map[string]interface{} { func resourceLimitsSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
temp := map[string]interface{}{ "cu_c": {
"running": ams.Running, Type: schema.TypeFloat,
"halted": ams.Halted, 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,
},
} }
res = append(res, temp)
return res return res
} }
func flattenAccAcl(acls []AccountAclRecord) []map[string]interface{} { func sepsSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
for _, acls := range acls { "sep_id": {
temp := map[string]interface{}{ Type: schema.TypeString,
"can_be_deleted": acls.CanBeDeleted, Computed: true,
"explicit": acls.IsExplicit, },
"guid": acls.Guid, "data_name": {
"right": acls.Rights, Type: schema.TypeString,
"status": acls.Status, Computed: true,
"type": acls.Type, },
"user_group_id": acls.UgroupID, "disk_size": {
} Type: schema.TypeFloat,
res = append(res, temp) Computed: true,
},
"disk_size_max": {
Type: schema.TypeInt,
Computed: true,
},
} }
return res return res
} }
func flattenRgResourceLimits(rl ResourceLimits) []map[string]interface{} { func resourcesSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
temp := map[string]interface{}{ "current": {
"cu_c": rl.CUC, Type: schema.TypeList,
"cu_d": rl.CUD, Computed: true,
"cu_i": rl.CUI, Elem: &schema.Resource{
"cu_m": rl.CUM, Schema: map[string]*schema.Schema{
"cu_np": rl.CUNP, "cpu": {
"gpu_units": rl.GpuUnits, Type: schema.TypeInt,
Computed: true,
},
"disksize": {
Type: schema.TypeFloat,
Computed: true,
},
"extips": {
Type: schema.TypeInt,
Computed: true,
},
"exttraffic": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"seps": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: sepsSchemaMake(),
},
},
},
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disksize": {
Type: schema.TypeFloat,
Computed: true,
},
"extips": {
Type: schema.TypeInt,
Computed: true,
},
"exttraffic": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"seps": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: sepsSchemaMake(),
},
},
},
},
},
} }
res = append(res, temp)
return res return res
}
func flattenAccResources(r Resources) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"current": flattenAccResource(r.Current),
"reserved": flattenAccResource(r.Reserved),
}
res = append(res, temp)
return res
} }
func flattenAccountSeps(seps map[string]map[string]ResourceSep) []map[string]interface{} { func computesSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
for sepKey, sepVal := range seps { "started": {
for dataKey, dataVal := range sepVal { Type: schema.TypeInt,
temp := map[string]interface{}{ Computed: true,
"sep_id": sepKey, },
"data_name": dataKey, "stopped": {
"disk_size": dataVal.DiskSize, Type: schema.TypeInt,
"disk_size_max": dataVal.DiskSizeMax, Computed: true,
} },
res = append(res, temp)
}
} }
return res return res
} }
func flattenAccResource(r Resource) []map[string]interface{} { func machinesSchemaMake() map[string]*schema.Schema {
res := make([]map[string]interface{}, 0) res := map[string]*schema.Schema{
temp := map[string]interface{}{ "halted": {
"cpu": r.CPU, Type: schema.TypeInt,
"disksize": r.Disksize, Computed: true,
"extips": r.Extips, },
"exttraffic": r.Exttraffic, "running": {
"gpu": r.GPU, Type: schema.TypeInt,
"ram": r.RAM, Computed: true,
"seps": flattenAccountSeps(r.SEPs), },
} }
res = append(res, temp)
return res return res
} }
@@ -183,126 +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: map[string]*schema.Schema{ // Schema: resourcesSchemaMake(),
"current": { // },
Type: schema.TypeList, // },
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disksize": {
Type: schema.TypeInt,
Computed: true,
},
"extips": {
Type: schema.TypeInt,
Computed: true,
},
"exttraffic": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"seps": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeString,
Computed: true,
},
"data_name": {
Type: schema.TypeString,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disksize": {
Type: schema.TypeInt,
Computed: true,
},
"extips": {
Type: schema.TypeInt,
Computed: true,
},
"exttraffic": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"seps": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeString,
Computed: true,
},
"data_name": {
Type: schema.TypeString,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
},
},
},
"ckey": { "ckey": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -318,36 +296,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: aclSchemaMake(),
"can_be_deleted": {
Type: schema.TypeBool,
Computed: true,
},
"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,
},
},
}, },
}, },
"company": { "company": {
@@ -394,32 +343,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: resourceLimitsSchemaMake(),
"cu_c": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_d": {
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,
},
},
}, },
}, },
"send_access_emails": { "send_access_emails": {
@@ -453,38 +377,28 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: computesSchemaMake(),
"started": {
Type: schema.TypeInt,
Computed: true,
},
"stopped": {
Type: schema.TypeInt,
Computed: true,
},
},
}, },
}, },
"machines": { "machines": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: machinesSchemaMake(),
"halted": {
Type: schema.TypeInt,
Computed: true,
},
"running": {
Type: schema.TypeInt,
Computed: true,
},
},
}, },
}, },
"vinses": { "vinses": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"cpu_allocation_parameter": {
Type: schema.TypeString,
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Computed: true,
},
} }
return res return res
} }

View File

@@ -1,125 +1,128 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountAuditsList(aal AccountAuditsList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, aa := range aal { func flattenAccountAuditsList(aal account.ListAudits) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"call": aa.Call, for _, aa := range aal {
"responsetime": aa.ResponseTime, temp := map[string]interface{}{
"statuscode": aa.StatusCode, "call": aa.Call,
"timestamp": aa.Timestamp, "responsetime": aa.ResponseTime,
"user": aa.User, "statuscode": aa.StatusCode,
} "timestamp": aa.Timestamp,
res = append(res, temp) "user": aa.User,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountAuditsList(accountAuditsList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountAuditsList(accountAuditsList))
func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema { return nil
res := map[string]*schema.Schema{ }
"account_id": {
Type: schema.TypeInt, func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
Required: true, res := map[string]*schema.Schema{
Description: "ID of the account", "account_id": {
}, Type: schema.TypeInt,
"items": { Required: true,
Type: schema.TypeList, Description: "ID of the account",
Computed: true, },
Description: "Search Result", "items": {
Elem: &schema.Resource{ Type: schema.TypeList,
Schema: map[string]*schema.Schema{ Computed: true,
"call": { Description: "Search Result",
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "call": {
"responsetime": { Type: schema.TypeString,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "responsetime": {
"statuscode": { Type: schema.TypeFloat,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "statuscode": {
"timestamp": { Type: schema.TypeInt,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "timestamp": {
"user": { Type: schema.TypeFloat,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "user": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
} },
return res },
} },
}
func DataSourceAccountAuditsList() *schema.Resource { return res
return &schema.Resource{ }
SchemaVersion: 1,
func DataSourceAccountAuditsList() *schema.Resource {
ReadContext: dataSourceAccountAuditsListRead, return &schema.Resource{
SchemaVersion: 1,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, ReadContext: dataSourceAccountAuditsListRead,
Default: &constants.Timeout60s,
}, Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Schema: dataSourceAccountAuditsListSchemaMake(), Default: &constants.Timeout60s,
} },
}
Schema: dataSourceAccountAuditsListSchemaMake(),
}
}

View File

@@ -1,200 +1,258 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountComputesList(acl AccountComputesList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, acc := range acl { func flattenAccountComputesList(acl *account.ListComputes) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"account_id": acc.AccountId, for _, acc := range acl.Data {
"account_name": acc.AccountName, temp := map[string]interface{}{
"cpus": acc.CPUs, "account_id": acc.AccountID,
"created_by": acc.CreatedBy, "account_name": acc.AccountName,
"created_time": acc.CreatedTime, "cpus": acc.CPUs,
"deleted_by": acc.DeletedBy, "created_by": acc.CreatedBy,
"deleted_time": acc.DeletedTime, "created_time": acc.CreatedTime,
"compute_id": acc.ComputeId, "deleted_by": acc.DeletedBy,
"compute_name": acc.ComputeName, "deleted_time": acc.DeletedTime,
"ram": acc.RAM, "compute_id": acc.ComputeID,
"registered": acc.Registered, "compute_name": acc.ComputeName,
"rg_id": acc.RgId, "ram": acc.RAM,
"rg_name": acc.RgName, "registered": acc.Registered,
"status": acc.Status, "rg_id": acc.RGID,
"tech_status": acc.TechStatus, "rg_name": acc.RGName,
"total_disks_size": acc.TotalDisksSize, "status": acc.Status,
"updated_by": acc.UpdatedBy, "tech_status": acc.TechStatus,
"updated_time": acc.UpdatedTime, "total_disks_size": acc.TotalDisksSize,
"user_managed": acc.UserManaged, "updated_by": acc.UpdatedBy,
"vins_connected": acc.VinsConnected, "updated_time": acc.UpdatedTime,
} "user_managed": acc.UserManaged,
res = append(res, temp) "vins_connected": acc.VINSConnected,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountComputesList(accountComputesList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountComputesList(accountComputesList))
d.Set("entry_count", accountComputesList.EntryCount)
func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Required: true, func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account", res := map[string]*schema.Schema{
}, "account_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Required: true,
Computed: true, Description: "ID of the account",
Description: "Search Result", },
Elem: &schema.Resource{ "compute_id": {
Schema: map[string]*schema.Schema{ Type: schema.TypeInt,
"account_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by compute ID",
Computed: true, },
}, "name": {
"account_name": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by compute name",
}, },
"cpus": { "rg_name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by RG name",
"created_by": { },
Type: schema.TypeString, "rg_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"created_time": { Description: "Filter by RG ID",
Type: schema.TypeInt, },
Computed: true, "tech_status": {
}, Type: schema.TypeString,
"deleted_by": { Optional: true,
Type: schema.TypeString, Description: "Filter by tech. status",
Computed: true, },
}, "ip_address": {
"deleted_time": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Filter by IP address",
}, },
"compute_id": { "extnet_name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by extnet name",
"compute_name": { },
Type: schema.TypeString, "extnet_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"ram": { Description: "Filter by extnet ID",
Type: schema.TypeInt, },
Computed: true, "page": {
}, Type: schema.TypeInt,
"registered": { Optional: true,
Type: schema.TypeBool, Description: "Page number",
Computed: true, },
}, "size": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Page size",
}, },
"rg_name": { "items": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
}, Description: "Search Result",
"status": { Elem: &schema.Resource{
Type: schema.TypeString, Schema: map[string]*schema.Schema{
Computed: true, "account_id": {
}, Type: schema.TypeInt,
"tech_status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "account_name": {
}, Type: schema.TypeString,
"total_disks_size": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "cpus": {
}, Type: schema.TypeInt,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "created_by": {
}, Type: schema.TypeString,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_time": {
}, Type: schema.TypeInt,
"user_managed": { Computed: true,
Type: schema.TypeBool, },
Computed: true, "deleted_by": {
}, Type: schema.TypeString,
"vins_connected": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "deleted_time": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "compute_id": {
} Type: schema.TypeInt,
return res Computed: true,
} },
"compute_name": {
func DataSourceAccountComputesList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"ram": {
ReadContext: dataSourceAccountComputesListRead, Type: schema.TypeInt,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "registered": {
Default: &constants.Timeout60s, Type: schema.TypeBool,
}, Computed: true,
},
Schema: dataSourceAccountComputesListSchemaMake(), "rg_id": {
} Type: schema.TypeInt,
} Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"total_disks_size": {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
"vins_connected": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountComputesList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountComputesListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountComputesListSchemaMake(),
}
}

View File

@@ -1,109 +1,116 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m) func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("cu_c", accountConsumedUnits.CUC) id := uuid.New()
d.Set("cu_d", accountConsumedUnits.CUD) d.SetId(id.String())
d.Set("cu_i", accountConsumedUnits.CUI) d.Set("cu_c", accountConsumedUnits.CUC)
d.Set("cu_m", accountConsumedUnits.CUM) d.Set("cu_d", accountConsumedUnits.CUD)
d.Set("cu_np", accountConsumedUnits.CUNP) d.Set("cu_dm", accountConsumedUnits.CUDM)
d.Set("gpu_units", accountConsumedUnits.GpuUnits) d.Set("cu_i", accountConsumedUnits.CUI)
d.Set("cu_m", accountConsumedUnits.CUM)
return nil d.Set("cu_np", accountConsumedUnits.CUNP)
} d.Set("gpu_units", accountConsumedUnits.GPUUnits)
func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema { return nil
res := map[string]*schema.Schema{ }
"account_id": {
Type: schema.TypeInt, func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
Required: true, res := map[string]*schema.Schema{
Description: "ID of the account", "account_id": {
}, Type: schema.TypeInt,
"cu_c": { Required: true,
Type: schema.TypeFloat, Description: "ID of the account",
Computed: true, },
}, "cu_c": {
"cu_d": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_d": {
"cu_i": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_dm": {
"cu_m": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_i": {
"cu_np": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_m": {
"gpu_units": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_np": {
} Type: schema.TypeFloat,
return res Computed: true,
} },
"gpu_units": {
func DataSourceAccountConsumedUnits() *schema.Resource { Type: schema.TypeFloat,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
}
ReadContext: dataSourceAccountConsumedUnitsRead, return res
}
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, func DataSourceAccountConsumedUnits() *schema.Resource {
Default: &constants.Timeout60s, return &schema.Resource{
}, SchemaVersion: 1,
Schema: dataSourceAccountConsumedUnitsSchemaMake(), ReadContext: dataSourceAccountConsumedUnitsRead,
}
} Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountConsumedUnitsSchemaMake(),
}
}

View File

@@ -1,89 +1,91 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m) func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("cu_result", result) id := uuid.New()
d.SetId(id.String())
return nil d.Set("cu_result", result)
}
return nil
func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Required: true, "account_id": {
Description: "ID of the account", Type: schema.TypeInt,
}, Required: true,
"cu_type": { Description: "ID of the account",
Type: schema.TypeString, },
Required: true, "cu_type": {
Description: "cloud unit resource type", Type: schema.TypeString,
}, Required: true,
"cu_result": { Description: "cloud unit resource type",
Type: schema.TypeFloat, },
Computed: true, "cu_result": {
}, Type: schema.TypeFloat,
} Computed: true,
return res },
} }
return res
func DataSourceAccountConsumedUnitsByType() *schema.Resource { }
return &schema.Resource{
SchemaVersion: 1, func DataSourceAccountConsumedUnitsByType() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAccountConsumedUnitsByTypeRead, SchemaVersion: 1,
Timeouts: &schema.ResourceTimeout{ ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
Read: &constants.Timeout30s,
Default: &constants.Timeout60s, Timeouts: &schema.ResourceTimeout{
}, Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(), },
}
} Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),
}
}

View File

@@ -1,69 +1,78 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m) func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("items", flattenAccountList(accountDeletedList)) id := uuid.New()
d.SetId(id.String())
return nil d.Set("items", flattenAccountList(accountDeletedList))
} d.Set("entry_count", accountDeletedList.EntryCount)
func DataSourceAccountDeletedList() *schema.Resource { return nil
return &schema.Resource{ }
SchemaVersion: 1,
func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
ReadContext: dataSourceAccountDeletedListRead, temp := dataSourceAccountListSchemaMake()
delete(temp, "status")
Timeouts: &schema.ResourceTimeout{ return temp
Read: &constants.Timeout30s, }
Default: &constants.Timeout60s,
}, func DataSourceAccountDeletedList() *schema.Resource {
return &schema.Resource{
Schema: dataSourceAccountListSchemaMake(), SchemaVersion: 1,
}
} ReadContext: dataSourceAccountDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountDeletedListSchemaMake(),
}
}

View File

@@ -1,134 +1,172 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
package account */
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountDisksList(adl AccountDisksList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, ad := range adl { func flattenAccountDisksList(adl *account.ListDisks) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"disk_id": ad.ID, for _, ad := range adl.Data {
"disk_name": ad.Name, temp := map[string]interface{}{
"pool": ad.Pool, "disk_id": ad.ID,
"sep_id": ad.SepId, "disk_name": ad.Name,
"shareable": ad.Shareable, "pool": ad.Pool,
"size_max": ad.SizeMax, "sep_id": ad.SEPID,
"type": ad.Type, "shareable": ad.Shareable,
} "size_max": ad.SizeMax,
res = append(res, temp) "type": ad.Type,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountDisksList(accountDisksList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountDisksList(accountDisksList))
d.Set("entry_count", accountDisksList.EntryCount)
func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Required: true, func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account", res := map[string]*schema.Schema{
}, "account_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Required: true,
Computed: true, Description: "ID of the account",
Description: "Search Result", },
Elem: &schema.Resource{ "disk_id": {
Schema: map[string]*schema.Schema{ Type: schema.TypeInt,
"disk_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by disk ID",
Computed: true, },
}, "name": {
"disk_name": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by disk name",
}, },
"pool": { "disk_max_size": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Filter by disk max size",
"sep_id": { },
Type: schema.TypeInt, "type": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"shareable": { Description: "Filter by disk type",
Type: schema.TypeBool, },
Computed: true, "page": {
}, Type: schema.TypeInt,
"size_max": { Optional: true,
Type: schema.TypeInt, Description: "Page number",
Computed: true, },
}, "size": {
"type": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Page size",
}, },
}, "items": {
}, Type: schema.TypeList,
}, Computed: true,
} Description: "Search Result",
return res Elem: &schema.Resource{
} Schema: map[string]*schema.Schema{
"disk_id": {
func DataSourceAccountDisksList() *schema.Resource { Type: schema.TypeInt,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"disk_name": {
ReadContext: dataSourceAccountDisksListRead, Type: schema.TypeString,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "pool": {
Default: &constants.Timeout60s, Type: schema.TypeString,
}, Computed: true,
},
Schema: dataSourceAccountDisksListSchemaMake(), "sep_id": {
} Type: schema.TypeInt,
} Computed: true,
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountDisksList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountDisksListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountDisksListSchemaMake(),
}
}

View File

@@ -1,205 +1,253 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountFlipGroupsList(afgl AccountFlipGroupsList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, afg := range afgl { func flattenAccountFlipGroupsList(afgl *account.ListFLIPGroups) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"account_id": afg.AccountId, for _, afg := range afgl.Data {
"client_type": afg.ClientType, temp := map[string]interface{}{
"conn_type": afg.ConnType, "account_id": afg.AccountID,
"created_by": afg.CreatedBy, "client_type": afg.ClientType,
"created_time": afg.CreatedTime, "conn_type": afg.ConnType,
"default_gw": afg.DefaultGW, "created_by": afg.CreatedBy,
"deleted_by": afg.DeletedBy, "created_time": afg.CreatedTime,
"deleted_time": afg.DeletedTime, "default_gw": afg.DefaultGW,
"desc": afg.Desc, "deleted_by": afg.DeletedBy,
"gid": afg.GID, "deleted_time": afg.DeletedTime,
"guid": afg.GUID, "desc": afg.Description,
"fg_id": afg.ID, "gid": afg.GID,
"ip": afg.IP, "guid": afg.GUID,
"milestones": afg.Milestones, "fg_id": afg.ID,
"fg_name": afg.Name, "ip": afg.IP,
"net_id": afg.NetID, "milestones": afg.Milestones,
"net_type": afg.NetType, "fg_name": afg.Name,
"netmask": afg.NetMask, "net_id": afg.NetID,
"status": afg.Status, "net_type": afg.NetType,
"updated_by": afg.UpdatedBy, "netmask": afg.NetMask,
"updated_time": afg.UpdatedTime, "status": afg.Status,
} "updated_by": afg.UpdatedBy,
res = append(res, temp) "updated_time": afg.UpdatedTime,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
d.Set("entry_count", accountFlipGroupsList.EntryCount)
func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Required: true, func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account", res := map[string]*schema.Schema{
}, "account_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Required: true,
Computed: true, Description: "ID of the account",
Description: "Search Result", },
Elem: &schema.Resource{ "name": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"account_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by name",
Computed: true, },
}, "vins_id": {
"client_type": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by ViNS ID",
}, },
"conn_type": { "vins_name": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by ViNS name",
"created_by": { },
Type: schema.TypeString, "extnet_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"created_time": { Description: "Filter by extnet ID",
Type: schema.TypeInt, },
Computed: true, "by_ip": {
}, Type: schema.TypeString,
"default_gw": { Optional: true,
Type: schema.TypeString, Description: "Filter by IP",
Computed: true, },
}, "flipgroup_id": {
"deleted_by": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by flipgroup ID",
}, },
"deleted_time": { "page": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page number",
"desc": { },
Type: schema.TypeString, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"gid": { Description: "Page size",
Type: schema.TypeInt, },
Computed: true, "items": {
}, Type: schema.TypeList,
"guid": { Computed: true,
Type: schema.TypeInt, Description: "Search Result",
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"fg_id": { "account_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"ip": { "client_type": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"milestones": { "conn_type": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"fg_name": { "created_by": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"net_id": { "created_time": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"net_type": { "default_gw": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"netmask": { "deleted_by": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"status": { "deleted_time": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"updated_by": { "desc": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"updated_time": { "gid": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
}, "guid": {
}, Type: schema.TypeInt,
}, Computed: true,
} },
return res "fg_id": {
} Type: schema.TypeInt,
Computed: true,
func DataSourceAccountFlipGroupsList() *schema.Resource { },
return &schema.Resource{ "ip": {
SchemaVersion: 1, Type: schema.TypeString,
Computed: true,
ReadContext: dataSourceAccountFlipGroupsListRead, },
"milestones": {
Timeouts: &schema.ResourceTimeout{ Type: schema.TypeInt,
Read: &constants.Timeout30s, Computed: true,
Default: &constants.Timeout60s, },
}, "fg_name": {
Type: schema.TypeString,
Schema: dataSourceAccountFlipGroupsListSchemaMake(), Computed: true,
} },
} "net_id": {
Type: schema.TypeInt,
Computed: true,
},
"net_type": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountFlipGroupsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountFlipGroupsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
}
}

View File

@@ -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(),
}
}

View File

@@ -1,182 +1,210 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountList(al AccountCloudApiList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, acc := range al { func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"acl": flattenRgAcl(acc.Acl), for _, acc := range al.Data {
"created_time": acc.CreatedTime, temp := map[string]interface{}{
"deleted_time": acc.DeletedTime, "acl": flattenRgAcl(acc.ACL),
"account_id": acc.ID, "created_time": acc.CreatedTime,
"account_name": acc.Name, "deleted_time": acc.DeletedTime,
"status": acc.Status, "account_id": acc.ID,
"updated_time": acc.UpdatedTime, "account_name": acc.Name,
} "status": acc.Status,
res = append(res, temp) "updated_time": acc.UpdatedTime,
} }
return res res = append(res, temp)
} }
return res
func flattenRgAcl(rgAcls []AccountAclRecord) []map[string]interface{} { }
res := make([]map[string]interface{}, 0)
for _, rgAcl := range rgAcls { func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"explicit": rgAcl.IsExplicit, for _, rgAcl := range rgAcls {
"guid": rgAcl.Guid, temp := map[string]interface{}{
"right": rgAcl.Rights, "explicit": rgAcl.IsExplicit,
"status": rgAcl.Status, "guid": rgAcl.GUID,
"type": rgAcl.Type, "right": rgAcl.Rights,
"user_group_id": rgAcl.UgroupID, "status": rgAcl.Status,
} "type": rgAcl.Type,
res = append(res, temp) "user_group_id": rgAcl.UgroupID,
} }
return res res = append(res, temp)
} }
return res
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountList, err := utilityAccountListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountList(accountList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountList(accountList))
d.Set("entry_count", accountList.EntryCount)
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"page": { }
Type: schema.TypeInt,
Optional: true, func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Description: "Page number", res := map[string]*schema.Schema{
}, "by_id": {
"size": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Optional: true, Description: "Filter by ID",
Description: "Page size", },
}, "name": {
"items": { Type: schema.TypeString,
Type: schema.TypeList, Optional: true,
Computed: true, Description: "Filter by name",
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "acl": {
"acl": { Type: schema.TypeString,
Type: schema.TypeList, Optional: true,
Computed: true, Description: "Filter by ACL",
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "status": {
"explicit": { Type: schema.TypeString,
Type: schema.TypeBool, Optional: true,
Computed: true, Description: "Filter by status",
}, },
"guid": { "page": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page number",
"right": { },
Type: schema.TypeString, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"status": { Description: "Page size",
Type: schema.TypeString, },
Computed: true, "items": {
}, Type: schema.TypeList,
"type": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "acl": {
"user_group_id": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
}, "explicit": {
}, Type: schema.TypeBool,
}, Computed: true,
"created_time": { },
Type: schema.TypeInt, "guid": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"deleted_time": { },
Type: schema.TypeInt, "right": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"account_id": { },
Type: schema.TypeInt, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"account_name": { },
Type: schema.TypeString, "type": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"status": { },
Type: schema.TypeString, "user_group_id": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, },
Computed: true, },
}, },
}, "created_time": {
}, Type: schema.TypeInt,
}, Computed: true,
} },
return res "deleted_time": {
} Type: schema.TypeInt,
Computed: true,
func DataSourceAccountList() *schema.Resource { },
return &schema.Resource{ "account_id": {
SchemaVersion: 1, Type: schema.TypeInt,
Computed: true,
ReadContext: dataSourceAccountListRead, },
"account_name": {
Timeouts: &schema.ResourceTimeout{ Type: schema.TypeString,
Read: &constants.Timeout30s, Computed: true,
Default: &constants.Timeout60s, },
}, "status": {
Type: schema.TypeString,
Schema: dataSourceAccountListSchemaMake(), Computed: true,
} },
} "updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountListSchemaMake(),
}
}

View File

@@ -1,109 +1,116 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m) func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("cu_c", accountReservedUnits.CUC) id := uuid.New()
d.Set("cu_d", accountReservedUnits.CUD) d.SetId(id.String())
d.Set("cu_i", accountReservedUnits.CUI) d.Set("cu_c", accountReservedUnits.CUC)
d.Set("cu_m", accountReservedUnits.CUM) d.Set("cu_d", accountReservedUnits.CUD)
d.Set("cu_np", accountReservedUnits.CUNP) d.Set("cu_dm", accountReservedUnits.CUDM)
d.Set("gpu_units", accountReservedUnits.GpuUnits) d.Set("cu_i", accountReservedUnits.CUI)
d.Set("cu_m", accountReservedUnits.CUM)
return nil d.Set("cu_np", accountReservedUnits.CUNP)
} d.Set("gpu_units", accountReservedUnits.GPUUnits)
func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema { return nil
res := map[string]*schema.Schema{ }
"account_id": {
Type: schema.TypeInt, func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
Required: true, res := map[string]*schema.Schema{
Description: "ID of the account", "account_id": {
}, Type: schema.TypeInt,
"cu_c": { Required: true,
Type: schema.TypeFloat, Description: "ID of the account",
Computed: true, },
}, "cu_c": {
"cu_d": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_d": {
"cu_i": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_dm": {
"cu_m": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_i": {
"cu_np": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_m": {
"gpu_units": { Type: schema.TypeFloat,
Type: schema.TypeFloat, Computed: true,
Computed: true, },
}, "cu_np": {
} Type: schema.TypeFloat,
return res Computed: true,
} },
"gpu_units": {
func DataSourceAccountReservedUnits() *schema.Resource { Type: schema.TypeFloat,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
}
ReadContext: dataSourceAccountReservedUnitsRead, return res
}
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, func DataSourceAccountReservedUnits() *schema.Resource {
Default: &constants.Timeout60s, return &schema.Resource{
}, SchemaVersion: 1,
Schema: dataSourceAccountReservedUnitsSchemaMake(), ReadContext: dataSourceAccountReservedUnitsRead,
}
} Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountReservedUnitsSchemaMake(),
}
}

View File

@@ -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(),
}
}

View File

@@ -1,300 +1,372 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountRGList(argl AccountRGList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, arg := range argl { func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"computes": flattenAccRGComputes(arg.Computes), for _, arg := range argl.Data {
"resources": flattenAccRGResources(arg.Resources), temp := map[string]interface{}{
"created_by": arg.CreatedBy, "computes": flattenAccRGComputes(arg.Computes),
"created_time": arg.CreatedTime, "resources": flattenAccRGResources(arg.Resources),
"deleted_by": arg.DeletedBy, "created_by": arg.CreatedBy,
"deleted_time": arg.DeletedTime, "created_time": arg.CreatedTime,
"rg_id": arg.RGID, "deleted_by": arg.DeletedBy,
"milestones": arg.Milestones, "deleted_time": arg.DeletedTime,
"rg_name": arg.RGName, "rg_id": arg.RGID,
"status": arg.Status, "milestones": arg.Milestones,
"updated_by": arg.UpdatedBy, "rg_name": arg.RGName,
"updated_time": arg.UpdatedTime, "status": arg.Status,
"vinses": arg.Vinses, "updated_by": arg.UpdatedBy,
} "updated_time": arg.UpdatedTime,
res = append(res, temp) "vinses": arg.VINSes,
} }
return res res = append(res, temp)
}
} return res
func flattenAccRGComputes(argc AccountRGComputes) []map[string]interface{} { }
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ func flattenAccRGComputes(argc account.RGComputes) []map[string]interface{} {
"started": argc.Started, res := make([]map[string]interface{}, 0)
"stopped": argc.Stopped, temp := map[string]interface{}{
} "started": argc.Started,
res = append(res, temp) "stopped": argc.Stopped,
return res }
} res = append(res, temp)
return res
func flattenAccRGResources(argr AccountRGResources) []map[string]interface{} { }
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ func flattenAccResourceHack(r account.LimitsRG) []map[string]interface{} {
"consumed": flattenAccResource(argr.Consumed), res := make([]map[string]interface{}, 0)
"limits": flattenAccResource(argr.Limits), temp := map[string]interface{}{
"reserved": flattenAccResource(argr.Reserved), "cpu": r.CPU,
} "disksize": r.DiskSize,
res = append(res, temp) "extips": r.ExtIPs,
return res "exttraffic": r.ExtTraffic,
} "gpu": r.GPU,
"ram": r.RAM,
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { //"seps": flattenAccountSeps(r.SEPs),
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m) }
if err != nil { res = append(res, temp)
return diag.FromErr(err) return res
} }
id := uuid.New() func flattenAccResourceRg(r account.Resource) []map[string]interface{} {
d.SetId(id.String()) res := make([]map[string]interface{}, 0)
d.Set("items", flattenAccountRGList(accountRGList)) temp := map[string]interface{}{
"cpu": r.CPU,
return nil "disksize": r.DiskSize,
} "extips": r.ExtIPs,
"exttraffic": r.ExtTraffic,
func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { "gpu": r.GPU,
res := map[string]*schema.Schema{ "ram": r.RAM,
"account_id": { }
Type: schema.TypeInt, res = append(res, temp)
Required: true, return res
Description: "ID of the account", }
},
"items": { func flattenAccRGResources(argr account.RGResources) []map[string]interface{} {
Type: schema.TypeList, res := make([]map[string]interface{}, 0)
Computed: true, temp := map[string]interface{}{
Description: "Search Result", "consumed": flattenAccResourceRg(argr.Consumed),
Elem: &schema.Resource{ "limits": flattenAccResourceHack(argr.Limits),
Schema: map[string]*schema.Schema{ "reserved": flattenAccResourceRg(argr.Reserved),
"computes": { }
Type: schema.TypeList, res = append(res, temp)
Computed: true, return res
Elem: &schema.Resource{ }
Schema: map[string]*schema.Schema{
"started": { func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
Type: schema.TypeInt, accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
Computed: true, if err != nil {
}, d.SetId("")
"stopped": { return diag.FromErr(err)
Type: schema.TypeInt, }
Computed: true,
}, id := uuid.New()
}, d.SetId(id.String())
}, d.Set("items", flattenAccountRGList(accountRGList))
}, d.Set("entry_count", accountRGList.EntryCount)
"resources": {
Type: schema.TypeList, return nil
Computed: true, }
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
"consumed": { res := map[string]*schema.Schema{
Type: schema.TypeList, "account_id": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Resource{ Required: true,
Schema: map[string]*schema.Schema{ Description: "ID of the account",
"cpu": { },
Type: schema.TypeInt, "page": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"disksize": { Description: "Page number",
Type: schema.TypeInt, },
Computed: true, "size": {
}, Type: schema.TypeInt,
"extips": { Optional: true,
Type: schema.TypeInt, Description: "Page size",
Computed: true, },
}, "rg_id": {
"exttraffic": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Filter by RG ID",
}, },
"gpu": { "vins_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Filter by ViNS ID",
"ram": { },
Type: schema.TypeInt, "vm_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
}, Description: "Filter by VM ID",
}, },
}, "name": {
Type: schema.TypeString,
"limits": { Optional: true,
Type: schema.TypeList, Description: "Filter by name",
Computed: true, },
Elem: &schema.Resource{ "status": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"cpu": { Optional: true,
Type: schema.TypeInt, Description: "Filter by status",
Computed: true, },
}, "items": {
"disksize": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Search Result",
}, Elem: &schema.Resource{
"extips": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "computes": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"exttraffic": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "started": {
}, Type: schema.TypeInt,
"gpu": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "stopped": {
}, Type: schema.TypeInt,
"ram": { Computed: true,
Type: schema.TypeInt, },
Computed: true, },
}, },
}, },
}, "resources": {
}, Type: schema.TypeList,
"reserved": { Computed: true,
Type: schema.TypeList, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
Elem: &schema.Resource{ "consumed": {
Schema: map[string]*schema.Schema{ Type: schema.TypeList,
"cpu": { Computed: true,
Type: schema.TypeInt, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "cpu": {
"disksize": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "disksize": {
"extips": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "extips": {
"exttraffic": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "exttraffic": {
"gpu": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "gpu": {
"ram": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "ram": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, },
}, },
}, },
"created_by": { "limits": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
}, Elem: &schema.Resource{
"created_time": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "cpu": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"deleted_by": { },
Type: schema.TypeString, "disksize": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"deleted_time": { },
Type: schema.TypeInt, "extips": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_id": { },
Type: schema.TypeInt, "exttraffic": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"milestones": { },
Type: schema.TypeInt, "gpu": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_name": { },
Type: schema.TypeString, "ram": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"status": { },
Type: schema.TypeString, },
Computed: true, },
}, },
"updated_by": { "reserved": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
}, Elem: &schema.Resource{
"updated_time": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "cpu": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"vinses": { },
Type: schema.TypeInt, "disksize": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "extips": {
}, Type: schema.TypeInt,
} Computed: true,
return res },
} "exttraffic": {
Type: schema.TypeInt,
func DataSourceAccountRGList() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, "gpu": {
Type: schema.TypeInt,
ReadContext: dataSourceAccountRGListRead, Computed: true,
},
Timeouts: &schema.ResourceTimeout{ "ram": {
Read: &constants.Timeout30s, Type: schema.TypeInt,
Default: &constants.Timeout60s, Computed: true,
}, },
},
Schema: dataSourceAccountRGListSchemaMake(), },
} },
} },
},
},
"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,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"vinses": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountRGList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountRGListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountRGListSchemaMake(),
}
}

View File

@@ -1,150 +1,186 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountTemplatesList(atl AccountTemplatesList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, at := range atl { func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0, len(atl.Data))
"unc_path": at.UNCPath, for _, at := range atl.Data {
"account_id": at.AccountId, temp := map[string]interface{}{
"desc": at.Desc, "unc_path": at.UNCPath,
"template_id": at.ID, "account_id": at.AccountID,
"template_name": at.Name, "desc": at.Description,
"public": at.Public, "template_id": at.ID,
"size": at.Size, "template_name": at.Name,
"status": at.Status, "public": at.Public,
"type": at.Type, "size": at.Size,
"username": at.Username, "status": at.Status,
} "type": at.Type,
res = append(res, temp) "username": at.Username,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
d.Set("entry_count", accountTemplatesList.EntryCount)
func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema { return nil
res := map[string]*schema.Schema{ }
"account_id": {
Type: schema.TypeInt, func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
Required: true, res := map[string]*schema.Schema{
Description: "ID of the account", "account_id": {
}, Type: schema.TypeInt,
"items": { Required: true,
Type: schema.TypeList, Description: "ID of the account",
Computed: true, },
Description: "Search Result", "include_deleted": {
Elem: &schema.Resource{ Type: schema.TypeBool,
Schema: map[string]*schema.Schema{ Optional: true,
"unc_path": { },
Type: schema.TypeString, "image_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"account_id": { Description: "Find by image id",
Type: schema.TypeInt, },
Computed: true, "name": {
}, Type: schema.TypeString,
"desc": { Optional: true,
Type: schema.TypeString, Description: "Filter by name",
Computed: true, },
}, "type": {
"template_id": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Filter by type",
}, },
"template_name": { "page": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page number",
"public": { },
Type: schema.TypeBool, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"size": { Description: "Page size",
Type: schema.TypeInt, },
Computed: true, "items": {
}, Type: schema.TypeList,
"status": { Computed: true,
Type: schema.TypeString, Description: "Search Result",
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"type": { "unc_path": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"username": { "account_id": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
}, "desc": {
}, Type: schema.TypeString,
}, Computed: true,
} },
return res "template_id": {
} Type: schema.TypeInt,
Computed: true,
func DataSourceAccountTemplatessList() *schema.Resource { },
return &schema.Resource{ "template_name": {
SchemaVersion: 1, Type: schema.TypeString,
Computed: true,
ReadContext: dataSourceAccountTemplatesListRead, },
"public": {
Timeouts: &schema.ResourceTimeout{ Type: schema.TypeBool,
Read: &constants.Timeout30s, Computed: true,
Default: &constants.Timeout60s, },
}, "size": {
Type: schema.TypeInt,
Schema: dataSourceAccountTemplatesListSchemaMake(), Computed: true,
} },
} "status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"username": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountTemplatessList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountTemplatesListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountTemplatesListSchemaMake(),
}
}

View File

@@ -1,185 +1,223 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
package account
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenAccountVinsList(avl AccountVinsList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, av := range avl { func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"account_id": av.AccountId, for _, av := range avl.Data {
"account_name": av.AccountName, temp := map[string]interface{}{
"computes": av.Computes, "account_id": av.AccountID,
"created_by": av.CreatedBy, "account_name": av.AccountName,
"created_time": av.CreatedTime, "computes": av.Computes,
"deleted_by": av.DeletedBy, "created_by": av.CreatedBy,
"deleted_time": av.DeletedTime, "created_time": av.CreatedTime,
"external_ip": av.ExternalIP, "deleted_by": av.DeletedBy,
"vin_id": av.ID, "deleted_time": av.DeletedTime,
"vin_name": av.Name, "external_ip": av.ExternalIP,
"network": av.Network, "vin_id": av.ID,
"pri_vnf_dev_id": av.PriVnfDevId, "vin_name": av.Name,
"rg_id": av.RgId, "network": av.Network,
"rg_name": av.RgName, "pri_vnf_dev_id": av.PriVNFDevID,
"status": av.Status, "rg_id": av.RGID,
"updated_by": av.UpdatedBy, "rg_name": av.RGName,
"updated_time": av.UpdatedTime, "status": av.Status,
} "updated_by": av.UpdatedBy,
res = append(res, temp) "updated_time": av.UpdatedTime,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountVinsList(accountVinsList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountVinsList(accountVinsList))
d.Set("entry_count", accountVinsList.EntryCount)
func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Required: true, func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account", res := map[string]*schema.Schema{
}, "account_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Required: true,
Computed: true, Description: "ID of the account",
Description: "Search Result", },
Elem: &schema.Resource{ "vins_id": {
Schema: map[string]*schema.Schema{ Type: schema.TypeInt,
"account_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by ViNS ID",
Computed: true, },
}, "name": {
"account_name": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by name",
}, },
"computes": { "rg_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Filter by RG ID",
"created_by": { },
Type: schema.TypeString, "ext_ip": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"created_time": { Description: "Filter by external IP",
Type: schema.TypeInt, },
Computed: true, "page": {
}, Type: schema.TypeInt,
"deleted_by": { Optional: true,
Type: schema.TypeString, Description: "Page number",
Computed: true, },
}, "size": {
"deleted_time": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Page size",
}, },
"external_ip": { "items": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
}, Description: "Search Result",
"vin_id": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "account_id": {
}, Type: schema.TypeInt,
"vin_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "account_name": {
}, Type: schema.TypeString,
"network": { Computed: true,
Type: schema.TypeString, },
Computed: true, "computes": {
}, Type: schema.TypeInt,
"pri_vnf_dev_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_by": {
}, Type: schema.TypeString,
"rg_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_time": {
}, Type: schema.TypeInt,
"rg_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "deleted_by": {
}, Type: schema.TypeString,
"status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "deleted_time": {
}, Type: schema.TypeInt,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "external_ip": {
}, Type: schema.TypeString,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "vin_id": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "vin_name": {
} Type: schema.TypeString,
return res Computed: true,
} },
"network": {
func DataSourceAccountVinsList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"pri_vnf_dev_id": {
ReadContext: dataSourceAccountVinsListRead, Type: schema.TypeInt,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "rg_id": {
Default: &constants.Timeout60s, Type: schema.TypeInt,
}, Computed: true,
},
Schema: dataSourceAccountVinsListSchemaMake(), "rg_name": {
} Type: schema.TypeString,
} Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountVinsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountVinsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountVinsListSchemaMake(),
}
}

View File

@@ -0,0 +1,159 @@
package account
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
)
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("dc_location", acc.DCLocation)
// d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey)
d.Set("acl", flattenAccAcl(acc.ACL))
d.Set("company", acc.Company)
d.Set("companyurl", acc.CompanyURL)
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactivationTime)
d.Set("deleted_by", acc.DeletedBy)
d.Set("deleted_time", acc.DeletedTime)
d.Set("displayname", acc.DisplayName)
d.Set("guid", acc.GUID)
d.Set("account_id", acc.ID)
d.Set("account_name", acc.Name)
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.VINS)
d.Set("vinses", acc.VINSes)
d.Set("computes", flattenAccComputes(acc.Computes))
d.Set("machines", flattenAccMachines(acc.Machines))
d.Set("cpu_allocation_parameter", acc.CPUAllocationParameter)
d.Set("cpu_allocation_ratio", acc.CPUAllocationRatio)
if username, ok := d.GetOk("username"); ok {
d.Set("username", username)
} else {
d.Set("username", acc.ACL[0].UgroupID)
}
return nil
}
func flattenAccComputes(acs account.Computes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"started": acs.Started,
"stopped": acs.Stopped,
}
res = append(res, temp)
return res
}
func flattenAccMachines(ams account.Machines) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"running": ams.Running,
"halted": ams.Halted,
}
res = append(res, temp)
return res
}
func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, acls := range acls {
temp := map[string]interface{}{
"can_be_deleted": acls.CanBeDeleted,
"explicit": acls.IsExplicit,
"guid": acls.GUID,
"right": acls.Rights,
"status": acls.Status,
"type": acls.Type,
"user_group_id": acls.UgroupID,
}
res = append(res, temp)
}
return res
}
func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
d.Set("account_id", acc.AccountID)
d.Set("consumed", flattenAccResource(acc.Consumed))
d.Set("reserved", flattenAccResource(acc.Reserved))
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
}
func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cu_c": rl.CUC,
"cu_d": rl.CUD,
"cu_dm": rl.CUDM,
"cu_i": rl.CUI,
"cu_m": rl.CUM,
"cu_np": rl.CUNP,
"gpu_units": rl.GPUUnits,
}
res = append(res, temp)
return res
}
// func flattenAccResources(r account.Resources) []map[string]interface{} {
// res := make([]map[string]interface{}, 0)
// temp := map[string]interface{}{
// "current": flattenAccResource(r.Current),
// "reserved": flattenAccResource(r.Reserved),
// }
// res = append(res, temp)
// return res
// }
func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for sepKey, sepVal := range seps {
for dataKey, dataVal := range sepVal {
temp := map[string]interface{}{
"sep_id": sepKey,
"data_name": dataKey,
"disk_size": dataVal.DiskSize,
"disk_size_max": dataVal.DiskSizeMax,
}
res = append(res, temp)
}
}
return res
}
func flattenAccResource(r account.Resource) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cpu": r.CPU,
"disk_size": r.DiskSize,
"disk_size_max": r.DiskSizeMax,
"ext_ips": r.ExtIPs,
"ext_traffic": r.ExtTraffic,
"gpu": r.GPU,
"ram": r.RAM,
"seps": flattenAccountSeps(r.SEPs),
}
res = append(res, temp)
return res
}
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lrc.Data))
for _, rc := range lrc.Data {
temp := map[string]interface{}{
"consumed": flattenAccResource(rc.Consumed),
"reserved": flattenAccResource(rc.Reserved),
"account_id": rc.AccountID,
}
res = append(res, temp)
}
return res
}

View File

@@ -1,267 +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>
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://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
type AccountAclRecord struct {
IsExplicit bool `json:"explicit"`
Guid string `json:"guid"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
CanBeDeleted bool `json:"canBeDeleted"`
}
type ResourceLimits struct {
CUC float64 `json:"CU_C"`
CUD float64 `json:"CU_D"`
CUI float64 `json:"CU_I"`
CUM float64 `json:"CU_M"`
CUNP float64 `json:"CU_NP"`
GpuUnits float64 `json:"gpu_units"`
}
type Account struct {
DCLocation string `json:"DCLocation"`
CKey string `jspn:"_ckey"`
Meta []interface{} `json:"_meta"`
Acl []AccountAclRecord `json:"acl"`
Company string `json:"company"`
CompanyUrl string `json:"companyurl"`
CreatedBy string `jspn:"createdBy"`
CreatedTime int `json:"createdTime"`
DeactiovationTime float64 `json:"deactivationTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
DisplayName string `json:"displayname"`
GUID int `json:"guid"`
ID int `json:"id"`
Name string `json:"name"`
ResourceLimits ResourceLimits `json:"resourceLimits"`
SendAccessEmails bool `json:"sendAccessEmails"`
ServiceAccount bool `json:"serviceAccount"`
Status string `json:"status"`
UpdatedTime int `json:"updatedTime"`
Version int `json:"version"`
Vins []int `json:"vins"`
}
type AccountList []Account
type AccountCloudApi struct {
Acl []AccountAclRecord `json:"acl"`
CreatedTime int `json:"createdTime"`
DeletedTime int `json:"deletedTime"`
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
UpdatedTime int `json:"updatedTime"`
}
type AccountCloudApiList []AccountCloudApi
type ResourceSep struct {
DiskSize float64 `json:"disksize"`
DiskSizeMax int `json:"disksizemax"`
}
type Resource struct {
CPU int `json:"cpu"`
Disksize int `json:"disksize"`
Extips int `json:"extips"`
Exttraffic int `json:"exttraffic"`
GPU int `json:"gpu"`
RAM int `json:"ram"`
SEPs map[string]map[string]ResourceSep `json:"seps"`
}
type Resources struct {
Current Resource `json:"Current"`
Reserved Resource `json:"Reserved"`
}
type Computes struct {
Started int `json:"started"`
Stopped int `json:"stopped"`
}
type Machines struct {
Running int `json:"running"`
Halted int `json:"halted"`
}
type AccountWithResources struct {
Account
Resources Resources `json:"Resources"`
Computes Computes `json:"computes"`
Machines Machines `json:"machines"`
Vinses int `json:"vinses"`
}
type AccountCompute struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
CPUs int `json:"cpus"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
ComputeId int `json:"id"`
ComputeName string `json:"name"`
RAM int `json:"ram"`
Registered bool `json:"registered"`
RgId int `json:"rgId"`
RgName string `json:"rgName"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
TotalDisksSize int `json:"totalDisksSize"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
UserManaged bool `json:"userManaged"`
VinsConnected int `json:"vinsConnected"`
}
type AccountComputesList []AccountCompute
type AccountDisk struct {
ID int `json:"id"`
Name string `json:"name"`
Pool string `json:"pool"`
SepId int `json:"sepId"`
Shareable bool `json:"shareable"`
SizeMax int `json:"sizeMax"`
Type string `json:"type"`
}
type AccountDisksList []AccountDisk
type AccountVin struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Computes int `json:"computes"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
ExternalIP string `json:"externalIP"`
ID int `json:"id"`
Name string `json:"name"`
Network string `json:"network"`
PriVnfDevId int `json:"priVnfDevId"`
RgId int `json:"rgId"`
RgName string `json:"rgName"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
}
type AccountVinsList []AccountVin
type AccountAudit struct {
Call string `json:"call"`
ResponseTime float64 `json:"responsetime"`
StatusCode int `json:"statuscode"`
Timestamp float64 `json:"timestamp"`
User string `json:"user"`
}
type AccountAuditsList []AccountAudit
type AccountRGComputes struct {
Started int `json:"Started"`
Stopped int `json:"Stopped"`
}
type AccountRGResources struct {
Consumed Resource `json:"Consumed"`
Limits Resource `json:"Limits"`
Reserved Resource `json:"Reserved"`
}
type AccountRG struct {
Computes AccountRGComputes `json:"Computes"`
Resources AccountRGResources `json:"Resources"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
RGID int `json:"id"`
Milestones int `json:"milestones"`
RGName string `json:"name"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
Vinses int `json:"vinses"`
}
type AccountRGList []AccountRG
type AccountTemplate struct {
UNCPath string `json:"UNCPath"`
AccountId int `json:"accountId"`
Desc string `json:"desc"`
ID int `json:"id"`
Name string `json:"name"`
Public bool `json:"public"`
Size int `json:"size"`
Status string `json:"status"`
Type string `json:"type"`
Username string `json:"username"`
}
type AccountTemplatesList []AccountTemplate
type AccountFlipGroup struct {
AccountId int `json:"accountId"`
ClientType string `json:"clientType"`
ConnType string `json:"connType"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DefaultGW string `json:"defaultGW"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Desc string `json:"desc"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
IP string `json:"ip"`
Milestones int `json:"milestones"`
Name string `json:"name"`
NetID int `json:"netId"`
NetType string `json:"netType"`
NetMask int `json:"netmask"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
}
type AccountFlipGroupsList []AccountFlipGroup

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,46 +22,44 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*AccountWithResources, error) { func utilityAccountCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordAccount, error) {
account := &AccountWithResources{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
if (strconv.Itoa(d.Get("account_id").(int))) != "0" { if (strconv.Itoa(d.Get("account_id").(int))) != "0" {
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
} else { } else {
urlValues.Add("accountId", d.Id()) idParsed, _ := strconv.Atoi(d.Id())
id = uint64(idParsed)
}
req := account.GetRequest{
AccountID: id,
} }
log.Debugf("utilityAccountCheckPresence: load account") log.Debugf("utilityAccountCheckPresence: load account")
accountRaw, err := c.DecortAPICall(ctx, "POST", accountGetAPI, urlValues) account, err := c.CloudAPI().Account().Get(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(accountRaw), &account)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,38 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountAuditsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountAuditsList, error) { func utilityAccountAuditsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListAudits, error) {
accountAuditsList := AccountAuditsList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountAuditsListCheckPresence: load account list") req := account.AuditsRequest{
accountAuditsListRaw, err := c.DecortAPICall(ctx, "POST", accountAuditsAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountAuditsListRaw), &accountAuditsList) log.Debugf("utilityAccountAuditsListCheckPresence: load account list")
accountAuditsList, err := c.CloudAPI().Account().Audits(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,78 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountComputesList, error) { func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
accountComputesList := AccountComputesList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountComputesListCheckPresence: load account list") req := account.ListComputesRequest{
accountComputesListRaw, err := c.DecortAPICall(ctx, "POST", accountListComputesAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountComputesListRaw), &accountComputesList) if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if rg_name, ok := d.GetOk("rg_name"); ok {
req.RGName = rg_name.(string)
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if ip_address, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ip_address.(string)
}
if extnet_name, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extnet_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,38 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountConsumedUnitsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ResourceLimits, error) { func utilityAccountConsumedUnitsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ResourceLimits, error) {
accountConsumedUnits := &ResourceLimits{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountConsumedUnitsCheckPresence: load account list") req := account.GetConsumedAccountUnitsRequest{
accountConsumedUnitsRaw, err := c.DecortAPICall(ctx, "POST", accountGetConsumedUnitsAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountConsumedUnitsRaw), accountConsumedUnits) log.Debugf("utilityAccountConsumedUnitsCheckPresence: load account list")
accountConsumedUnits, err := c.CloudAPI().Account().GetConsumedAccountUnits(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,41 +22,42 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"net/url"
"strconv"
"strings" "strings"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountConsumedUnitsByTypeCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (float64, error) { func utilityAccountConsumedUnitsByTypeCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (float64, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
var cuType string
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
urlValues.Add("cutype", strings.ToUpper(d.Get("cu_type").(string))) cuType = strings.ToUpper(d.Get("cu_type").(string))
req := account.GetConsumedCloudUnitsByTypeRequest{
AccountID: id,
CUType: cuType,
}
log.Debugf("utilityAccountConsumedUnitsByTypeCheckPresence") log.Debugf("utilityAccountConsumedUnitsByTypeCheckPresence")
resultRaw, err := c.DecortAPICall(ctx, "POST", accountGetConsumedUnitsByTypeAPI, urlValues) result, err := c.CloudAPI().Account().GetConsumedCloudUnitsByType(ctx, req)
if err != nil {
return 0, err
}
result, err := strconv.ParseFloat(resultRaw, 64)
if err != nil { if err != nil {
return 0, err return 0, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,50 +22,55 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) { func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
accountDeletedList := AccountCloudApiList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
req := account.ListDeletedRequest{}
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int))) req.Page = uint64(page.(int))
} }
if size, ok := d.GetOk("size"); ok { if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int))) req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
} }
log.Debugf("utilityAccountDeletedListCheckPresence: load") log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedListRaw, err := c.DecortAPICall(ctx, "POST", accountListDeletedAPI, urlValues) accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = json.Unmarshal([]byte(accountDeletedListRaw), &accountDeletedList)
if err != nil {
return nil, err
}
return accountDeletedList, nil return accountDeletedList, nil
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,60 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"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{}) (AccountDisksList, error) { func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
accountDisksList := AccountDisksList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountDisksListCheckPresence: load account list") req := account.ListDisksRequest{
accountDisksListRaw, err := c.DecortAPICall(ctx, "POST", accountListDisksAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountDisksListRaw), &accountDisksList) if disk_id, ok := d.GetOk("disk_id"); ok {
req.DiskID = uint64(disk_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = uint64(disk_max_size.(int))
}
if typeVal, ok := d.GetOk("type"); ok {
req.Type = typeVal.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,70 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountFlipGroupsList, error) { func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListFLIPGroups, error) {
accountFlipGroupsList := AccountFlipGroupsList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountFlipGroupsListCheckPresence") req := account.ListFLIPGroupsRequest{
accountFlipGroupsListRaw, err := c.DecortAPICall(ctx, "POST", accountListFlipGroupsAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountFlipGroupsListRaw), &accountFlipGroupsList) if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vins_name, ok := d.GetOk("vins_name"); ok {
req.VINSName = vins_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if by_ip, ok := d.GetOk("by_ip"); ok {
req.ByIP = by_ip.(string)
}
if flipgroup_id, ok := d.GetOk("flipgroup_id"); ok {
req.FLIPGroupID = uint64(flipgroup_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountFlipGroupsListCheckPresence")
accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,54 +1,61 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@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.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/* /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package k8s package account
const ( import (
K8sCreateAPI = "/restmachine/cloudapi/k8s/create" "context"
K8sGetAPI = "/restmachine/cloudapi/k8s/get"
K8sUpdateAPI = "/restmachine/cloudapi/k8s/update" log "github.com/sirupsen/logrus"
K8sDeleteAPI = "/restmachine/cloudapi/k8s/delete" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
K8sListAPI = "/restmachine/cloudapi/k8s/list" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
K8sListDeletedAPI = "/restmachine/cloudapi/k8s/listDeleted"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd" )
K8sWgDeleteAPI = "/restmachine/cloudapi/k8s/workersGroupDelete"
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
K8sWorkerAddAPI = "/restmachine/cloudapi/k8s/workerAdd" c := m.(*controller.ControllerCfg)
K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
id := uint64(d.Get("account_id").(int))
K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
req:= account.GetResourceConsumptionRequest {
LbGetAPI = "/restmachine/cloudapi/lb/get" AccountID: id,
}
AsyncTaskGetAPI = "/restmachine/cloudapi/tasks/get"
) log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
accountResourceConsumptionRec, err := c.CloudAPI().Account().GetResourceConsumption(ctx, req)
if err != nil {
return nil, err
}
return accountResourceConsumptionRec, nil
}

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,78 +22,58 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) { func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
accountList := AccountCloudApiList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := account.ListRequest{}
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int))) req.Page = uint64(page.(int))
} }
if size, ok := d.GetOk("size"); ok { if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(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 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")
accountListRaw, err := c.DecortAPICall(ctx, "POST", accountListAPI, urlValues) accountList, err := c.CloudAPI().Account().List(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(accountListRaw), &accountList)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return accountList, nil return accountList, nil
} }
/*uncomment for cloudbroker
func utilityAccountListCheckPresence(d *schema.ResourceData, m interface{}) (AccountList, error) {
accountList := AccountList{}
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int)))
}
if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int)))
}
log.Debugf("utilityAccountListCheckPresence: load account list")
accountListRaw, err := controller.decortAPICall("POST", accountListAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(accountListRaw), &accountList)
if err != nil {
return nil, err
}
return accountList, nil
}
*/

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,38 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountReservedUnitsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ResourceLimits, error) { func utilityAccountReservedUnitsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ResourceLimits, error) {
accountReservedUnits := &ResourceLimits{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountReservedUnitsCheckPresence: load units") req := account.GetReservedAccountUnitsRequest{
accountReservedUnitsRaw, err := c.DecortAPICall(ctx, "POST", accountGetReservedUnitsAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountReservedUnitsRaw), accountReservedUnits) log.Debugf("utilityAccountReservedUnitsCheckPresence: load units")
accountReservedUnits, err := c.CloudAPI().Account().GetReservedAccountUnits(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -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
}

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,66 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountRGList, error) { func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
accountRGList := AccountRGList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountRGListCheckPresence: load account list") req := account.ListRGRequest{
accountRGListRaw, err := c.DecortAPICall(ctx, "POST", accountListRGAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountRGListRaw), &accountRGList) if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vm_id, ok := d.GetOk("vm_id"); ok {
req.VMID = uint64(vm_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
log.Debugf("utilityAccountRGListCheckPresence: load account list")
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,56 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountTemplatesList, error) { func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
accountTemplatesList := AccountTemplatesList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id := uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountTemplatesListCheckPresence: load") req := account.ListTemplatesRequest{
accountTemplatesListRaw, err := c.DecortAPICall(ctx, "POST", accountListTemplatesAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountTemplatesListRaw), &accountTemplatesList) if include_deleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = include_deleted.(bool)
}
if imageId, ok := d.GetOk("image_id"); ok {
req.ImageID = uint64(imageId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if typeTemplates, ok := d.GetOk("type"); ok {
req.Type = typeTemplates.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,42 +22,62 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package account package account
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (AccountVinsList, error) { func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
accountVinsList := AccountVinsList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) id = uint64(d.Get("account_id").(int))
log.Debugf("utilityAccountVinsListCheckPresence: load account list") req := account.ListVINSRequest{
accountVinsListRaw, err := c.DecortAPICall(ctx, "POST", accountListVinsAPI, urlValues) AccountID: id,
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(accountVinsListRaw), &accountVinsList) if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,59 +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>
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://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package bservice
const bserviceCreateAPI = "/restmachine/cloudapi/bservice/create"
const bserviceDeleteAPI = "/restmachine/cloudapi/bservice/delete"
const bserviceDisableAPI = "/restmachine/cloudapi/bservice/disable"
const bserviceEnableAPI = "/restmachine/cloudapi/bservice/enable"
const bserviceGetAPI = "/restmachine/cloudapi/bservice/get"
const bserviceGroupAddAPI = "/restmachine/cloudapi/bservice/groupAdd"
const bserviceGroupComputeRemoveAPI = "/restmachine/cloudapi/bservice/groupComputeRemove"
const bserviceGroupGetAPI = "/restmachine/cloudapi/bservice/groupGet"
const bserviceGroupParentAddAPI = "/restmachine/cloudapi/bservice/groupParentAdd"
const bserviceGroupParentRemoveAPI = "/restmachine/cloudapi/bservice/groupParentRemove"
const bserviceGroupRemoveAPI = "/restmachine/cloudapi/bservice/groupRemove"
const bserviceGroupResizeAPI = "/restmachine/cloudapi/bservice/groupResize"
const bserviceGroupStartAPI = "/restmachine/cloudapi/bservice/groupStart"
const bserviceGroupStopAPI = "/restmachine/cloudapi/bservice/groupStop"
const bserviceGroupUpdateAPI = "/restmachine/cloudapi/bservice/groupUpdate"
const bserviceGroupUpdateExtnetAPI = "/restmachine/cloudapi/bservice/groupUpdateExtnet"
const bserviceGroupUpdateVinsAPI = "/restmachine/cloudapi/bservice/groupUpdateVins"
const bserviceListAPI = "/restmachine/cloudapi/bservice/list"
const bserviceListDeletedAPI = "/restmachine/cloudapi/bservice/listDeleted"
const bserviceRestoreAPI = "/restmachine/cloudapi/bservice/restore"
const bserviceSnapshotCreateAPI = "/restmachine/cloudapi/bservice/snapshotCreate"
const bserviceSnapshotDeleteAPI = "/restmachine/cloudapi/bservice/snapshotDelete"
const bserviceSnapshotListAPI = "/restmachine/cloudapi/bservice/snapshotList"
const bserviceSnapshotRollbackAPI = "/restmachine/cloudapi/bservice/snapshotRollback"
const bserviceStartAPI = "/restmachine/cloudapi/bservice/start"
const bserviceStopAPI = "/restmachine/cloudapi/bservice/stop"

View File

@@ -1,304 +1,298 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
package bservice
import (
"context" import (
"context"
"github.com/google/uuid" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
bs, err := utilityBasicServiceCheckPresence(ctx, d, m) func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("account_id", bs.AccountId) d.SetId(strconv.FormatUint(bs.ID, 10))
d.Set("account_name", bs.AccountName)
d.Set("base_domain", bs.BaseDomain) flattenService(d, bs)
d.Set("computes", flattenBasicServiceComputes(bs.Computes))
d.Set("cpu_total", bs.CPUTotal) return nil
d.Set("created_by", bs.CreatedBy) }
d.Set("created_time", bs.CreatedTime)
d.Set("deleted_by", bs.DeletedBy) func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
d.Set("deleted_time", bs.DeletedTime) res := map[string]*schema.Schema{
d.Set("disk_total", bs.DiskTotal) "service_id": {
d.Set("gid", bs.GID) Type: schema.TypeInt,
d.Set("groups", bs.Groups) Required: true,
d.Set("groups_name", bs.GroupsName) },
d.Set("guid", bs.GUID) "account_id": {
d.Set("milestones", bs.Milestones) Type: schema.TypeInt,
d.Set("service_name", bs.Name) Computed: true,
d.Set("parent_srv_id", bs.ParentSrvId) },
d.Set("parent_srv_type", bs.ParentSrvType) "account_name": {
d.Set("ram_total", bs.RamTotal) Type: schema.TypeString,
d.Set("rg_id", bs.RGID) Computed: true,
d.Set("rg_name", bs.RGName) },
d.Set("snapshots", flattenBasicServiceSnapshots(bs.Snapshots)) "base_domain": {
d.Set("ssh_key", bs.SSHKey) Type: schema.TypeString,
d.Set("ssh_user", bs.SSHUser) Computed: true,
d.Set("status", bs.Status) },
d.Set("tech_status", bs.TechStatus) "computes": {
d.Set("updated_by", bs.UpdatedBy) Type: schema.TypeList,
d.Set("updated_time", bs.UpdatedTime) Computed: true,
d.Set("user_managed", bs.UserManaged) Elem: &schema.Resource{
return nil Schema: map[string]*schema.Schema{
} "account_id": {
Type: schema.TypeInt,
func flattenBasicServiceComputes(bscs BasicServiceComputes) []map[string]interface{} { Computed: true,
res := make([]map[string]interface{}, 0) },
for _, bsc := range bscs { "architecture": {
temp := map[string]interface{}{ Type: schema.TypeString,
"compgroup_id": bsc.CompGroupId, Computed: true,
"compgroup_name": bsc.CompGroupName, },
"compgroup_role": bsc.CompGroupRole, "compgroup_id": {
"id": bsc.ID, Type: schema.TypeInt,
"name": bsc.Name, Computed: true,
} },
res = append(res, temp) "compgroup_name": {
} Type: schema.TypeString,
Computed: true,
return res },
} "compgroup_role": {
Type: schema.TypeString,
func flattenBasicServiceSnapshots(bsrvss BasicServiceSnapshots) []map[string]interface{} { Computed: true,
res := make([]map[string]interface{}, 0) },
for _, bsrvs := range bsrvss { "id": {
temp := map[string]interface{}{ Type: schema.TypeInt,
"guid": bsrvs.GUID, Computed: true,
"label": bsrvs.Label, },
"timestamp": bsrvs.Timestamp, "rg_id": {
"valid": bsrvs.Valid, Type: schema.TypeInt,
} Computed: true,
res = append(res, temp) },
} "stack_id": {
return res Type: schema.TypeInt,
} Computed: true,
},
func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema { "name": {
res := map[string]*schema.Schema{ Type: schema.TypeString,
"service_id": { Computed: true,
Type: schema.TypeInt, },
Required: true, "status": {
}, Type: schema.TypeString,
"account_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "tech_status": {
}, Type: schema.TypeString,
"account_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, },
}, },
"base_domain": { },
Type: schema.TypeString,
Computed: true, "cpu_total": {
}, Type: schema.TypeInt,
"computes": { Computed: true,
Type: schema.TypeList, },
Computed: true, "created_by": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Computed: true,
"compgroup_id": { },
Type: schema.TypeInt, "created_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"compgroup_name": { },
Type: schema.TypeString, "deleted_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"compgroup_role": { },
Type: schema.TypeString, "deleted_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"id": { },
Type: schema.TypeInt, "disk_total": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"name": { },
Type: schema.TypeString, "gid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "groups": {
}, Type: schema.TypeList,
Computed: true,
"cpu_total": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "computes": {
}, Type: schema.TypeInt,
"created_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "consistency": {
}, Type: schema.TypeBool,
"created_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "id": {
}, Type: schema.TypeInt,
"deleted_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "name": {
}, Type: schema.TypeString,
"deleted_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "status": {
}, Type: schema.TypeString,
"disk_total": { Computed: true,
Type: schema.TypeString, },
Computed: true, "tech_status": {
}, Type: schema.TypeString,
"gid": { Computed: true,
Type: schema.TypeInt, },
Computed: true, },
}, },
"groups": { },
Type: schema.TypeList, // "groups_name": {
Computed: true, // Type: schema.TypeList,
Elem: &schema.Schema{ // Computed: true,
Type: schema.TypeInt, // Elem: &schema.Schema{
}, // Type: schema.TypeString,
}, // },
"groups_name": { // },
Type: schema.TypeList, "guid": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeString, },
}, "milestones": {
}, Type: schema.TypeInt,
"guid": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "service_name": {
}, Type: schema.TypeString,
"milestones": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "parent_srv_id": {
}, Type: schema.TypeInt,
"service_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "parent_srv_type": {
}, Type: schema.TypeString,
"parent_srv_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "ram_total": {
}, Type: schema.TypeInt,
"parent_srv_type": { Computed: true,
Type: schema.TypeString, },
Computed: true, "rg_id": {
}, Type: schema.TypeInt,
"ram_total": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "rg_name": {
}, Type: schema.TypeString,
"rg_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "snapshots": {
}, Type: schema.TypeList,
"rg_name": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "guid": {
"snapshots": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Resource{ "label": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"guid": { Computed: true,
Type: schema.TypeString, },
Computed: true, "timestamp": {
}, Type: schema.TypeInt,
"label": { Computed: true,
Type: schema.TypeString, },
Computed: true, "valid": {
}, Type: schema.TypeBool,
"timestamp": { Computed: true,
Type: schema.TypeInt, },
Computed: true, },
}, },
"valid": { },
Type: schema.TypeBool,
Computed: true, "ssh_key": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, "ssh_user": {
Type: schema.TypeString,
"ssh_key": { Computed: true,
Type: schema.TypeString, },
Computed: true, "status": {
}, Type: schema.TypeString,
"ssh_user": { Computed: true,
Type: schema.TypeString, },
Computed: true, "tech_status": {
}, Type: schema.TypeString,
"status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "updated_by": {
}, Type: schema.TypeString,
"tech_status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "updated_time": {
}, Type: schema.TypeInt,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "user_managed": {
}, Type: schema.TypeBool,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, }
}, return res
"user_managed": { }
Type: schema.TypeBool,
Computed: true, func DataSourceBasicService() *schema.Resource {
}, return &schema.Resource{
} SchemaVersion: 1,
return res
} ReadContext: dataSourceBasicServiceRead,
func DataSourceBasicService() *schema.Resource { Timeouts: &schema.ResourceTimeout{
return &schema.Resource{ Read: &constants.Timeout30s,
SchemaVersion: 1, Default: &constants.Timeout60s,
},
ReadContext: dataSourceBasicServiceRead,
Schema: dataSourceBasicServiceSchemaMake(),
Timeouts: &schema.ResourceTimeout{ }
Read: &constants.Timeout30s, }
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSchemaMake(),
}
}

View File

@@ -1,69 +1,85 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
package bservice
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m) func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("items", flattenBasicServiceList(basicServiceDeletedList)) id := uuid.New()
d.SetId(id.String())
return nil d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
} d.Set("entry_count", basicServiceDeletedList.EntryCount)
func DataSourceBasicServiceDeletedList() *schema.Resource { return nil
return &schema.Resource{ }
SchemaVersion: 1,
func dataSourceBasicServiceDeletedListSchemaMake() map[string]*schema.Schema {
ReadContext: dataSourceBasicServiceDeletedListRead, temp := dataSourceBasicServiceListSchemaMake()
Timeouts: &schema.ResourceTimeout{ delete(temp, "by_id")
Read: &constants.Timeout30s, delete(temp, "name")
Default: &constants.Timeout60s, delete(temp, "rg_name")
}, delete(temp, "status")
delete(temp, "tech_status")
Schema: dataSourceBasicServiceListSchemaMake(), delete(temp, "account_name")
}
} return temp
}
func DataSourceBasicServiceDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
}
}

View File

@@ -1,302 +1,305 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
package bservice
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { )
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
if err != nil { func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("account_id", bsg.AccountId)
d.Set("account_name", bsg.AccountName) id := uuid.New()
d.Set("computes", flattenBSGroupComputes(bsg.Computes)) d.SetId(id.String())
d.Set("consistency", bsg.Consistency) d.Set("account_id", bsg.AccountID)
d.Set("cpu", bsg.CPU) d.Set("account_name", bsg.AccountName)
d.Set("created_by", bsg.CreatedBy) d.Set("computes", flattenBSGroupComputes(bsg.Computes))
d.Set("created_time", bsg.CreatedTime) d.Set("consistency", bsg.Consistency)
d.Set("deleted_by", bsg.DeletedBy) d.Set("cpu", bsg.CPU)
d.Set("deleted_time", bsg.DeletedTime) d.Set("created_by", bsg.CreatedBy)
d.Set("disk", bsg.Disk) d.Set("created_time", bsg.CreatedTime)
d.Set("driver", bsg.Driver) d.Set("deleted_by", bsg.DeletedBy)
d.Set("extnets", bsg.Extnets) d.Set("deleted_time", bsg.DeletedTime)
d.Set("gid", bsg.GID) d.Set("disk", bsg.Disk)
d.Set("guid", bsg.GUID) d.Set("driver", bsg.Driver)
d.Set("image_id", bsg.ImageId) d.Set("extnets", bsg.ExtNets)
d.Set("milestones", bsg.Milestones) d.Set("gid", bsg.GID)
d.Set("compgroup_name", bsg.Name) d.Set("guid", bsg.GUID)
d.Set("parents", bsg.Parents) d.Set("image_id", bsg.ImageID)
d.Set("ram", bsg.RAM) d.Set("milestones", bsg.Milestones)
d.Set("rg_id", bsg.RGID) d.Set("compgroup_name", bsg.Name)
d.Set("rg_name", bsg.RGName) d.Set("parents", bsg.Parents)
d.Set("role", bsg.Role) d.Set("ram", bsg.RAM)
d.Set("sep_id", bsg.SepId) d.Set("rg_id", bsg.RGID)
d.Set("seq_no", bsg.SeqNo) d.Set("rg_name", bsg.RGName)
d.Set("status", bsg.Status) d.Set("role", bsg.Role)
d.Set("tech_status", bsg.TechStatus) d.Set("sep_id", bsg.SEPID)
d.Set("timeout_start", bsg.TimeoutStart) d.Set("seq_no", bsg.SeqNo)
d.Set("updated_by", bsg.UpdatedBy) d.Set("status", bsg.Status)
d.Set("updated_time", bsg.UpdatedTime) d.Set("tech_status", bsg.TechStatus)
d.Set("vinses", bsg.Vinses) d.Set("timeout_start", bsg.TimeoutStart)
return nil d.Set("updated_by", bsg.UpdatedBy)
} d.Set("updated_time", bsg.UpdatedTime)
d.Set("vinses", bsg.VINSes)
func flattenBSGroupOSUsers(bsgosus BasicServiceGroupOSUsers) []map[string]interface{} { return nil
res := make([]map[string]interface{}, 0) }
for _, bsgosu := range bsgosus {
temp := map[string]interface{}{ func flattenBSGroupOSUsers(bsgosus bservice.ListOSUsers) []map[string]interface{} {
"login": bsgosu.Login, res := make([]map[string]interface{}, 0)
"password": bsgosu.Password, for _, bsgosu := range bsgosus {
} temp := map[string]interface{}{
res = append(res, temp) "login": bsgosu.Login,
} "password": bsgosu.Password,
}
return res res = append(res, temp)
} }
func flattenBSGroupComputes(bsgcs BasicServiceGroupComputes) []map[string]interface{} { return res
res := make([]map[string]interface{}, 0) }
for _, bsgc := range bsgcs {
temp := map[string]interface{}{ func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]interface{} {
"id": bsgc.ID, res := make([]map[string]interface{}, 0)
"ip_addresses": bsgc.IPAdresses, for _, bsgc := range bsgcs {
"name": bsgc.Name, temp := map[string]interface{}{
"os_users": flattenBSGroupOSUsers(bsgc.OSUsers), "id": bsgc.ID,
} "ip_addresses": bsgc.IPAddresses,
res = append(res, temp) "name": bsgc.Name,
} "os_users": flattenBSGroupOSUsers(bsgc.OSUsers),
return res }
} res = append(res, temp)
}
func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema { return res
res := map[string]*schema.Schema{ }
"service_id": {
Type: schema.TypeInt, func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Required: true, res := map[string]*schema.Schema{
}, "service_id": {
"compgroup_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Required: true,
Required: true, },
}, "compgroup_id": {
"account_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Required: true,
Computed: true, },
}, "account_id": {
"account_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "account_name": {
"computes": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Resource{ "computes": {
Schema: map[string]*schema.Schema{ Type: schema.TypeList,
"id": { Computed: true,
Type: schema.TypeInt, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "id": {
"ip_addresses": { Type: schema.TypeInt,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Schema{ "ip_addresses": {
Type: schema.TypeString, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
"name": { Type: schema.TypeString,
Type: schema.TypeString, },
Computed: true, },
}, "name": {
"os_users": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Resource{ "os_users": {
Schema: map[string]*schema.Schema{ Type: schema.TypeList,
"login": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "login": {
"password": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "password": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
}, },
"consistency": { },
Type: schema.TypeBool, },
Computed: true, },
}, "consistency": {
"cpu": { Type: schema.TypeBool,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "cpu": {
"created_by": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "created_by": {
"created_time": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "created_time": {
"deleted_by": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "deleted_by": {
"deleted_time": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "deleted_time": {
"disk": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "disk": {
"driver": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "driver": {
"extnets": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Schema{ "extnets": {
Type: schema.TypeInt, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
"gid": { Type: schema.TypeInt,
Type: schema.TypeInt, },
Computed: true, },
}, "gid": {
"guid": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "guid": {
"image_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "image_id": {
"milestones": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "milestones": {
"compgroup_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "compgroup_name": {
"parents": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Schema{ "parents": {
Type: schema.TypeInt, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
"ram": { Type: schema.TypeInt,
Type: schema.TypeInt, },
Computed: true, },
}, "ram": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "rg_id": {
"rg_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "rg_name": {
"role": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "role": {
"sep_id": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "sep_id": {
"seq_no": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "seq_no": {
"status": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "status": {
"tech_status": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "tech_status": {
"timeout_start": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "timeout_start": {
"updated_by": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "updated_by": {
"updated_time": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "updated_time": {
"vinses": { Type: schema.TypeInt,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Schema{ "vinses": {
Type: schema.TypeInt, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
} Type: schema.TypeInt,
return res },
} },
}
func DataSourceBasicServiceGroup() *schema.Resource { return res
return &schema.Resource{ }
SchemaVersion: 1,
func DataSourceBasicServiceGroup() *schema.Resource {
ReadContext: dataSourceBasicServiceGroupRead, return &schema.Resource{
SchemaVersion: 1,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, ReadContext: dataSourceBasicServiceGroupRead,
Default: &constants.Timeout60s,
}, Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Schema: dataSourceBasicServiceGroupSchemaMake(), Default: &constants.Timeout60s,
} },
}
Schema: dataSourceBasicServiceGroupSchemaMake(),
}
}

View File

@@ -1,226 +1,264 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
package bservice
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
func flattenBasicServiceList(bsl BasicServiceList) []map[string]interface{} { )
res := make([]map[string]interface{}, 0)
for _, bs := range bsl { func flattenBasicServiceList(bsl *bservice.ListBasicServices) []map[string]interface{} {
temp := map[string]interface{}{ res := make([]map[string]interface{}, 0)
"account_id": bs.AccountId, for _, bs := range bsl.Data {
"account_name": bs.AccountName, temp := map[string]interface{}{
"base_domain": bs.BaseDomain, "account_id": bs.AccountID,
"created_by": bs.CreatedBy, "account_name": bs.AccountName,
"created_time": bs.CreatedTime, "base_domain": bs.BaseDomain,
"deleted_by": bs.DeletedBy, "created_by": bs.CreatedBy,
"deleted_time": bs.DeletedTime, "created_time": bs.CreatedTime,
"gid": bs.GID, "deleted_by": bs.DeletedBy,
"groups": bs.Groups, "deleted_time": bs.DeletedTime,
"guid": bs.GUID, "gid": bs.GID,
"service_id": bs.ID, "groups": bs.Groups,
"service_name": bs.Name, "guid": bs.GUID,
"parent_srv_id": bs.ParentSrvId, "service_id": bs.ID,
"parent_srv_type": bs.ParentSrvType, "service_name": bs.Name,
"rg_id": bs.RGID, "parent_srv_id": bs.ParentSrvID,
"rg_name": bs.RGName, "parent_srv_type": bs.ParentSrvType,
"ssh_user": bs.SSHUser, "rg_id": bs.RGID,
"status": bs.Status, "rg_name": bs.RGName,
"tech_status": bs.TechStatus, "ssh_user": bs.SSHUser,
"updated_by": bs.UpdatedBy, "status": bs.Status,
"updated_time": bs.UpdatedTime, "tech_status": bs.TechStatus,
"user_managed": bs.UserManaged, "updated_by": bs.UpdatedBy,
} "updated_time": bs.UpdatedTime,
res = append(res, temp) "user_managed": bs.UserManaged,
} }
return res res = append(res, temp)
} }
return res
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
if err != nil { func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenBasicServiceList(basicServiceList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenBasicServiceList(basicServiceList))
d.Set("entry_count", basicServiceList.EntryCount)
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Optional: true, func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account to query for BasicService instances", res := map[string]*schema.Schema{
}, "by_id": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Optional: true, Description: "Filter by ID",
Description: "ID of the resource group to query for BasicService instances", },
}, "name": {
"page": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Optional: true, Description: "Filter by bservice name",
Description: "Page number", },
}, "rg_name": {
"size": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Optional: true, Description: "Filter by resource group name",
Description: "Page size", },
}, "status": {
"items": { Type: schema.TypeString,
Type: schema.TypeList, Optional: true,
Computed: true, Description: "Filter by status",
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "tech_status": {
"account_id": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Filter by tech status",
}, },
"account_name": { "account_name": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by account name",
"base_domain": { },
Type: schema.TypeString, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"created_by": { Description: "ID of the account to query for BasicService instances",
Type: schema.TypeString, },
Computed: true, "rg_id": {
}, Type: schema.TypeInt,
"created_time": { Optional: true,
Type: schema.TypeInt, Description: "ID of the resource group to query for BasicService instances",
Computed: true, },
}, "page": {
"deleted_by": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Page number",
}, },
"deleted_time": { "size": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page size",
"gid": { },
Type: schema.TypeInt, "items": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"groups": { Elem: &schema.Resource{
Type: schema.TypeList, Schema: map[string]*schema.Schema{
Computed: true, "account_id": {
Elem: &schema.Schema{ Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
}, },
}, "account_name": {
"guid": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "base_domain": {
"service_id": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "created_by": {
"service_name": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "created_time": {
"parent_srv_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "deleted_by": {
"parent_srv_type": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "deleted_time": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "gid": {
"rg_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "groups": {
"ssh_user": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"status": { },
Type: schema.TypeString, },
Computed: true, "guid": {
}, Type: schema.TypeInt,
"tech_status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "service_id": {
}, Type: schema.TypeInt,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "service_name": {
}, Type: schema.TypeString,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "parent_srv_id": {
}, Type: schema.TypeInt,
"user_managed": { Computed: true,
Type: schema.TypeBool, },
Computed: true, "parent_srv_type": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, "rg_id": {
} Type: schema.TypeInt,
return res Computed: true,
} },
"rg_name": {
func DataSourceBasicServiceList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"ssh_user": {
ReadContext: dataSourceBasicServiceListRead, Type: schema.TypeString,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "status": {
Default: &constants.Timeout60s, Type: schema.TypeString,
}, Computed: true,
},
Schema: dataSourceBasicServiceListSchemaMake(), "tech_status": {
} Type: schema.TypeString,
} Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceBasicServiceList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceListSchemaMake(),
}
}

View File

@@ -1,104 +1,110 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
package bservice
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m) func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList)) id := uuid.New()
d.SetId(id.String())
return nil d.Set("items", flattenBasicServiceSnapshotsList(basicServiceSnapshotList))
} d.Set("entry_count", basicServiceSnapshotList.EntryCount)
return nil
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"service_id": { func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Required: true, "service_id": {
Description: "ID of the BasicService instance", Type: schema.TypeInt,
}, Required: true,
"items": { Description: "ID of the BasicService instance",
Type: schema.TypeList, },
Computed: true, "items": {
Elem: &schema.Resource{ Type: schema.TypeList,
Schema: map[string]*schema.Schema{ Computed: true,
"guid": { Elem: &schema.Resource{
Type: schema.TypeString, Schema: map[string]*schema.Schema{
Computed: true, "guid": {
}, Type: schema.TypeString,
"label": { Computed: true,
Type: schema.TypeString, },
Computed: true, "label": {
}, Type: schema.TypeString,
"timestamp": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "timestamp": {
}, Type: schema.TypeInt,
"valid": { Computed: true,
Type: schema.TypeBool, },
Computed: true, "valid": {
}, Type: schema.TypeBool,
}, Computed: true,
}, },
}, },
} },
return res },
} "entry_count": {
Type: schema.TypeInt,
func DataSourceBasicServiceSnapshotList() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, }
return res
ReadContext: dataSourceBasicServiceSnapshotListRead, }
Timeouts: &schema.ResourceTimeout{ func DataSourceBasicServiceSnapshotList() *schema.Resource {
Read: &constants.Timeout30s, return &schema.Resource{
Default: &constants.Timeout60s, SchemaVersion: 1,
},
ReadContext: dataSourceBasicServiceSnapshotListRead,
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
} Timeouts: &schema.ResourceTimeout{
} Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
}
}

View File

@@ -0,0 +1,139 @@
package bservice
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
)
func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.RecordGroup) {
d.Set("account_id", bsg.AccountID)
d.Set("account_name", bsg.AccountName)
d.Set("computes", flattenBSGroupComputes(bsg.Computes))
d.Set("consistency", bsg.Consistency)
d.Set("cpu", bsg.CPU)
d.Set("created_by", bsg.CreatedBy)
d.Set("created_time", bsg.CreatedTime)
d.Set("deleted_by", bsg.DeletedBy)
d.Set("deleted_time", bsg.DeletedTime)
d.Set("disk", bsg.Disk)
d.Set("driver", bsg.Driver)
d.Set("extnets", bsg.ExtNets)
d.Set("gid", bsg.GID)
d.Set("guid", bsg.GUID)
d.Set("image_id", bsg.ImageID)
d.Set("milestones", bsg.Milestones)
d.Set("compgroup_name", bsg.Name)
d.Set("compgroup_id", bsg.ID)
d.Set("parents", bsg.Parents)
d.Set("ram", bsg.RAM)
d.Set("rg_id", bsg.RGID)
d.Set("rg_name", bsg.RGName)
d.Set("role", bsg.Role)
d.Set("sep_id", bsg.SEPID)
d.Set("sep_pool", bsg.PoolName)
d.Set("seq_no", bsg.SeqNo)
d.Set("status", bsg.Status)
d.Set("tech_status", bsg.TechStatus)
d.Set("timeout_start", bsg.TimeoutStart)
d.Set("updated_by", bsg.UpdatedBy)
d.Set("updated_time", bsg.UpdatedTime)
d.Set("vinses", bsg.VINSes)
}
func flattenGroups(groups bservice.ListGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, group := range groups {
temp := map[string]interface{}{
"computes": group.Computes,
"consistency": group.Consistency,
"id": group.ID,
"name": group.Name,
"status": group.Status,
"tech_status": group.TechStatus,
}
res = append(res, temp)
}
return res
}
func flattenService(d *schema.ResourceData, bs *bservice.RecordBasicService) {
d.Set("account_id", bs.AccountID)
d.Set("account_name", bs.AccountName)
d.Set("base_domain", bs.BaseDomain)
d.Set("computes", flattenBasicServiceComputes(bs.Computes))
d.Set("cpu_total", bs.CPUTotal)
d.Set("created_by", bs.CreatedBy)
d.Set("created_time", bs.CreatedTime)
d.Set("deleted_by", bs.DeletedBy)
d.Set("deleted_time", bs.DeletedTime)
d.Set("disk_total", bs.DiskTotal)
d.Set("gid", bs.GID)
d.Set("groups", flattenGroups(bs.Groups))
d.Set("guid", bs.GUID)
d.Set("milestones", bs.Milestones)
d.Set("service_name", bs.Name)
d.Set("service_id", bs.ID)
d.Set("parent_srv_id", bs.ParentSrvID)
d.Set("parent_srv_type", bs.ParentSrvType)
d.Set("ram_total", bs.RAMTotal)
d.Set("rg_id", bs.RGID)
d.Set("rg_name", bs.RGName)
d.Set("snapshots", flattenBasicServiceSnapshots(bs.Snapshots))
d.Set("ssh_key", bs.SSHKey)
d.Set("ssh_user", bs.SSHUser)
d.Set("status", bs.Status)
d.Set("tech_status", bs.TechStatus)
d.Set("updated_by", bs.UpdatedBy)
d.Set("updated_time", bs.UpdatedTime)
d.Set("user_managed", bs.UserManaged)
}
func flattenBasicServiceComputes(bscs bservice.ListComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, bsc := range bscs {
temp := map[string]interface{}{
"account_id": bsc.AccountID,
"architecture": bsc.Architecture,
"compgroup_id": bsc.CompGroupID,
"compgroup_name": bsc.CompGroupName,
"compgroup_role": bsc.CompGroupRole,
"id": bsc.ID,
"name": bsc.Name,
"rg_id": bsc.RGID,
"stack_id": bsc.StackID,
"status": bsc.Status,
"tech_status": bsc.TechStatus,
}
res = append(res, temp)
}
return res
}
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(bsrvss))
for _, bsrvs := range bsrvss {
temp := map[string]interface{}{
"guid": bsrvs.GUID,
"label": bsrvs.Label,
"timestamp": bsrvs.Timestamp,
"valid": bsrvs.Valid,
}
res = append(res, temp)
}
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
}

View File

@@ -1,144 +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>
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://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package bservice
///Structs
type BasicServiceCompute struct {
CompGroupId int `json:"compgroupId"`
CompGroupName string `json:"compgroupName"`
CompGroupRole string `json:"compgroupRole"`
ID int `json:"id"`
Name string `json:"name"`
}
type BasicServiceComputes []BasicServiceCompute
type BasicServiceSnapshot struct {
GUID string `json:"guid"`
Label string `json:"label"`
Timestamp int `json:"timestamp"`
Valid bool `json:"valid"`
}
type BasicServiceSnapshots []BasicServiceSnapshot
type BasicService struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
BaseDomain string `json:"baseDomain"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
GID int `json:"gid"`
Groups []int `json:"groups"`
GUID int `json:"guid"`
ID int `json:"id"`
Name string `json:"name"`
ParentSrvId int `json:"parentSrvId"`
ParentSrvType string `json:"parentSrvType"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
SSHUser string `json:"sshUser"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
UserManaged bool `json:"userManaged"`
}
type BasicServiceList []BasicService
type BasicServiceExtend struct {
BasicService
Computes BasicServiceComputes `json:"computes"`
CPUTotal int `json:"cpuTotal"`
DiskTotal int `json:"diskTotal"`
GroupsName []string `json:"groupsName"`
Milestones int `json:"milestones"`
RamTotal int `json:"ramTotal"`
Snapshots BasicServiceSnapshots `json:"snapshots"`
SSHKey string `json:"sshKey"`
}
type BasicServiceGroupOSUser struct {
Login string `json:"login"`
Password string `json:"password"`
}
type BasicServiceGroupOSUsers []BasicServiceGroupOSUser
type BasicServicceGroupCompute struct {
ID int `json:"id"`
IPAdresses []string `json:"ipAddresses"`
Name string `json:"name"`
OSUsers BasicServiceGroupOSUsers `json:"osUsers"`
}
type BasicServiceGroupComputes []BasicServicceGroupCompute
type BasicServiceGroup struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Computes BasicServiceGroupComputes `json:"computes"`
Consistency bool `json:"consistency"`
CPU int `json:"cpu"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Disk int `json:"disk"`
Driver string `json:"driver"`
Extnets []int `json:"extnets"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
ImageId int `json:"imageId"`
Milestones int `json:"milestones"`
Name string `json:"name"`
Parents []int `json:"parents"`
RAM int `json:"ram"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
Role string `json:"role"`
SepId int `json:"sepId"`
SeqNo int `json:"seqNo"`
ServiceId int `json:"serviceId"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
TimeoutStart int `json:"timeoutStart"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
Vinses []int `json:"vinses"`
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
package bservice
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListRequest{}
rgList, err := c.CloudAPI().RG().List(ctx, req)
if err != nil {
return false, err
}
rgId := uint64(d.Get("rg_id").(int))
return len(rgList.FilterByID(rgId).Data) != 0, nil
}

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,53 +22,45 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package bservice package bservice
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"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{}) (BasicServiceList, error) { func utilityBasicServiceDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
basicServiceDeletedList := BasicServiceList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := bservice.ListDeletedRequest{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
urlValues.Add("accountId", strconv.Itoa(accountId.(int))) req.AccountID = uint64(accountId.(int))
} }
if rgId, ok := d.GetOk("rg_id"); ok { if rgId, ok := d.GetOk("rg_id"); ok {
urlValues.Add("rgId", strconv.Itoa(rgId.(int))) req.RGID = uint64(rgId.(int))
} }
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int))) req.Page = uint64(page.(int))
} }
if size, ok := d.GetOk("size"); ok { if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int))) req.Size = uint64(size.(int))
} }
log.Debugf("utilityBasicServiceDeletedListCheckPresence") log.Debugf("utilityBasicServiceDeletedListCheckPresence")
basicServiceDeletedListRaw, err := c.DecortAPICall(ctx, "POST", bserviceListDeletedAPI, urlValues) basicServiceDeletedList, err := c.CloudAPI().BService().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(basicServiceDeletedListRaw), &basicServiceDeletedList)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,46 +22,43 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package bservice package bservice
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*BasicServiceExtend, error) { func utilityBasicServiceCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.RecordBasicService, error) {
bservice := &BasicServiceExtend{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
if (strconv.Itoa(d.Get("service_id").(int))) != "0" { if (strconv.Itoa(d.Get("service_id").(int))) != "0" {
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) id = uint64(d.Get("service_id").(int))
} else { } else {
urlValues.Add("serviceId", d.Id()) id, _ = strconv.ParseUint(d.Id(), 10, 64)
}
req := bservice.GetRequest{
ServiceID: id,
} }
log.Debugf("utilityBasicServiceCheckPresence") log.Debugf("utilityBasicServiceCheckPresence")
bserviceRaw, err := c.DecortAPICall(ctx, "POST", bserviceGetAPI, urlValues) bservice, err := c.CloudAPI().BService().Get(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(bserviceRaw), &bservice)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,47 +22,43 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package bservice package bservice
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*BasicServiceGroup, error) { func utilityBasicServiceGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.RecordGroup, error) {
bserviceGroup := &BasicServiceGroup{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) req := bservice.GroupGetRequest{
ServiceID: uint64(d.Get("service_id").(int)),
}
if (strconv.Itoa(d.Get("compgroup_id").(int))) != "0" { if (strconv.Itoa(d.Get("compgroup_id").(int))) != "0" {
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) req.CompGroupID = uint64(d.Get("compgroup_id").(int))
} else { } else {
urlValues.Add("compgroupId", d.Id()) comGroupID, _ := strconv.ParseUint(d.Id(), 10, 64)
req.CompGroupID = comGroupID
} }
log.Debugf("utilityBasicServiceGroupCheckPresence") log.Debugf("utilityBasicServiceGroupCheckPresence")
bserviceGroupRaw, err := c.DecortAPICall(ctx, "POST", bserviceGroupGetAPI, urlValues) bserviceGroup, err := c.CloudAPI().BService().GroupGet(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(bserviceGroupRaw), &bserviceGroup)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,53 +22,69 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package bservice package bservice
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"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{}) (BasicServiceList, error) { func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
basicServiceList := BasicServiceList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := bservice.ListRequest{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
urlValues.Add("accountId", strconv.Itoa(accountId.(int))) req.AccountID = uint64(accountId.(int))
} }
if rgId, ok := d.GetOk("rg_id"); ok { if rgId, ok := d.GetOk("rg_id"); ok {
urlValues.Add("rgId", strconv.Itoa(rgId.(int))) req.RGID = uint64(rgId.(int))
} }
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int))) req.Page = uint64(page.(int))
} }
if size, ok := d.GetOk("size"); ok { if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(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")
basicServiceListRaw, err := c.DecortAPICall(ctx, "POST", bserviceListAPI, urlValues) basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(basicServiceListRaw), &basicServiceList)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@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.
@@ -21,44 +22,40 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package bservice package bservice
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"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{}) (BasicServiceSnapshots, error) { func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListInfoSnapshots, error) {
basicServiceSnapshotList := BasicServiceSnapshots{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} var id uint64
if serviceId, ok := d.GetOk("service_id"); ok { if serviceId, ok := d.GetOk("service_id"); ok {
urlValues.Add("serviceId", strconv.Itoa(serviceId.(int))) id = uint64(serviceId.(int))
}
req := bservice.SnapshotListRequest{
ServiceID: id,
} }
log.Debugf("utilityBasicServiceSnapshotListCheckPresence") log.Debugf("utilityBasicServiceSnapshotListCheckPresence")
basicServiceSnapshotListRaw, err := c.DecortAPICall(ctx, "POST", bserviceSnapshotListAPI, urlValues) basicServiceSnapshotList, err := c.CloudAPI().BService().SnapshotList(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(basicServiceSnapshotListRaw), &basicServiceSnapshotList)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,52 +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.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package disks
const (
disksCreateAPI = "/restmachine/cloudapi/disks/create"
disksGetAPI = "/restmachine/cloudapi/disks/get"
disksListAPI = "/restmachine/cloudapi/disks/list"
disksResizeAPI = "/restmachine/cloudapi/disks/resize2"
disksRenameAPI = "/restmachine/cloudapi/disks/rename"
disksDeleteAPI = "/restmachine/cloudapi/disks/delete"
disksIOLimitAPI = "/restmachine/cloudapi/disks/limitIO"
disksRestoreAPI = "/restmachine/cloudapi/disks/restore"
disksListTypesAPI = "/restmachine/cloudapi/disks/listTypes"
disksListDeletedAPI = "/restmachine/cloudapi/disks/listDeleted"
disksListUnattachedAPI = "/restmachine/cloudapi/disks/listUnattached"
disksSnapshotDeleteAPI = "/restmachine/cloudapi/disks/snapshotDelete"
disksSnapshotRollbackAPI = "/restmachine/cloudapi/disks/snapshotRollback"
disksShareAPI = "/restmachine/cloudapi/disks/share"
disksUnshareAPI = "/restmachine/cloudapi/disks/unshare"
)

View File

@@ -22,24 +22,23 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
// "net/url" // "net/url"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"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"
@@ -48,59 +47,14 @@ 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)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
diskAcl, _ := json.Marshal(disk.Acl) flattenDisk(d, disk)
d.Set("account_id", disk.AccountID)
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Desc)
d.Set("destruction_time", disk.DestructionTime)
d.Set("devicename", disk.DeviceName)
d.Set("disk_path", disk.DiskPath)
d.Set("gid", disk.GridID)
d.Set("guid", disk.GUID)
d.Set("disk_id", disk.ID)
d.Set("image_id", disk.ImageID)
d.Set("images", disk.Images)
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
d.Set("params", disk.Params)
d.Set("parent_id", disk.ParentId)
d.Set("passwd", disk.Passwd)
d.Set("pci_slot", disk.PciSlot)
d.Set("pool", disk.Pool)
d.Set("present_to", disk.PresentTo)
d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("purge_time", disk.PurgeTime)
d.Set("reality_device_number", disk.RealityDeviceNumber)
d.Set("reference_id", disk.ReferenceId)
d.Set("res_id", disk.ResID)
d.Set("res_name", disk.ResName)
d.Set("role", disk.Role)
d.Set("sep_id", disk.SepID)
d.Set("sep_type", disk.SepType)
d.Set("shareable", disk.Shareable)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
d.Set("status", disk.Status)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
return nil return nil
} }
@@ -126,11 +80,11 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"boot_partition": { // "boot_partition": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Number of disk partitions", // Description: "Number of disk partitions",
}, // },
"computes": { "computes": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -172,21 +126,21 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "Name of the device", Description: "Name of the device",
}, },
"disk_path": { // "disk_path": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Disk path", // Description: "Disk path",
}, // },
"gid": { "gid": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "ID of the grid (platform)", Description: "ID of the grid (platform)",
}, },
"guid": { // "guid": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Disk ID on the storage side", // Description: "Disk ID on the storage side",
}, // },
"image_id": { "image_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -273,21 +227,21 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
}, },
}, },
}, },
"iqn": { // "iqn": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Disk IQN", // Description: "Disk IQN",
}, // },
"login": { // "login": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Login to access the disk", // Description: "Login to access the disk",
}, // },
"milestones": { // "milestones": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Milestones", // Description: "Milestones",
}, // },
"disk_name": { "disk_name": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -308,11 +262,11 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "ID of the parent disk", Description: "ID of the parent disk",
}, },
"passwd": { // "passwd": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Password to access the disk", // Description: "Password to access the disk",
}, // },
"pci_slot": { "pci_slot": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -330,26 +284,26 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, Type: schema.TypeInt,
}, },
}, },
"purge_attempts": { // "purge_attempts": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Number of deletion attempts", // Description: "Number of deletion attempts",
}, // },
"purge_time": { "purge_time": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "Time of the last deletion attempt", Description: "Time of the last deletion attempt",
}, },
"reality_device_number": { // "reality_device_number": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Reality device number", // Description: "Reality device number",
}, // },
"reference_id": { // "reference_id": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "ID of the reference to the disk", // Description: "ID of the reference to the disk",
}, // },
"res_id": { "res_id": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -385,7 +339,7 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Description: "Size in GB", Description: "Size in GB",
}, },
"size_used": { "size_used": {
Type: schema.TypeInt, Type: schema.TypeFloat,
Computed: true, Computed: true,
Description: "Number of used space, in GB", Description: "Number of used space, in GB",
}, },

File diff suppressed because it is too large Load Diff

View File

@@ -22,12 +22,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
@@ -38,23 +38,35 @@ 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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
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
} }

View File

@@ -22,12 +22,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
@@ -38,27 +38,32 @@ 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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
func flattenDiskListTypesDetailed(tld TypesDetailedList) []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{})
temp := map[string]interface{}{ temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(typeListDetailed.Pools), "pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": typeListDetailed.SepID, "sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
} }
res = append(res, temp) res = append(res, temp)
} }
return res return res
} }
func flattenListTypesDetailedPools(pools PoolList) []interface{} { func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
res := make([]interface{}, 0) res := make([]interface{}, 0)
for _, pool := range pools { for _, pool := range pools {
toMap := pool.(map[string]interface{})
temp := map[string]interface{}{ temp := map[string]interface{}{
"name": pool.Name, "name": toMap["name"].(string),
"types": pool.Types, "system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
} }
res = append(res, temp) res = append(res, temp)
} }
@@ -69,17 +74,29 @@ func flattenListTypesDetailedPools(pools PoolList) []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,
@@ -95,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,
@@ -111,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
} }

View File

@@ -22,113 +22,36 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/flattens"
log "github.com/sirupsen/logrus"
) )
func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (UnattachedList, error) {
unattachedList := UnattachedList{}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
if accountId, ok := d.GetOk("accountId"); ok {
urlValues.Add("accountId", strconv.Itoa(accountId.(int)))
}
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
unattachedListRaw, err := c.DecortAPICall(ctx, "POST", disksListUnattachedAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(unattachedListRaw), &unattachedList)
if err != nil {
return nil, err
}
return unattachedList, nil
}
func flattenDiskListUnattached(ul UnattachedList) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, unattachedDisk := range ul {
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.Acl)
tmp := map[string]interface{}{
"_ckey": unattachedDisk.Ckey,
"_meta": flattens.FlattenMeta(unattachedDisk.Meta),
"account_id": unattachedDisk.AccountID,
"account_name": unattachedDisk.AccountName,
"acl": string(unattachedDiskAcl),
"boot_partition": unattachedDisk.BootPartition,
"created_time": unattachedDisk.CreatedTime,
"deleted_time": unattachedDisk.DeletedTime,
"desc": unattachedDisk.Desc,
"destruction_time": unattachedDisk.DestructionTime,
"disk_path": unattachedDisk.DiskPath,
"gid": unattachedDisk.GridID,
"guid": unattachedDisk.GUID,
"disk_id": unattachedDisk.ID,
"image_id": unattachedDisk.ImageID,
"images": unattachedDisk.Images,
"iotune": flattenIOTune(unattachedDisk.IOTune),
"iqn": unattachedDisk.IQN,
"login": unattachedDisk.Login,
"milestones": unattachedDisk.Milestones,
"disk_name": unattachedDisk.Name,
"order": unattachedDisk.Order,
"params": unattachedDisk.Params,
"parent_id": unattachedDisk.ParentID,
"passwd": unattachedDisk.Passwd,
"pci_slot": unattachedDisk.PciSlot,
"pool": unattachedDisk.Pool,
"purge_attempts": unattachedDisk.PurgeAttempts,
"purge_time": unattachedDisk.PurgeTime,
"reality_device_number": unattachedDisk.RealityDeviceNumber,
"reference_id": unattachedDisk.ReferenceID,
"res_id": unattachedDisk.ResID,
"res_name": unattachedDisk.ResName,
"role": unattachedDisk.Role,
"sep_id": unattachedDisk.SepID,
"size_max": unattachedDisk.SizeMax,
"size_used": unattachedDisk.SizeUsed,
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
"status": unattachedDisk.Status,
"tech_status": unattachedDisk.TechStatus,
"type": unattachedDisk.Type,
"vmid": unattachedDisk.VMID,
}
res = append(res, tmp)
}
return res
}
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
} }
@@ -150,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,
@@ -409,13 +376,18 @@ 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,
Description: "Size in GB", Description: "Size in GB",
}, },
"size_used": { "size_used": {
Type: schema.TypeInt, Type: schema.TypeFloat,
Computed: true, Computed: true,
Description: "Number of used space, in GB", Description: "Number of used space, in GB",
}, },
@@ -480,6 +452,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
}, },
}, },
}, },
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
} }
return res return res
} }

View File

@@ -22,12 +22,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
@@ -38,21 +38,20 @@ 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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
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 disk == nil { if err != nil {
if err != nil { d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
}
return nil
} }
snapshots := disk.Snapshots
snapshot := Snapshot{} var snapshot disks.ItemSnapshot
label := d.Get("label").(string) label := d.Get("label").(string)
for _, sn := range snapshots { for _, sn := range disk.Snapshots {
if label == sn.Label { if label == sn.Label {
snapshot = sn snapshot = sn
break break
@@ -64,11 +63,9 @@ func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m i
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("timestamp", snapshot.TimeStamp)
d.Set("guid", snapshot.Guid) flattenDiskSnapshot(d, snapshot)
d.Set("res_id", snapshot.ResId)
d.Set("snap_set_guid", snapshot.SnapSetGuid)
d.Set("snap_set_time", snapshot.SnapSetTime)
return nil return nil
} }

View File

@@ -22,12 +22,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
@@ -38,16 +38,14 @@ 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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
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 disk == nil { if err != nil {
if err != nil { d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
}
return nil
} }
id := uuid.New() id := uuid.New()

View File

@@ -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.
@@ -22,12 +23,12 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
@@ -38,22 +39,437 @@ 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"
"github.com/rudecs/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
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, disksListDeletedAPI) 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(),
} }
} }

View File

@@ -0,0 +1,220 @@
package disks
import (
"encoding/json"
"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/flattens"
)
func flattenDiskSnapshot(d *schema.ResourceData, snapshot disks.ItemSnapshot) {
d.Set("timestamp", snapshot.TimeStamp)
d.Set("guid", snapshot.GUID)
d.Set("res_id", snapshot.ResID)
d.Set("snap_set_guid", snapshot.SnapSetGUID)
d.Set("snap_set_time", snapshot.SnapSetTime)
}
func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ul.Data))
for _, unattachedDisk := range ul.Data {
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
tmp := map[string]interface{}{
"_ckey": unattachedDisk.CKey,
"_meta": flattens.FlattenMeta(unattachedDisk.Meta),
"account_id": unattachedDisk.AccountID,
"account_name": unattachedDisk.AccountName,
"acl": string(unattachedDiskAcl),
"boot_partition": unattachedDisk.BootPartition,
"created_time": unattachedDisk.CreatedTime,
"deleted_time": unattachedDisk.DeletedTime,
"desc": unattachedDisk.Description,
"destruction_time": unattachedDisk.DestructionTime,
"disk_path": unattachedDisk.DiskPath,
"gid": unattachedDisk.GID,
"guid": unattachedDisk.GUID,
"disk_id": unattachedDisk.ID,
"image_id": unattachedDisk.ImageID,
"images": unattachedDisk.Images,
"iotune": flattenIOTune(unattachedDisk.IOTune),
"iqn": unattachedDisk.IQN,
"login": unattachedDisk.Login,
"milestones": unattachedDisk.Milestones,
"disk_name": unattachedDisk.Name,
"order": unattachedDisk.Order,
"params": unattachedDisk.Params,
"parent_id": unattachedDisk.ParentID,
"passwd": unattachedDisk.Password,
"pci_slot": unattachedDisk.PCISlot,
"pool": unattachedDisk.Pool,
"purge_attempts": unattachedDisk.PurgeAttempts,
"purge_time": unattachedDisk.PurgeTime,
"reality_device_number": unattachedDisk.RealityDeviceNumber,
"reference_id": unattachedDisk.ReferenceID,
"res_id": unattachedDisk.ResID,
"res_name": unattachedDisk.ResName,
"role": unattachedDisk.Role,
"sep_id": unattachedDisk.SEPID,
"shareable": unattachedDisk.Shareable,
"size_max": unattachedDisk.SizeMax,
"size_used": unattachedDisk.SizeUsed,
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
"status": unattachedDisk.Status,
"tech_status": unattachedDisk.TechStatus,
"type": unattachedDisk.Type,
"vmid": unattachedDisk.VMID,
}
res = append(res, tmp)
}
return res
}
func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
diskAcl, _ := json.Marshal(disk.ACL)
d.Set("account_id", disk.AccountID)
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
// d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Description)
d.Set("destruction_time", disk.DestructionTime)
d.Set("devicename", disk.DeviceName)
// d.Set("disk_path", disk.DiskPath)
d.Set("gid", disk.GID)
// d.Set("guid", disk.GUID)
d.Set("disk_id", disk.ID)
d.Set("image_id", disk.ImageID)
d.Set("images", disk.Images)
d.Set("iotune", flattenIOTune(disk.IOTune))
// d.Set("iqn", disk.IQN)
// d.Set("login", disk.Login)
// d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
d.Set("params", disk.Params)
d.Set("parent_id", disk.ParentID)
// d.Set("passwd", disk.Passwd)
d.Set("pci_slot", disk.PCISlot)
d.Set("pool", disk.Pool)
d.Set("present_to", disk.PresentTo)
// d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("purge_time", disk.PurgeTime)
// d.Set("reality_device_number", disk.RealityDeviceNumber)
// d.Set("reference_id", disk.ReferenceID)
d.Set("res_id", disk.ResID)
d.Set("res_name", disk.ResName)
d.Set("role", disk.Role)
d.Set("sep_id", disk.SepID)
d.Set("sep_type", disk.SepType)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("shareable", disk.Shareable)
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
d.Set("status", disk.Status)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
}
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
res := make([]interface{}, 0, len(sl))
for _, snapshot := range sl {
temp := map[string]interface{}{
"guid": snapshot.GUID,
"label": snapshot.Label,
"res_id": snapshot.ResID,
"snap_set_guid": snapshot.SnapSetGUID,
"snap_set_time": snapshot.SnapSetTime,
"timestamp": snapshot.TimeStamp,
}
res = append(res, temp)
}
return res
}
func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(dl.Data))
for _, disk := range dl.Data {
diskAcl, _ := json.Marshal(disk.ACL)
temp := map[string]interface{}{
"account_id": disk.AccountID,
"account_name": disk.AccountName,
"acl": string(diskAcl),
"computes": flattenDiskComputes(disk.Computes),
"created_time": disk.CreatedTime,
"deleted_time": disk.DeletedTime,
"desc": disk.Description,
"destruction_time": disk.DestructionTime,
"devicename": disk.DeviceName,
"gid": disk.GID,
"disk_id": disk.ID,
"image_id": disk.ImageID,
"images": disk.Images,
"iotune": flattenIOTune(disk.IOTune),
"machine_id": disk.MachineID,
"machine_name": disk.MachineName,
"disk_name": disk.Name,
"order": disk.Order,
"params": disk.Params,
"parent_id": disk.ParentID,
"pci_slot": disk.PCISlot,
"pool": disk.Pool,
"present_to": disk.PresentTo,
"purge_time": disk.PurgeTime,
"res_id": disk.ResID,
"res_name": disk.ResName,
"role": disk.Role,
"sep_id": disk.SepID,
"sep_type": disk.SepType,
"shareable": disk.Shareable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
"status": disk.Status,
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
}
res = append(res, temp)
}
return res
}
func flattenIOTune(iot disks.IOTune) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"read_bytes_sec": iot.ReadBytesSec,
"read_bytes_sec_max": iot.ReadBytesSecMax,
"read_iops_sec": iot.ReadIOPSSec,
"read_iops_sec_max": iot.ReadIOPSSecMax,
"size_iops_sec": iot.SizeIOPSSec,
"total_bytes_sec": iot.TotalBytesSec,
"total_bytes_sec_max": iot.TotalBytesSecMax,
"total_iops_sec": iot.TotalIOPSSec,
"total_iops_sec_max": iot.TotalIOPSSecMax,
"write_bytes_sec": iot.WriteBytesSec,
"write_bytes_sec_max": iot.WriteBytesSecMax,
"write_iops_sec": iot.WriteIOPSSec,
"write_iops_sec_max": iot.WriteIOPSSecMax,
}
res = append(res, temp)
return res
}
func flattenDiskComputes(computes map[string]string) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for computeKey, computeVal := range computes {
temp := map[string]interface{}{
"compute_id": computeKey,
"compute_name": computeVal,
}
res = append(res, temp)
}
return res
}

View File

@@ -1,181 +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.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package disks
type Disk struct {
Acl map[string]interface{} `json:"acl"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
BootPartition int `json:"bootPartition"`
Computes map[string]string `json:"computes"`
CreatedTime uint64 `json:"creationTime"`
DeletedTime uint64 `json:"deletionTime"`
DeviceName string `json:"devicename"`
Desc string `json:"desc"`
DestructionTime uint64 `json:"destructionTime"`
DiskPath string `json:"diskPath"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID uint `json:"id"`
ImageID int `json:"imageId"`
Images []int `json:"images"`
IOTune IOTune `json:"iotune"`
IQN string `json:"iqn"`
Login string `json:"login"`
Name string `json:"name"`
MachineId int `json:"machineId"`
MachineName string `json:"machineName"`
Milestones uint64 `json:"milestones"`
Order int `json:"order"`
Params string `json:"params"`
Passwd string `json:"passwd"`
ParentId int `json:"parentId"`
PciSlot int `json:"pciSlot"`
Pool string `json:"pool"`
PresentTo []int `json:"presentTo"`
PurgeTime uint64 `json:"purgeTime"`
PurgeAttempts uint64 `json:"purgeAttempts"`
RealityDeviceNumber int `json:"realityDeviceNumber"`
ReferenceId string `json:"referenceId"`
ResID string `json:"resId"`
ResName string `json:"resName"`
Role string `json:"role"`
SepType string `json:"sepType"`
Shareable bool `json:"shareable"`
SepID int `json:"sepId"` // NOTE: absent from compute/get output
SizeMax int `json:"sizeMax"`
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
Snapshots []Snapshot `json:"snapshots"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
UpdateBy uint64 `json:"updateBy"`
VMID int `json:"vmid"`
}
type Snapshot struct {
Guid string `json:"guid"`
Label string `json:"label"`
ResId string `json:"resId"`
SnapSetGuid string `json:"snapSetGuid"`
SnapSetTime uint64 `json:"snapSetTime"`
TimeStamp uint64 `json:"timestamp"`
}
type SnapshotList []Snapshot
type DisksList []Disk
type IOTune struct {
ReadBytesSec int `json:"read_bytes_sec"`
ReadBytesSecMax int `json:"read_bytes_sec_max"`
ReadIopsSec int `json:"read_iops_sec"`
ReadIopsSecMax int `json:"read_iops_sec_max"`
SizeIopsSec int `json:"size_iops_sec"`
TotalBytesSec int `json:"total_bytes_sec"`
TotalBytesSecMax int `json:"total_bytes_sec_max"`
TotalIopsSec int `json:"total_iops_sec"`
TotalIopsSecMax int `json:"total_iops_sec_max"`
WriteBytesSec int `json:"write_bytes_sec"`
WriteBytesSecMax int `json:"write_bytes_sec_max"`
WriteIopsSec int `json:"write_iops_sec"`
WriteIopsSecMax int `json:"write_iops_sec_max"`
}
type Pool struct {
Name string `json:"name"`
Types []string `json:"types"`
}
type PoolList []Pool
type TypeDetailed struct {
Pools []Pool `json:"pools"`
SepID int `json:"sepId"`
}
type TypesDetailedList []TypeDetailed
type TypesList []string
type Unattached struct {
Ckey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
Acl map[string]interface{} `json:"acl"`
BootPartition int `json:"bootPartition"`
CreatedTime int `json:"createdTime"`
DeletedTime int `json:"deletedTime"`
Desc string `json:"desc"`
DestructionTime int `json:"destructionTime"`
DiskPath string `json:"diskPath"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
ImageID int `json:"imageId"`
Images []int `json:"images"`
IOTune IOTune `json:"iotune"`
IQN string `json:"iqn"`
Login string `json:"login"`
Milestones int `json:"milestones"`
Name string `json:"name"`
Order int `json:"order"`
Params string `json:"params"`
ParentID int `json:"parentId"`
Passwd string `json:"passwd"`
PciSlot int `json:"pciSlot"`
Pool string `json:"pool"`
PurgeAttempts int `json:"purgeAttempts"`
PurgeTime int `json:"purgeTime"`
RealityDeviceNumber int `json:"realityDeviceNumber"`
ReferenceID string `json:"referenceId"`
ResID string `json:"resId"`
ResName string `json:"resName"`
Role string `json:"role"`
SepID int `json:"sepId"`
SizeMax int `json:"sizeMax"`
SizeUsed int `json:"sizeUsed"`
Snapshots []Snapshot `json:"snapshots"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
VMID int `json:"vmid"`
}
type UnattachedList []Unattached
type Pair struct {
intPort int
extPortStart int
}

View File

@@ -0,0 +1,36 @@
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
c := m.(*controller.ControllerCfg)
accountId := uint64(d.Get("account_id").(int))
req := account.ListRequest{}
accountList, err := c.CloudAPI().Account().List(ctx, req)
if err != nil {
return false, err
}
return len(accountList.FilterByID(accountId).Data) != 0, nil
}
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
c := m.(*controller.ControllerCfg)
gid := uint64(d.Get("gid").(int))
req := locations.ListRequest{}
locationList, err := c.CloudAPI().Locations().List(ctx, req)
if err != nil {
return false, err
}
return len(locationList.FilterByGID(gid).Data) != 0, nil
}

View File

@@ -22,29 +22,28 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"net/url"
"strconv" "strconv"
"strings" "strings"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/dc"
"github.com/rudecs/terraform-provider-decort/internal/status"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"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/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
"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"
@@ -53,183 +52,217 @@ import (
func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := disks.CreateRequest{}
urlValues.Add("accountId", fmt.Sprintf("%d", d.Get("account_id").(int))) haveAccount, err := existAccountID(ctx, d, m)
urlValues.Add("gid", fmt.Sprintf("%d", d.Get("gid").(int))) if err != nil {
urlValues.Add("name", d.Get("disk_name").(string)) return diag.FromErr(err)
urlValues.Add("size", fmt.Sprintf("%d", d.Get("size_max").(int))) }
if !haveAccount {
return diag.Errorf("resourceDiskCreate: can't create Disk because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
}
haveGID, err := existGID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveGID {
return diag.Errorf("resourceDiskCreate: can't create Disk because GID %d is not allowed or does not exist", d.Get("gid").(int))
}
req.AccountID = uint64(d.Get("account_id").(int))
req.GID = uint64(d.Get("gid").(int))
req.Name = d.Get("disk_name").(string)
req.Size = uint64(d.Get("size_max").(int))
if typeRaw, ok := d.GetOk("type"); ok { if typeRaw, ok := d.GetOk("type"); ok {
urlValues.Add("type", strings.ToUpper(typeRaw.(string))) req.Type = strings.ToUpper(typeRaw.(string))
} else { } else {
urlValues.Add("type", "D") req.Type = "D"
} }
if sepId, ok := d.GetOk("sep_id"); ok { if sepId, ok := d.GetOk("sep_id"); ok {
urlValues.Add("sep_id", strconv.Itoa(sepId.(int))) req.SEPID = uint64(sepId.(int))
} }
if poolName, ok := d.GetOk("pool"); ok { if poolName, ok := d.GetOk("pool"); ok {
urlValues.Add("pool", poolName.(string)) req.Pool = poolName.(string)
} }
argVal, argSet := d.GetOk("desc") argVal, argSet := d.GetOk("desc")
if argSet { if argSet {
urlValues.Add("description", argVal.(string)) req.Description = argVal.(string)
} }
diskId, err := c.DecortAPICall(ctx, "POST", disksCreateAPI, urlValues) diskId, err := c.CloudAPI().Disks().Create(ctx, req)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{} d.SetId(strconv.FormatUint(diskId, 10))
d.SetId(diskId) // update ID of the resource to tell Terraform that the disk resource exists
if iotuneRaw, ok := d.GetOk("iotune"); ok { if iotuneRaw, ok := d.GetOk("iotune"); ok {
iot := iotuneRaw.([]interface{})[0] iot := iotuneRaw.([]interface{})[0]
iotune := iot.(map[string]interface{}) iotune := iot.(map[string]interface{})
urlValues.Add("diskId", diskId) req := disks.LimitIORequest{
urlValues.Add("iops", strconv.Itoa(iotune["total_iops_sec"].(int))) DiskID: diskId,
urlValues.Add("read_bytes_sec", strconv.Itoa(iotune["read_bytes_sec"].(int))) IOPS: uint64(iotune["total_iops_sec"].(int)),
urlValues.Add("read_bytes_sec_max", strconv.Itoa(iotune["read_bytes_sec_max"].(int))) ReadBytesSec: uint64(iotune["read_bytes_sec"].(int)),
urlValues.Add("read_iops_sec", strconv.Itoa(iotune["read_iops_sec"].(int))) ReadBytesSecMax: uint64(iotune["read_bytes_sec_max"].(int)),
urlValues.Add("read_iops_sec_max", strconv.Itoa(iotune["read_iops_sec_max"].(int))) ReadIOPSSec: uint64(iotune["read_iops_sec"].(int)),
urlValues.Add("size_iops_sec", strconv.Itoa(iotune["size_iops_sec"].(int))) ReadIOPSSecMax: uint64(iotune["read_iops_sec_max"].(int)),
urlValues.Add("total_bytes_sec", strconv.Itoa(iotune["total_bytes_sec"].(int))) SizeIOPSSec: uint64(iotune["size_iops_sec"].(int)),
urlValues.Add("total_bytes_sec_max", strconv.Itoa(iotune["total_bytes_sec_max"].(int))) TotalBytesSec: uint64(iotune["total_bytes_sec"].(int)),
urlValues.Add("total_iops_sec_max", strconv.Itoa(iotune["total_iops_sec_max"].(int))) TotalBytesSecMax: uint64(iotune["total_bytes_sec_max"].(int)),
urlValues.Add("write_bytes_sec", strconv.Itoa(iotune["write_bytes_sec"].(int))) TotalIOPSSecMax: uint64(iotune["total_iops_sec_max"].(int)),
urlValues.Add("write_bytes_sec_max", strconv.Itoa(iotune["write_bytes_sec_max"].(int))) TotalIOPSSec: uint64(iotune["total_iops_sec"].(int)),
urlValues.Add("write_iops_sec", strconv.Itoa(iotune["write_iops_sec"].(int))) WriteBytesSec: uint64(iotune["write_bytes_sec"].(int)),
urlValues.Add("write_iops_sec_max", strconv.Itoa(iotune["write_iops_sec_max"].(int))) WriteBytesSecMax: uint64(iotune["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotune["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotune["write_iops_sec_max"].(int)),
}
_, err := c.DecortAPICall(ctx, "POST", disksIOLimitAPI, urlValues) _, err := c.CloudAPI().Disks().LimitIO(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
if shareable := d.Get("shareable"); shareable.(bool) == true { if shareable := d.Get("shareable"); shareable.(bool) == true {
urlValues.Add("diskId", diskId) req := disks.ShareRequest{
_, err := c.DecortAPICall(ctx, "POST", disksShareAPI, urlValues) DiskID: diskId,
}
_, err := c.CloudAPI().Disks().Share(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
dgn := resourceDiskRead(ctx, d, m) return resourceDiskRead(ctx, d, m)
if dgn != nil {
return dgn
}
return nil
} }
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
urlValues := &url.Values{} // 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)
if disk == nil { if err != nil {
d.SetId("") d.SetId("")
if err != nil { return diag.FromErr(err)
return diag.FromErr(err)
}
return nil
} }
hasChangeState := false hasChangeState := false
if disk.Status == status.Destroyed || disk.Status == status.Purged {
switch disk.Status {
case status.Destroyed, status.Purged:
d.Set("disk_id", 0) d.Set("disk_id", 0)
return resourceDiskCreate(ctx, d, m) d.SetId("")
} else if disk.Status == status.Deleted { return diag.Errorf("The resource cannot be updated because it has been destroyed")
hasChangeState = true // return resourceDiskCreate(ctx, d, m)
urlValues.Add("diskId", d.Id()) case status.Deleted:
urlValues.Add("reason", d.Get("reason").(string)) // hasChangeState = true
// req := disks.RestoreRequest{
// DiskID: disk.ID,
// }
_, err := c.DecortAPICall(ctx, "POST", disksRestoreAPI, urlValues) // if reason, ok := d.GetOk("reason"); ok {
if err != nil { // req.Reason = reason.(string)
warnings.Add(err) // } else {
} // req.Reason = "Terraform automatic restore"
// }
// _, err := c.CloudAPI().Disks().Restore(ctx, req)
// if err != nil {
// warnings.Add(err)
// }
case status.Assigned:
case status.Modeled:
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
case status.Creating:
case status.Created:
case status.Allocated:
case status.Unallocated:
} }
if hasChangeState { if hasChangeState {
urlValues = &url.Values{}
disk, err = utilityDiskCheckPresence(ctx, d, m) disk, err = utilityDiskCheckPresence(ctx, d, m)
if disk == nil { if err != nil {
d.SetId("") d.SetId("")
if err != nil { return diag.FromErr(err)
return diag.FromErr(err)
}
return nil
} }
} }
diskAcl, _ := json.Marshal(disk.Acl) flattenDisk(d, disk)
d.Set("account_id", disk.AccountID)
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Desc)
d.Set("destruction_time", disk.DestructionTime)
d.Set("devicename", disk.DeviceName)
d.Set("disk_path", disk.DiskPath)
d.Set("gid", disk.GridID)
d.Set("guid", disk.GUID)
d.Set("disk_id", disk.ID)
d.Set("image_id", disk.ImageID)
d.Set("images", disk.Images)
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
d.Set("params", disk.Params)
d.Set("parent_id", disk.ParentId)
d.Set("passwd", disk.Passwd)
d.Set("pci_slot", disk.PciSlot)
d.Set("pool", disk.Pool)
d.Set("present_to", disk.PresentTo)
d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("purge_time", disk.PurgeTime)
d.Set("reality_device_number", disk.RealityDeviceNumber)
d.Set("reference_id", disk.ReferenceId)
d.Set("res_id", disk.ResID)
d.Set("res_name", disk.ResName)
d.Set("role", disk.Role)
d.Set("sep_id", disk.SepID)
d.Set("sep_type", disk.SepType)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("shareable", disk.Shareable)
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
d.Set("status", disk.Status)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
return warnings.Get() return warnings.Get()
} }
func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} warnings := dc.Warnings{}
haveAccount, err := existAccountID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveAccount {
return diag.Errorf("resourceDiskUpdate: can't update Disk because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
}
haveGID, err := existGID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveGID {
return diag.Errorf("resourceDiskUpdate: can't update Disk because GID %d is not allowed or does not exist", d.Get("gid").(int))
}
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if disk == nil { if err != nil {
d.SetId("")
return diag.FromErr(err)
}
hasChangeState := false
switch disk.Status {
case status.Destroyed, status.Purged:
d.Set("disk_id", 0)
d.SetId("")
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted:
hasChangeState = true
req := disks.RestoreRequest{
DiskID: disk.ID,
}
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
} else {
req.Reason = "Terraform automatic restore"
}
_, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil { if err != nil {
warnings.Add(err)
}
case status.Assigned:
case status.Modeled:
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
case status.Creating:
case status.Created:
case status.Allocated:
case status.Unallocated:
}
if hasChangeState {
disk, err = utilityDiskCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
return nil
} }
if d.HasChange("size_max") { if d.HasChange("size_max") {
@@ -237,68 +270,75 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
if oldSize.(int) < newSize.(int) { if oldSize.(int) < newSize.(int) {
log.Debugf("resourceDiskUpdate: resizing disk ID %s - %d GB -> %d GB", log.Debugf("resourceDiskUpdate: resizing disk ID %s - %d GB -> %d GB",
d.Id(), oldSize.(int), newSize.(int)) d.Id(), oldSize.(int), newSize.(int))
urlValues.Add("diskId", d.Id()) req := disks.ResizeRequest{
urlValues.Add("size", fmt.Sprintf("%d", newSize.(int))) DiskID: disk.ID,
_, err := c.DecortAPICall(ctx, "POST", disksResizeAPI, urlValues) Size: uint64(newSize.(int)),
}
_, err := c.CloudAPI().Disks().Resize2(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
d.Set("size_max", newSize) d.Set("size_max", newSize)
} else if oldSize.(int) > newSize.(int) { } else if oldSize.(int) > newSize.(int) {
return diag.FromErr(fmt.Errorf("resourceDiskUpdate: Disk ID %s - reducing disk size is not allowed", d.Id())) return diag.FromErr(fmt.Errorf("resourceDiskUpdate: Disk ID %s - reducing disk size is not allowed", d.Id()))
} }
urlValues = &url.Values{}
} }
if d.HasChange("disk_name") { if d.HasChange("disk_name") {
urlValues.Add("diskId", d.Id()) req := disks.RenameRequest{
urlValues.Add("name", d.Get("disk_name").(string)) DiskID: disk.ID,
_, err := c.DecortAPICall(ctx, "POST", disksRenameAPI, urlValues) Name: d.Get("disk_name").(string),
}
_, err := c.CloudAPI().Disks().Rename(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
if d.HasChange("iotune") { if d.HasChange("iotune") {
iot := d.Get("iotune").([]interface{})[0] iot := d.Get("iotune").([]interface{})[0]
iotune := iot.(map[string]interface{}) iotune := iot.(map[string]interface{})
urlValues.Add("diskId", d.Id()) req := disks.LimitIORequest{
urlValues.Add("iops", strconv.Itoa(iotune["total_iops_sec"].(int))) DiskID: disk.ID,
urlValues.Add("read_bytes_sec", strconv.Itoa(iotune["read_bytes_sec"].(int))) IOPS: uint64(iotune["total_iops_sec"].(int)),
urlValues.Add("read_bytes_sec_max", strconv.Itoa(iotune["read_bytes_sec_max"].(int))) ReadBytesSec: uint64(iotune["read_bytes_sec"].(int)),
urlValues.Add("read_iops_sec", strconv.Itoa(iotune["read_iops_sec"].(int))) ReadBytesSecMax: uint64(iotune["read_bytes_sec_max"].(int)),
urlValues.Add("read_iops_sec_max", strconv.Itoa(iotune["read_iops_sec_max"].(int))) ReadIOPSSec: uint64(iotune["read_iops_sec"].(int)),
urlValues.Add("size_iops_sec", strconv.Itoa(iotune["size_iops_sec"].(int))) ReadIOPSSecMax: uint64(iotune["read_iops_sec_max"].(int)),
urlValues.Add("total_bytes_sec", strconv.Itoa(iotune["total_bytes_sec"].(int))) SizeIOPSSec: uint64(iotune["size_iops_sec"].(int)),
urlValues.Add("total_bytes_sec_max", strconv.Itoa(iotune["total_bytes_sec_max"].(int))) TotalBytesSec: uint64(iotune["total_bytes_sec"].(int)),
urlValues.Add("total_iops_sec_max", strconv.Itoa(iotune["total_iops_sec_max"].(int))) TotalBytesSecMax: uint64(iotune["total_bytes_sec_max"].(int)),
urlValues.Add("write_bytes_sec", strconv.Itoa(iotune["write_bytes_sec"].(int))) TotalIOPSSecMax: uint64(iotune["total_iops_sec_max"].(int)),
urlValues.Add("write_bytes_sec_max", strconv.Itoa(iotune["write_bytes_sec_max"].(int))) TotalIOPSSec: uint64(iotune["total_iops_sec"].(int)),
urlValues.Add("write_iops_sec", strconv.Itoa(iotune["write_iops_sec"].(int))) WriteBytesSec: uint64(iotune["write_bytes_sec"].(int)),
urlValues.Add("write_iops_sec_max", strconv.Itoa(iotune["write_iops_sec_max"].(int))) WriteBytesSecMax: uint64(iotune["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotune["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotune["write_iops_sec_max"].(int)),
}
_, err := c.DecortAPICall(ctx, "POST", disksIOLimitAPI, urlValues) _, err := c.CloudAPI().Disks().LimitIO(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
if d.HasChange("shareable") { if d.HasChange("shareable") {
oldShare, newShare := d.GetChange("shareable") oldShare, newShare := d.GetChange("shareable")
urlValues = &url.Values{}
urlValues.Add("diskId", d.Id())
if oldShare.(bool) == false && newShare.(bool) == true { if oldShare.(bool) == false && newShare.(bool) == true {
_, err := c.DecortAPICall(ctx, "POST", disksShareAPI, urlValues) req := disks.ShareRequest{DiskID: disk.ID}
_, err := c.CloudAPI().Disks().Share(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
} }
if oldShare.(bool) == true && newShare.(bool) == false { if oldShare.(bool) == true && newShare.(bool) == false {
_, err := c.DecortAPICall(ctx, "POST", disksUnshareAPI, urlValues) req := disks.UnshareRequest{DiskID: disk.ID}
_, err := c.CloudAPI().Disks().Unshare(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -310,35 +350,38 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if disk == nil { if err != nil {
if err != nil { d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
}
return nil
} }
if disk.Status == status.Destroyed || disk.Status == status.Purged { if disk.Status == status.Destroyed || disk.Status == status.Purged {
return nil return nil
} }
params := &url.Values{}
params.Add("diskId", d.Id()) req := disks.DeleteRequest{
params.Add("detach", strconv.FormatBool(d.Get("detach").(bool))) DiskID: disk.ID,
params.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool))) Detach: d.Get("detach").(bool),
params.Add("reason", d.Get("reason").(string)) Permanently: d.Get("permanently").(bool),
Reason: d.Get("reason").(string),
}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
_, err = c.DecortAPICall(ctx, "POST", disksDeleteAPI, params) _, err = c.CloudAPI().Disks().Delete(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
d.SetId("")
return nil return nil
} }
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": {
@@ -352,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": {
@@ -363,13 +406,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "Pool for disk location", Description: "Pool for disk location",
}, },
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"sep_id": { "sep_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
@@ -412,85 +448,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Optional: true, Optional: true,
Computed: true, Computed: true,
}, },
"disk_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk ID. Duplicates the value of the ID parameter",
},
"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",
},
"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",
},
"guid": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk ID on the storage side",
},
"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": { "iotune": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
@@ -579,22 +536,106 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
}, },
}, },
}, },
"iqn": { "present_to": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
Description: "Disk IQN", Elem: &schema.Schema{
Type: schema.TypeInt,
},
}, },
"login": { "disk_id": {
Type: schema.TypeString,
Computed: true,
Description: "Login to access the disk",
},
"milestones": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "Milestones", Description: "Disk ID. Duplicates the value of the ID parameter",
}, },
"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",
},
"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",
// },
// "guid": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Disk ID on the storage side",
// },
"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",
},
// "iqn": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Disk IQN",
// },
// "login": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Login to access the disk",
// },
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"order": { "order": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -610,36 +651,36 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "ID of the parent disk", Description: "ID of the parent disk",
}, },
"passwd": { // "passwd": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Password to access the disk", // Description: "Password to access the disk",
}, // },
"pci_slot": { "pci_slot": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "ID of the pci slot to which the disk is connected", Description: "ID of the pci slot to which the disk is connected",
}, },
"purge_attempts": { // "purge_attempts": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Number of deletion attempts", // Description: "Number of deletion attempts",
}, // },
"purge_time": { "purge_time": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "Time of the last deletion attempt", Description: "Time of the last deletion attempt",
}, },
"reality_device_number": { // "reality_device_number": {
Type: schema.TypeInt, // Type: schema.TypeInt,
Computed: true, // Computed: true,
Description: "Reality device number", // Description: "Reality device number",
}, // },
"reference_id": { // "reference_id": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "ID of the reference to the disk", // Description: "ID of the reference to the disk",
}, // },
"res_id": { "res_id": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -661,7 +702,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform", Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
}, },
"size_used": { "size_used": {
Type: schema.TypeInt, Type: schema.TypeFloat,
Computed: true, Computed: true,
Description: "Number of used space, in GB", Description: "Number of used space, in GB",
}, },

View File

@@ -22,40 +22,37 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"net/url"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"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/controller"
) )
func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
urlValues := &url.Values{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if disk == nil { if err != nil {
if err != nil { return diag.FromErr(err)
return diag.FromErr(err)
}
return nil
} }
snapshots := disk.Snapshots snapshots := disk.Snapshots
snapshot := Snapshot{} snapshot := disks.ItemSnapshot{}
label := d.Get("label").(string) label := d.Get("label").(string)
for _, sn := range snapshots { for _, sn := range snapshots {
if label == sn.Label { if label == sn.Label {
@@ -66,30 +63,32 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
if label != snapshot.Label { if label != snapshot.Label {
return diag.Errorf("Snapshot with label \"%v\" not found", label) return diag.Errorf("Snapshot with label \"%v\" not found", label)
} }
if rollback := d.Get("rollback").(bool); rollback { if rollback := d.Get("rollback").(bool); rollback {
urlValues.Add("diskId", strconv.Itoa(d.Get("disk_id").(int))) req := disks.SnapshotRollbackRequest{
urlValues.Add("label", label) DiskID: disk.ID,
urlValues.Add("timestamp", strconv.Itoa(d.Get("timestamp").(int))) Label: label,
TimeStamp: uint64(d.Get("timestamp").(int)),
}
log.Debugf("resourceDiskCreate: Snapshot rollback with label", label) log.Debugf("resourceDiskCreate: Snapshot rollback with label", label)
_, err := c.DecortAPICall(ctx, "POST", disksSnapshotRollbackAPI, urlValues) _, err := c.CloudAPI().Disks().SnapshotRollback(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
return resourceDiskSnapshotRead(ctx, d, m) return resourceDiskSnapshotRead(ctx, d, m)
} }
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 disk == nil { if err != nil {
if err != nil { d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
}
return nil
} }
snapshots := disk.Snapshots snapshots := disk.Snapshots
snapshot := Snapshot{} snapshot := disks.ItemSnapshot{}
label := d.Get("label").(string) label := d.Get("label").(string)
for _, sn := range snapshots { for _, sn := range snapshots {
if label == sn.Label { if label == sn.Label {
@@ -101,27 +100,20 @@ func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m int
return diag.Errorf("Snapshot with label \"%v\" not found", label) return diag.Errorf("Snapshot with label \"%v\" not found", label)
} }
d.SetId(d.Get("label").(string)) flattenDiskSnapshot(d, snapshot)
d.Set("timestamp", snapshot.TimeStamp)
d.Set("guid", snapshot.Guid)
d.Set("res_id", snapshot.ResId)
d.Set("snap_set_guid", snapshot.SnapSetGuid)
d.Set("snap_set_time", snapshot.SnapSetTime)
return nil return nil
} }
func resourceDiskSnapshotUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskSnapshotUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
urlValues := &url.Values{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if disk == nil { if err != nil {
if err != nil { return diag.FromErr(err)
return diag.FromErr(err)
}
return nil
} }
snapshots := disk.Snapshots snapshots := disk.Snapshots
snapshot := Snapshot{} snapshot := disks.ItemSnapshot{}
label := d.Get("label").(string) label := d.Get("label").(string)
for _, sn := range snapshots { for _, sn := range snapshots {
if label == sn.Label { if label == sn.Label {
@@ -129,19 +121,23 @@ func resourceDiskSnapshotUpdate(ctx context.Context, d *schema.ResourceData, m i
break break
} }
} }
if label != snapshot.Label { if label != snapshot.Label {
return diag.Errorf("Snapshot with label \"%v\" not found", label) return diag.Errorf("Snapshot with label \"%v\" not found", label)
} }
if d.HasChange("rollback") && d.Get("rollback").(bool) == true { if d.HasChange("rollback") && d.Get("rollback").(bool) == true {
urlValues.Add("diskId", strconv.Itoa(d.Get("disk_id").(int))) req := disks.SnapshotRollbackRequest{
urlValues.Add("label", label) DiskID: disk.ID,
urlValues.Add("timestamp", strconv.Itoa(d.Get("timestamp").(int))) Label: label,
TimeStamp: uint64(d.Get("timestamp").(int)),
}
log.Debugf("resourceDiskUpdtae: Snapshot rollback with label", label) log.Debugf("resourceDiskUpdtae: Snapshot rollback with label", label)
_, err := c.DecortAPICall(ctx, "POST", disksSnapshotRollbackAPI, urlValues) _, err := c.CloudAPI().Disks().SnapshotRollback(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
urlValues = &url.Values{}
} }
return resourceDiskSnapshotRead(ctx, d, m) return resourceDiskSnapshotRead(ctx, d, m)
@@ -151,37 +147,38 @@ func resourceDiskSnapshotDelete(ctx context.Context, d *schema.ResourceData, m i
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if disk == nil { //if disk not exits, can't call snapshotDelete if err != nil {
d.SetId("") d.SetId("")
if err != nil { return diag.FromErr(err)
return diag.FromErr(err)
}
return nil
} }
params := &url.Values{} req := disks.SnapshotDeleteRequest{
params.Add("diskId", strconv.Itoa(d.Get("disk_id").(int))) DiskID: disk.ID,
params.Add("label", d.Get("label").(string)) Label: d.Get("label").(string),
}
_, err = c.DecortAPICall(ctx, "POST", disksSnapshotDeleteAPI, params) _, err = c.CloudAPI().Disks().SnapshotDelete(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
d.SetId("")
return nil return nil
} }
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": {
@@ -190,17 +187,17 @@ func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
Default: false, Default: false,
Description: "Needed in order to make a snapshot rollback", Description: "Needed in order to make a snapshot rollback",
}, },
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the snapshot",
},
"timestamp": { "timestamp": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
Computed: true, Computed: true,
Description: "Snapshot time", Description: "Snapshot time",
}, },
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the snapshot",
},
"res_id": { "res_id": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,

View File

@@ -22,47 +22,45 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityDiskCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Disk, error) { func utilityDiskCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.RecordDisk, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := disks.GetRequest{}
disk := &Disk{} if d.Get("disk_id") != nil {
if d.Get("disk_id").(int) == 0 {
if d.Get("disk_id").(int) == 0 { id, _ := strconv.ParseUint(d.Id(), 10, 64)
urlValues.Add("diskId", d.Id()) req.DiskID = id
} else {
req.DiskID = uint64(d.Get("disk_id").(int))
}
} else { } else {
urlValues.Add("diskId", strconv.Itoa(d.Get("disk_id").(int))) id, _ := strconv.ParseUint(d.Id(), 10, 64)
req.DiskID = id
} }
log.Debugf("utilityDiskCheckPresence: load disk") log.Debugf("utilityDiskCheckPresence: load disk")
diskRaw, err := c.DecortAPICall(ctx, "POST", disksGetAPI, urlValues) disk, err := c.CloudAPI().Disks().Get(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(diskRaw), disk)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -22,54 +22,70 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"net/url"
"strconv"
"strings" "strings"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"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{}, api string) (DisksList, error) { func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
diskList := DisksList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := disks.ListRequest{}
if page, ok := d.GetOk("page"); ok { if by_id, ok := d.GetOk("by_id"); ok {
urlValues.Add("page", strconv.Itoa(page.(int))) req.ByID = uint64(by_id.(int))
} }
if size, ok := d.GetOk("size"); ok { if name, ok := d.GetOk("name"); ok {
urlValues.Add("size", strconv.Itoa(size.(int))) 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 { if diskType, ok := d.GetOk("type"); ok {
urlValues.Add("type", strings.ToUpper(diskType.(string))) req.Type = strings.ToUpper(diskType.(string))
} }
if accountId, ok := d.GetOk("accountId"); ok { if sepId, ok := d.GetOk("sep_id"); ok {
urlValues.Add("accountId", strconv.Itoa(accountId.(int))) 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("utilityDiskListCheckPresence: load disk list") log.Debugf("utilityDiskListCheckPresence: load disk list")
diskListRaw, err := c.DecortAPICall(ctx, "POST", api, urlValues) diskList, err := c.CloudAPI().Disks().List(ctx, req)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(diskListRaw), &diskList)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View 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
}

View File

@@ -0,0 +1,54 @@
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 utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisksUnattached, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListUnattachedRequest{}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if account_name, ok := d.GetOk("account_name"); ok {
req.AccountName = account_name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = int64(disk_max_size.(int))
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
if pool_name, ok := d.GetOk("pool_name"); ok {
req.Pool = pool_name.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
if err != nil {
return nil, err
}
return unattachedList, nil
}

View File

@@ -22,38 +22,40 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"net/url"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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 utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (TypesDetailedList, error) { func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
listTypesDetailed := TypesDetailedList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := disks.ListTypesRequest{
urlValues.Add("detailed", "true") Detailed: true,
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed") }
diskListRaw, err := c.DecortAPICall(ctx, "POST", disksListTypesAPI, urlValues)
if err != nil { if page, ok := d.GetOk("page"); ok {
return nil, err req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
} }
err = json.Unmarshal([]byte(diskListRaw), &listTypesDetailed) log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -22,38 +22,40 @@ limitations under the License.
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it Please see README.md to learn where to place source code so that it
builds seamlessly. builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/ */
package disks package disks
import ( import (
"context" "context"
"encoding/json"
"net/url"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" 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 utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (TypesList, error) { func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
typesList := TypesList{}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} req := disks.ListTypesRequest{
urlValues.Add("detailed", "false") Detailed: false,
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
diskListRaw, err := c.DecortAPICall(ctx, "POST", disksListTypesAPI, urlValues)
if err != nil {
return nil, err
} }
err = json.Unmarshal([]byte(diskListRaw), &typesList) if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,37 +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>
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://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package extnet
const extnetListAPI = "/restmachine/cloudapi/extnet/list"
const extnetListComputesAPI = "/restmachine/cloudapi/extnet/listComputes"
const extnetGetDefaultAPI = "/restmachine/cloudapi/extnet/getDefault"
const extnetGetAPI = "/restmachine/cloudapi/extnet/get"

View File

@@ -1,331 +1,286 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Tim Tkachev, <tvtkachev@basistech.ru>
you may not use this file except in compliance with the License.
You may obtain a copy of the License at Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
http://www.apache.org/licenses/LICENSE-2.0 You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software http://www.apache.org/licenses/LICENSE-2.0
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Unless required by applicable law or agreed to in writing, software
See the License for the specific language governing permissions and distributed under the License is distributed on an "AS IS" BASIS,
limitations under the License. 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. /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Source code: https://github.com/rudecs/terraform-provider-decort Orchestration Technology) with Terraform by Hashicorp.
Please see README.md to learn where to place source code so that it Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
builds seamlessly.
Please see README.md to learn where to place source code so that it
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki builds seamlessly.
*/
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
package extnet */
import ( package extnet
"context"
import (
"github.com/google/uuid" "context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/flattens" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
e, err := utilityExtnetCheckPresence(ctx, d, m) func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { e, err := utilityExtnetCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("ckey", e.CKey) d.SetId(strconv.FormatUint(e.ID, 10))
d.Set("meta", flattens.FlattenMeta(e.Meta)) flattenExtnet(d, e)
d.Set("check__ips", e.CheckIPs)
d.Set("check_ips", e.CheckIps) return nil
d.Set("default", e.Default) }
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQos))
d.Set("desc", e.Desc) func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
d.Set("dns", e.Dns) res := map[string]*schema.Schema{
d.Set("excluded", e.Excluded) "net_id": {
d.Set("free_ips", e.FreeIps) Type: schema.TypeInt,
d.Set("gateway", e.Gateway) Required: true,
d.Set("gid", e.GID) },
d.Set("guid", e.GUID) "ckey": {
d.Set("ipcidr", e.IPCidr) Type: schema.TypeString,
d.Set("milestones", e.Milestones) Computed: true,
d.Set("net_name", e.Name) },
d.Set("network", e.Network) "meta": {
d.Set("network_id", e.NetworkId) Type: schema.TypeList,
d.Set("pre_reservations_num", e.PreReservationsNum) Computed: true,
d.Set("prefix", e.Prefix) Elem: &schema.Schema{
d.Set("pri_vnf_dev_id", e.PriVnfDevId) Type: schema.TypeString,
d.Set("reservations", flattenExtnetReservations(e.Reservations)) },
d.Set("shared_with", e.SharedWith) Description: "meta",
d.Set("status", e.Status) },
d.Set("vlan_id", e.VlanID) "check_ips": {
d.Set("vnfs", flattenExtnetVNFS(e.VNFS)) Type: schema.TypeList,
return nil Computed: true,
} Elem: &schema.Schema{
Type: schema.TypeString,
func flattenExtnetReservations(ers ExtnetReservations) []map[string]interface{} { },
res := make([]map[string]interface{}, 0) },
for _, er := range ers { "default": {
temp := map[string]interface{}{ Type: schema.TypeBool,
"client_type": er.ClientType, Computed: true,
"domainname": er.DomainName, },
"hostname": er.HostName, "default_qos": {
"desc": er.Desc, Type: schema.TypeList,
"ip": er.IP, Computed: true,
"mac": er.MAC, Elem: &schema.Resource{
"type": er.Type, Schema: map[string]*schema.Schema{
"vm_id": er.VMID, "e_rate": {
} Type: schema.TypeInt,
res = append(res, temp) Computed: true,
} },
"e_burst": {
return res Type: schema.TypeInt,
} Computed: true,
},
func flattenExtnetDefaultQos(edqos ExtnetQos) []map[string]interface{} { "guid": {
res := make([]map[string]interface{}, 0) Type: schema.TypeString,
temp := map[string]interface{}{ Computed: true,
"e_rate": edqos.ERate, },
"guid": edqos.GUID, "in_burst": {
"in_burst": edqos.InBurst, Type: schema.TypeInt,
"in_rate": edqos.InRate, Computed: true,
} },
res = append(res, temp) "in_rate": {
return res Type: schema.TypeInt,
} Computed: true,
},
func flattenExtnetVNFS(evnfs ExtnetVNFS) []map[string]interface{} { },
res := make([]map[string]interface{}, 0) },
temp := map[string]interface{}{ },
"dhcp": evnfs.DHCP, "desc": {
} Type: schema.TypeString,
res = append(res, temp) Computed: true,
return res },
} "dns": {
Type: schema.TypeList,
func dataSourceExtnetSchemaMake() map[string]*schema.Schema { Computed: true,
res := map[string]*schema.Schema{ Elem: &schema.Schema{
"net_id": { Type: schema.TypeString,
Type: schema.TypeInt, },
Required: true, },
}, "excluded": {
"ckey": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"meta": { "client_type": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Schema{ },
Type: schema.TypeString, "mac": {
}, Type: schema.TypeString,
Description: "meta", Computed: true,
}, },
"check__ips": { "ip": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Schema{ },
Type: schema.TypeString, "type": {
}, Type: schema.TypeString,
}, Computed: true,
"check_ips": { },
Type: schema.TypeList, "vm_id": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeString, },
}, },
}, },
"default": { },
Type: schema.TypeBool, "free_ips": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"default_qos": { },
Type: schema.TypeList, "gateway": {
Computed: true, Type: schema.TypeString,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ },
"e_rate": { "gid": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"guid": { "guid": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"in_burst": { "ipcidr": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"in_rate": { "milestones": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
}, "net_name": {
}, Type: schema.TypeString,
}, Computed: true,
"desc": { },
Type: schema.TypeString, "network": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"dns": { },
Type: schema.TypeList, "network_id": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeString, },
}, "pre_reservations_num": {
}, Type: schema.TypeInt,
"excluded": { Computed: true,
Type: schema.TypeList, },
Computed: true, "prefix": {
Elem: &schema.Schema{ Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
}, },
}, "pri_vnf_dev_id": {
"free_ips": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "reservations": {
"gateway": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"gid": { "client_type": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"guid": { "domainname": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"ipcidr": { "hostname": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"milestones": { "desc": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"net_name": { "ip": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"network": { "mac": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"network_id": { "type": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"pre_reservations_num": { "vm_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"prefix": { },
Type: schema.TypeInt, },
Computed: true, },
}, "shared_with": {
"pri_vnf_dev_id": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"reservations": { },
Type: schema.TypeList, },
Computed: true, "status": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Computed: true,
"client_type": { },
Type: schema.TypeString, "vlan_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"domainname": { },
Type: schema.TypeString, "vnfs": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"hostname": { Elem: &schema.Resource{
Type: schema.TypeString, Schema: map[string]*schema.Schema{
Computed: true, "dhcp": {
}, Type: schema.TypeInt,
"desc": { Computed: true,
Type: schema.TypeString, },
Computed: true, },
}, },
"ip": { },
Type: schema.TypeString, }
Computed: true, return res
}, }
"mac": {
Type: schema.TypeString, func DataSourceExtnet() *schema.Resource {
Computed: true, return &schema.Resource{
}, SchemaVersion: 1,
"type": {
Type: schema.TypeString, ReadContext: dataSourceExtnetRead,
Computed: true,
}, Timeouts: &schema.ResourceTimeout{
"vm_id": { Read: &constants.Timeout30s,
Type: schema.TypeInt, Default: &constants.Timeout60s,
Computed: true, },
},
}, Schema: dataSourceExtnetSchemaMake(),
}, }
}, }
"shared_with": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"vlan_id": {
Type: schema.TypeInt,
Computed: true,
},
"vnfs": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dhcp": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
}
return res
}
func DataSourceExtnet() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceExtnetRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceExtnetSchemaMake(),
}
}

View File

@@ -1,167 +1,162 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package extnet
package extnet
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func flattenExtnetsComputes(ecs ExtnetExtendList) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
for _, ec := range ecs { extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
temp := map[string]interface{}{ if err != nil {
"net_id": ec.ID, d.SetId("")
"ipaddr": ec.IPAddr, return diag.FromErr(err)
"ipcidr": ec.IPCidr, }
"name": ec.Name,
} id := uuid.New()
res = append(res, temp) d.SetId(id.String())
} d.Set("items", flattenExtnetComputesList(extnetComputesList))
return res d.Set("entry_count", extnetComputesList.EntryCount)
} return nil
}
func flattenExtnetComputesList(ecl ExtnetComputesList) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
for _, ec := range ecl { res := map[string]*schema.Schema{
temp := map[string]interface{}{ "account_id": {
"account_id": ec.AccountId, Type: schema.TypeInt,
"account_name": ec.AccountName, Required: true,
"extnets": flattenExtnetsComputes(ec.Extnets), Description: "filter by account ID",
"id": ec.ID, },
"name": ec.Name, "rg_id": {
"rg_id": ec.RGID, Type: schema.TypeInt,
"rg_name": ec.RGName, Optional: true,
} Description: "Filter by RG ID",
res = append(res, temp) },
} "compute_id": {
return res Type: schema.TypeInt,
} Optional: true,
Description: "Filter by compute ID",
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { },
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m) "page": {
if err != nil { Type: schema.TypeInt,
return diag.FromErr(err) Optional: true,
} Description: "Page number",
},
id := uuid.New() "size": {
d.SetId(id.String()) Type: schema.TypeInt,
d.Set("items", flattenExtnetComputesList(extnetComputesList)) Optional: true,
Description: "Page size",
return nil },
} "items": {
Type: schema.TypeList,
func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema { Computed: true,
res := map[string]*schema.Schema{ Elem: &schema.Resource{
"account_id": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "account_id": {
Required: true, Type: schema.TypeInt,
Description: "filter by account ID", Computed: true,
}, },
"items": { "account_name": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "extnets": {
"account_id": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"account_name": { "net_id": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"extnets": { "ipaddr": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "ipcidr": {
"net_id": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "name": {
"ipaddr": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"ipcidr": { },
Type: schema.TypeString, },
Computed: true, "id": {
}, Type: schema.TypeInt,
"name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "name": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, "rg_id": {
"id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "rg_name": {
"name": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"rg_id": { },
Type: schema.TypeInt, },
Computed: true, "entry_count": {
}, Type: schema.TypeInt,
"rg_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, }
}, return res
}, }
},
}, func DataSourceExtnetComputesList() *schema.Resource {
} return &schema.Resource{
return res SchemaVersion: 1,
}
ReadContext: dataSourceExtnetComputesListRead,
func DataSourceExtnetComputesList() *schema.Resource {
return &schema.Resource{ Timeouts: &schema.ResourceTimeout{
SchemaVersion: 1, Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
ReadContext: dataSourceExtnetComputesListRead, },
Timeouts: &schema.ResourceTimeout{ Schema: dataSourceExtnetComputesListSchemaMake(),
Read: &constants.Timeout30s, }
Default: &constants.Timeout60s, }
},
Schema: dataSourceExtnetComputesListSchemaMake(),
}
}

View File

@@ -1,84 +1,86 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package extnet
package extnet
import (
"context" import (
"strconv" "context"
"strconv"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m) func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32) id := uuid.New()
if err != nil { d.SetId(id.String())
return diag.FromErr(err) extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32)
} if err != nil {
d.Set("net_id", extnetIdInt) return diag.FromErr(err)
}
return nil d.Set("net_id", extnetIdInt)
}
return nil
func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"net_id": { func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Computed: true, "net_id": {
}, Type: schema.TypeInt,
} Computed: true,
return res },
} }
return res
func DataSourceExtnetDefault() *schema.Resource { }
return &schema.Resource{
SchemaVersion: 1, func DataSourceExtnetDefault() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceExtnetDefaultRead, SchemaVersion: 1,
Timeouts: &schema.ResourceTimeout{ ReadContext: dataSourceExtnetDefaultRead,
Read: &constants.Timeout30s,
Default: &constants.Timeout60s, Timeouts: &schema.ResourceTimeout{
}, Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
Schema: dataSourceExtnetDefaultSchemaMake(), },
}
} Schema: dataSourceExtnetDefaultSchemaMake(),
}
}

View File

@@ -1,123 +1,150 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
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. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at 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
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, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. 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. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
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. Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package extnet
package extnet
import (
"context" import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func flattenExtnetList(el ExtnetList) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
for _, e := range el { extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
temp := map[string]interface{}{ if err != nil {
"net_id": e.ID, d.SetId("")
"ipcidr": e.IPCidr, return diag.FromErr(err)
"name": e.Name, }
}
res = append(res, temp) id := uuid.New()
} d.SetId(id.String())
return res d.Set("items", flattenExtnetList(extnetList))
} d.Set("entry_count", extnetList.EntryCount)
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { return nil
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m) }
if err != nil {
return diag.FromErr(err) func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
} res := map[string]*schema.Schema{
"account_id": {
id := uuid.New() Type: schema.TypeInt,
d.SetId(id.String()) Optional: true,
d.Set("items", flattenExtnetList(extnetList)) Description: "Find by account ID",
},
return nil "by_id": {
} Type: schema.TypeInt,
Optional: true,
func dataSourceExtnetListSchemaMake() map[string]*schema.Schema { Description: "Find by ID",
res := map[string]*schema.Schema{ },
"account_id": { "name": {
Type: schema.TypeInt, Type: schema.TypeString,
Optional: true, Optional: true,
Description: "filter by account ID", Description: "Find by name",
}, },
"page": { "network": {
Type: schema.TypeInt, Type: schema.TypeString,
Optional: true, Optional: true,
Description: "Page number", },
}, "vlan_id": {
"size": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Optional: true, Description: "Find by VLAN ID",
Description: "Page size", },
}, "vnfdev_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Optional: true,
Computed: true, Description: "Find by VnfDEV ID",
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "status": {
"net_id": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Find by status",
}, },
"ipcidr": { "page": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page number",
"name": { },
Type: schema.TypeString, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
}, Description: "Page size",
}, },
}, "items": {
} Type: schema.TypeList,
return res Computed: true,
} Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
func DataSourceExtnetList() *schema.Resource { "net_id": {
return &schema.Resource{ Type: schema.TypeInt,
SchemaVersion: 1, Computed: true,
},
ReadContext: dataSourceExtnetListRead, "ipcidr": {
Type: schema.TypeString,
Timeouts: &schema.ResourceTimeout{ Computed: true,
Read: &constants.Timeout30s, },
Default: &constants.Timeout60s, "name": {
}, Type: schema.TypeString,
Computed: true,
Schema: dataSourceExtnetListSchemaMake(), },
} "status": {
} Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceExtnetList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceExtnetListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceExtnetListSchemaMake(),
}
}

View File

@@ -0,0 +1,137 @@
package extnet
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
)
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
d.Set("ckey", e.CKey)
d.Set("meta", flattens.FlattenMeta(e.Meta))
d.Set("check_ips", e.CheckIPs)
d.Set("default", e.Default)
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
d.Set("desc", e.Description)
d.Set("dns", e.DNS)
d.Set("excluded", flattenExcluded(e.Excluded))
d.Set("free_ips", e.FreeIPs)
d.Set("gateway", e.Gateway)
d.Set("gid", e.GID)
d.Set("guid", e.GUID)
d.Set("ipcidr", e.IPCIDR)
d.Set("milestones", e.Milestones)
d.Set("net_name", e.Name)
d.Set("network", e.Network)
d.Set("network_id", e.NetworkID)
d.Set("pre_reservations_num", e.PreReservationsNum)
d.Set("prefix", e.Prefix)
d.Set("pri_vnf_dev_id", e.PriVNFDevID)
d.Set("reservations", flattenExtnetReservations(e.Reservations))
d.Set("shared_with", e.SharedWith)
d.Set("status", e.Status)
d.Set("vlan_id", e.VLANID)
d.Set("vnfs", flattenExtnetVNFS(e.VNFs))
}
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ex))
for _, item := range ex {
temp := map[string]interface{}{
"client_type": item.ClientType,
"mac": item.MAC,
"ip": item.IP,
"type": item.Type,
"vm_id": item.VMID,
}
res = append(res, temp)
}
return res
}
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ers))
for _, er := range ers {
temp := map[string]interface{}{
"client_type": er.ClientType,
"domainname": er.DomainName,
"hostname": er.Hostname,
"desc": er.Description,
"ip": er.IP,
"mac": er.MAC,
"type": er.Type,
"vm_id": er.VMID,
}
res = append(res, temp)
}
return res
}
func flattenExtnetDefaultQos(edqos extnet.QOS) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"e_rate": edqos.ERate,
"e_burst": edqos.EBurst,
"guid": edqos.GUID,
"in_burst": edqos.InBurst,
"in_rate": edqos.InRate,
}
res = append(res, temp)
return res
}
func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"dhcp": evnfs.DHCP,
}
res = append(res, temp)
return res
}
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ecs))
for _, ec := range ecs {
temp := map[string]interface{}{
"net_id": ec.ID,
"ipaddr": ec.IPAddr,
"ipcidr": ec.IPCIDR,
"name": ec.Name,
}
res = append(res, temp)
}
return res
}
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(ecl.Data))
for _, ec := range ecl.Data {
temp := map[string]interface{}{
"account_id": ec.AccountID,
"account_name": ec.AccountName,
"extnets": flattenExtnetsComputes(ec.ExtNets),
"id": ec.ID,
"name": ec.Name,
"rg_id": ec.RGID,
"rg_name": ec.RGName,
}
res = append(res, temp)
}
return res
}
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(el.Data))
for _, e := range el.Data {
temp := map[string]interface{}{
"net_id": e.ID,
"ipcidr": e.IPCIDR,
"name": e.Name,
"status": e.Status,
}
res = append(res, temp)
}
return res
}

Some files were not shown because too many files have changed in this diff Show More