Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
775a0b5adb | ||
|
|
1a983e945b | ||
|
|
b152359706 | ||
| a844f6cc30 | |||
|
|
8e6b5a9bab | ||
|
|
cd4695ee68 |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,10 +1,21 @@
|
|||||||
### Bug fixes
|
### Bug fixes
|
||||||
- fatal error when trying to retrieve compute boot disk if former does not have one
|
- error when importing kvmvm without image_id
|
||||||
- ignored timeouts
|
- state reading for kvmvm created from virtual image
|
||||||
- wrong handling of errors when attaching network interfaces and disks to kvmvm
|
- type field usage in image
|
||||||
|
- wrong API handle for image creation
|
||||||
|
- updating description in kvmvm
|
||||||
|
|
||||||
### New features
|
### New features
|
||||||
- parameter iotune in disk
|
- ipaType and IS parameters in kvmvm
|
||||||
- migrated to terraform SDKv2
|
|
||||||
- admin mode (activated by environment variable DECORT\_ADMIN\_MODE) for resources: account, k8s, image, disk, resgroup, kvmvm, vins
|
### New datasources
|
||||||
- parameters sep\_id and pool in kvmvm
|
- lb
|
||||||
|
- lb\_list
|
||||||
|
- lb\_list\_deleted
|
||||||
|
|
||||||
|
### New resources
|
||||||
|
- lb
|
||||||
|
- lb\_backend
|
||||||
|
- lb\_backend\_server
|
||||||
|
- lb\_frontend
|
||||||
|
- lb\_frontend\_bind
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -4,6 +4,7 @@ NAMESPACE=decort
|
|||||||
NAME=terraform-provider-decort
|
NAME=terraform-provider-decort
|
||||||
#BINARY=terraform-provider-${NAME}
|
#BINARY=terraform-provider-${NAME}
|
||||||
BINARY=${NAME}.exe
|
BINARY=${NAME}.exe
|
||||||
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=1.1
|
VERSION=1.1
|
||||||
#OS_ARCH=darwin_amd64
|
#OS_ARCH=darwin_amd64
|
||||||
@@ -14,8 +15,14 @@ default: install
|
|||||||
lint:
|
lint:
|
||||||
golangci-lint run --timeout 600s
|
golangci-lint run --timeout 600s
|
||||||
|
|
||||||
|
st:
|
||||||
|
go build -o ${BINARY} ${MAINPATH}
|
||||||
|
cp ${BINARY} ${WORKPATH}
|
||||||
|
rm ${BINARY}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o ${BINARY} ${MAINPATH}
|
go build -o ${BINARY} ${MAINPATH}
|
||||||
|
|
||||||
release:
|
release:
|
||||||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
|
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
|
||||||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
|
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -1,20 +1,25 @@
|
|||||||
# terraform-provider-decort
|
# terraform-provider-decort
|
||||||
|
|
||||||
Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT)
|
Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT)
|
||||||
|
|
||||||
Внимание: провайдер версии 3.x разработан для DECORT API 3.8.x.
|
Внимание: провайдер версии 3.x разработан для DECORT API 3.8.x.
|
||||||
Для более старых версий можно использовать:
|
Для более старых версий можно использовать:
|
||||||
|
|
||||||
- DECORT API 3.7.x - версия провайдера rc-1.25
|
- DECORT API 3.7.x - версия провайдера rc-1.25
|
||||||
- DECORT API 3.6.x - версия провайдера rc-1.10
|
- DECORT API 3.6.x - версия провайдера rc-1.10
|
||||||
- DECORT API до 3.6.0 - terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
- DECORT API до 3.6.0 - terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
||||||
|
|
||||||
## Режимы работы
|
## Режимы работы
|
||||||
|
|
||||||
Провайдер позволяет работать в двух режимах:
|
Провайдер позволяет работать в двух режимах:
|
||||||
|
|
||||||
- Режим пользователя,
|
- Режим пользователя,
|
||||||
- Режим администратора.
|
- Режим администратора.
|
||||||
Для переключения между режимами используйте флаг DECORT_ADMIN_MODE.
|
Для переключения между режимами используйте флаг DECORT_ADMIN_MODE.
|
||||||
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
|
||||||
## Возможности провайдера
|
## Возможности провайдера
|
||||||
|
|
||||||
- Работа с Compute instances,
|
- Работа с Compute instances,
|
||||||
- Работа с disks,
|
- Работа с disks,
|
||||||
- Работа с k8s,
|
- Работа с k8s,
|
||||||
@@ -29,18 +34,23 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
- Работа с vgpu,
|
- Работа с vgpu,
|
||||||
- Работа с bservice,
|
- Работа с bservice,
|
||||||
- Работа с extnets,
|
- Работа с extnets,
|
||||||
- Работа с locations.
|
- Работа с locations,
|
||||||
|
- Работа с load balancer.
|
||||||
|
|
||||||
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
|
||||||
## Начало
|
## Начало
|
||||||
|
|
||||||
Старт возможен по двум путям:
|
Старт возможен по двум путям:
|
||||||
|
|
||||||
1. Установка через собранные пакеты.
|
1. Установка через собранные пакеты.
|
||||||
2. Ручная установка.
|
2. Ручная установка.
|
||||||
|
|
||||||
### Установка через собранные пакеты.
|
### Установка через собранные пакеты.
|
||||||
|
|
||||||
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||||
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "oauth2"
|
authenticator = "oauth2"
|
||||||
@@ -51,45 +61,62 @@ provider "decort" {
|
|||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Выполните команду
|
3. Выполните команду
|
||||||
|
|
||||||
```
|
```
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
|
|
||||||
Провайдер автоматически будет установлен на ваш компьютер из terraform registry.
|
Провайдер автоматически будет установлен на ваш компьютер из terraform registry.
|
||||||
|
|
||||||
### Ручная установка
|
### Ручная установка
|
||||||
|
|
||||||
1. Скачайте и установите Go по ссылке: https://go.dev/dl/
|
1. Скачайте и установите Go по ссылке: https://go.dev/dl/
|
||||||
2. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
2. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||||
3. Склонируйте репозиторий с провайдером, выполнив команду:
|
3. Склонируйте репозиторий с провайдером, выполнив команду:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/rudecs/terraform-provider-decort.git
|
git clone https://github.com/rudecs/terraform-provider-decort.git
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Перейдите в скачанную папку с провайдером и выполните команду
|
4. Перейдите в скачанную папку с провайдером и выполните команду
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -o terraform-provider-decort
|
go build -o terraform-provider-decort
|
||||||
```
|
```
|
||||||
|
|
||||||
Если вы знаете как устроен _makefile_, то можно изменить в файле `Makefile` параметры под вашу ОС и выполнить команду
|
Если вы знаете как устроен _makefile_, то можно изменить в файле `Makefile` параметры под вашу ОС и выполнить команду
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Полученный файл необходимо поместить:
|
5. Полученный файл необходимо поместить:
|
||||||
Linux:
|
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.
|
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
|
||||||
Где:
|
Где:
|
||||||
|
|
||||||
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online
|
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online
|
||||||
- namespace - пространство имен хоста, например decort
|
- namespace - пространство имен хоста, например decort
|
||||||
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
||||||
- version - версия провайдера, например 1.2
|
- version - версия провайдера, например 1.2
|
||||||
- target - версия ОС, например windows_amd64
|
- target - версия ОС, например windows_amd64
|
||||||
|
|
||||||
6. После этого, создайте файл `main.tf`.
|
6. После этого, создайте файл `main.tf`.
|
||||||
7. Добавьте в него следующий блок
|
7. Добавьте в него следующий блок
|
||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
@@ -100,18 +127,22 @@ terraform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
В поле `version` указывается версия провайдера.
|
В поле `version` указывается версия провайдера.
|
||||||
Обязательный параметр
|
Обязательный параметр
|
||||||
Тип поля - строка
|
Тип поля - строка
|
||||||
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
|
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
|
||||||
|
|
||||||
В поле `source` помещается путь до репозитория с версией вида:
|
В поле `source` помещается путь до репозитория с версией вида:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
${host_name}/${namespace}/${type}
|
${host_name}/${namespace}/${type}
|
||||||
```
|
```
|
||||||
|
|
||||||
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
||||||
|
|
||||||
8. В консоле выполнить команду
|
8. В консоле выполнить команду
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
@@ -121,11 +152,14 @@ terraform init
|
|||||||
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
||||||
|
|
||||||
## Примеры работы
|
## Примеры работы
|
||||||
|
|
||||||
Примеры работы можно найти:
|
Примеры работы можно найти:
|
||||||
|
|
||||||
- На вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
- На вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
- В папке `samples`
|
- В папке `samples`
|
||||||
|
|
||||||
Схемы к terraform'у доступны:
|
Схемы к terraform'у доступны:
|
||||||
|
|
||||||
- В папке `docs`
|
- В папке `docs`
|
||||||
|
|
||||||
Хорошей работы!
|
Хорошей работы!
|
||||||
|
|||||||
43
README_EN.md
43
README_EN.md
@@ -1,20 +1,24 @@
|
|||||||
# terraform-provider-decort
|
# terraform-provider-decort
|
||||||
|
|
||||||
Terraform provider for Digital Energy Cloud Orchestration Technology (DECORT) platform
|
Terraform provider for Digital Energy Cloud Orchestration Technology (DECORT) platform
|
||||||
|
|
||||||
NOTE: provider 3.x is designed for DECORT API 3.8.x. For older API versions please use:
|
NOTE: provider 3.x is designed for DECORT API 3.8.x. For older API versions please use:
|
||||||
|
|
||||||
- DECORT API 3.7.x versions - provider verion rc-1.25
|
- DECORT API 3.7.x versions - provider verion rc-1.25
|
||||||
- DECORT API 3.6.x versions - provider version rc-1.10
|
- DECORT API 3.6.x versions - provider version rc-1.10
|
||||||
- DECORT API versions prior to 3.6.0 - Terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
- DECORT API versions prior to 3.6.0 - Terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
||||||
|
|
||||||
## Working modes
|
## Working modes
|
||||||
|
|
||||||
The provider support two working modes:
|
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://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Work with Compute instances,
|
- Work with Compute instances,
|
||||||
- Work with disks,
|
- Work with disks,
|
||||||
- Work with k8s,
|
- Work with k8s,
|
||||||
@@ -29,21 +33,25 @@ See user guide at https://github.com/rudecs/terraform-provider-decort/wiki
|
|||||||
- Work with vgpu,
|
- Work with vgpu,
|
||||||
- Work with bservice,
|
- Work with bservice,
|
||||||
- Work with extnets,
|
- Work with extnets,
|
||||||
- Work with locations.
|
- Work with locations,
|
||||||
|
- Work with load balancers.
|
||||||
|
|
||||||
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://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
|
||||||
|
|
||||||
## Get Started
|
## Get Started
|
||||||
|
|
||||||
Two ways for starting:
|
Two ways for starting:
|
||||||
|
|
||||||
1. Installing via binary packages
|
1. Installing via binary packages
|
||||||
2. Manual installing
|
2. Manual installing
|
||||||
|
|
||||||
### Installing via binary packages
|
### Installing via binary packages
|
||||||
|
|
||||||
1. Download and install terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
1. Download and install terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||||
2. Create a file `main.tf` and add to it next section.
|
2. Create a file `main.tf` and add to it next section.
|
||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "oauth2"
|
authenticator = "oauth2"
|
||||||
@@ -54,45 +62,62 @@ provider "decort" {
|
|||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Execute next command
|
3. Execute next command
|
||||||
|
|
||||||
```
|
```
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
|
|
||||||
The Provider will automatically install on your computer from the terrafrom registry.
|
The Provider will automatically install on your computer from the terrafrom registry.
|
||||||
|
|
||||||
### Manual installing
|
### Manual installing
|
||||||
|
|
||||||
1. Download and install Go Programming Language: https://go.dev/dl/
|
1. Download and install Go Programming Language: https://go.dev/dl/
|
||||||
2. Download and install terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
2. Download and install terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||||
3. Clone provider's repo:
|
3. Clone provider's repo:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/rudecs/terraform-provider-decort.git
|
git clone https://github.com/rudecs/terraform-provider-decort.git
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Change directory to clone provider's and execute next command
|
4. Change directory to clone provider's and execute next command
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -o terraform-provider-decort
|
go build -o terraform-provider-decort
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have experience with _makefile_, you can change `Makefile`'s paramters and execute next command
|
If you have experience with _makefile_, you can change `Makefile`'s paramters and execute next command
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Now move compilled file to:
|
5. Now move compilled file to:
|
||||||
Linux:
|
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}
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: for Windows OS `%APP_DATA%` is a cataloge, where will place terraform files.
|
NOTE: for Windows OS `%APP_DATA%` is a cataloge, where will place terraform files.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
- host_name - digitalenergy.online
|
- host_name - digitalenergy.online
|
||||||
- namespace - decort
|
- namespace - decort
|
||||||
- type - decort
|
- type - decort
|
||||||
- version - 1.2
|
- version - 1.2
|
||||||
- target - windows_amd64
|
- target - windows_amd64
|
||||||
|
|
||||||
6. After all, create a file `main.tf`.
|
6. After all, create a file `main.tf`.
|
||||||
7. Add to the file next code section
|
7. Add to the file next code section
|
||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
@@ -103,18 +128,22 @@ terraform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`version`- field for provider's version
|
`version`- field for provider's version
|
||||||
Required
|
Required
|
||||||
String
|
String
|
||||||
Note: Versions in code section and in a repository must be equal!
|
Note: Versions in code section and in a repository must be equal!
|
||||||
|
|
||||||
`source` - path to repository with provider's version
|
`source` - path to repository with provider's version
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
${host_name}/${namespace}/${type}
|
${host_name}/${namespace}/${type}
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: all paramters must be equal to the repository path!
|
NOTE: all paramters must be equal to the repository path!
|
||||||
|
|
||||||
8. Execute command in your terminal
|
8. Execute command in your terminal
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
terraform init
|
terraform init
|
||||||
```
|
```
|
||||||
@@ -124,10 +153,12 @@ terraform init
|
|||||||
More details about the provider's building process: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
More details about the provider's building process: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
||||||
|
|
||||||
## Examples and Samples
|
## Examples and Samples
|
||||||
|
|
||||||
- Examples: https://github.com/rudecs/terraform-provider-decort/wiki
|
- Examples: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
- Samples: see in repository `samples`
|
- Samples: see in repository `samples`
|
||||||
|
|
||||||
Terraform schemas in:
|
Terraform schemas in:
|
||||||
|
|
||||||
- See in repository `docs`
|
- See in repository `docs`
|
||||||
|
|
||||||
Good work!
|
Good work!
|
||||||
|
|||||||
167
docs/data-sources/lb.md
Normal file
167
docs/data-sources/lb.md
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb Data Source - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `lb_id` (Number)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `backends` (List of Object) (see [below for nested schema](#nestedatt--backends))
|
||||||
|
- `created_by` (String)
|
||||||
|
- `created_time` (Number)
|
||||||
|
- `deleted_by` (String)
|
||||||
|
- `deleted_time` (Number)
|
||||||
|
- `desc` (String)
|
||||||
|
- `dp_api_user` (String)
|
||||||
|
- `extnet_id` (Number)
|
||||||
|
- `frontends` (List of Object) (see [below for nested schema](#nestedatt--frontends))
|
||||||
|
- `gid` (Number)
|
||||||
|
- `guid` (Number)
|
||||||
|
- `ha_mode` (Boolean)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
- `image_id` (Number)
|
||||||
|
- `milestones` (Number)
|
||||||
|
- `name` (String)
|
||||||
|
- `primary_node` (List of Object) (see [below for nested schema](#nestedatt--primary_node))
|
||||||
|
- `rg_id` (Number)
|
||||||
|
- `rg_name` (String)
|
||||||
|
- `secondary_node` (List of Object) (see [below for nested schema](#nestedatt--secondary_node))
|
||||||
|
- `status` (String)
|
||||||
|
- `tech_status` (String)
|
||||||
|
- `updated_by` (String)
|
||||||
|
- `updated_time` (Number)
|
||||||
|
- `vins_id` (Number)
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `default` (String)
|
||||||
|
- `read` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--backends"></a>
|
||||||
|
### Nested Schema for `backends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `algorithm` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--server_default_settings))
|
||||||
|
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--server_default_settings"></a>
|
||||||
|
### Nested Schema for `backends.server_default_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--servers"></a>
|
||||||
|
### Nested Schema for `backends.servers`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `check` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers--server_settings))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--servers--server_settings"></a>
|
||||||
|
### Nested Schema for `backends.servers.server_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--frontends"></a>
|
||||||
|
### Nested Schema for `frontends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend` (String)
|
||||||
|
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--frontends--bindings))
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--frontends--bindings"></a>
|
||||||
|
### Nested Schema for `frontends.bindings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--primary_node"></a>
|
||||||
|
### Nested Schema for `primary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--secondary_node"></a>
|
||||||
|
### Nested Schema for `secondary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
175
docs/data-sources/lb_list.md
Normal file
175
docs/data-sources/lb_list.md
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_list Data Source - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_list (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `includedeleted` (Boolean)
|
||||||
|
- `page` (Number)
|
||||||
|
- `size` (Number)
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
- `items` (List of Object) (see [below for nested schema](#nestedatt--items))
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `default` (String)
|
||||||
|
- `read` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--items"></a>
|
||||||
|
### Nested Schema for `items`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backends` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends))
|
||||||
|
- `created_by` (String)
|
||||||
|
- `created_time` (Number)
|
||||||
|
- `deleted_by` (String)
|
||||||
|
- `deleted_time` (Number)
|
||||||
|
- `desc` (String)
|
||||||
|
- `dp_api_password` (String)
|
||||||
|
- `dp_api_user` (String)
|
||||||
|
- `extnet_id` (Number)
|
||||||
|
- `frontends` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends))
|
||||||
|
- `gid` (Number)
|
||||||
|
- `guid` (Number)
|
||||||
|
- `ha_mode` (Boolean)
|
||||||
|
- `image_id` (Number)
|
||||||
|
- `lb_id` (Number)
|
||||||
|
- `milestones` (Number)
|
||||||
|
- `name` (String)
|
||||||
|
- `primary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--primary_node))
|
||||||
|
- `rg_id` (Number)
|
||||||
|
- `rg_name` (String)
|
||||||
|
- `secondary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--secondary_node))
|
||||||
|
- `status` (String)
|
||||||
|
- `tech_status` (String)
|
||||||
|
- `updated_by` (String)
|
||||||
|
- `updated_time` (Number)
|
||||||
|
- `vins_id` (Number)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends"></a>
|
||||||
|
### Nested Schema for `items.backends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `algorithm` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--server_default_settings))
|
||||||
|
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--server_default_settings"></a>
|
||||||
|
### Nested Schema for `items.backends.server_default_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--servers"></a>
|
||||||
|
### Nested Schema for `items.backends.servers`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `check` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers--server_settings))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--servers--server_settings"></a>
|
||||||
|
### Nested Schema for `items.backends.servers.server_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--frontends"></a>
|
||||||
|
### Nested Schema for `items.frontends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend` (String)
|
||||||
|
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends--bindings))
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--frontends--bindings"></a>
|
||||||
|
### Nested Schema for `items.frontends.bindings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--primary_node"></a>
|
||||||
|
### Nested Schema for `items.primary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--secondary_node"></a>
|
||||||
|
### Nested Schema for `items.secondary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
174
docs/data-sources/lb_list_deleted.md
Normal file
174
docs/data-sources/lb_list_deleted.md
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_list_deleted Data Source - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_list_deleted (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `page` (Number)
|
||||||
|
- `size` (Number)
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
- `items` (List of Object) (see [below for nested schema](#nestedatt--items))
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `default` (String)
|
||||||
|
- `read` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--items"></a>
|
||||||
|
### Nested Schema for `items`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backends` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends))
|
||||||
|
- `created_by` (String)
|
||||||
|
- `created_time` (Number)
|
||||||
|
- `deleted_by` (String)
|
||||||
|
- `deleted_time` (Number)
|
||||||
|
- `desc` (String)
|
||||||
|
- `dp_api_password` (String)
|
||||||
|
- `dp_api_user` (String)
|
||||||
|
- `extnet_id` (Number)
|
||||||
|
- `frontends` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends))
|
||||||
|
- `gid` (Number)
|
||||||
|
- `guid` (Number)
|
||||||
|
- `ha_mode` (Boolean)
|
||||||
|
- `image_id` (Number)
|
||||||
|
- `lb_id` (Number)
|
||||||
|
- `milestones` (Number)
|
||||||
|
- `name` (String)
|
||||||
|
- `primary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--primary_node))
|
||||||
|
- `rg_id` (Number)
|
||||||
|
- `rg_name` (String)
|
||||||
|
- `secondary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--secondary_node))
|
||||||
|
- `status` (String)
|
||||||
|
- `tech_status` (String)
|
||||||
|
- `updated_by` (String)
|
||||||
|
- `updated_time` (Number)
|
||||||
|
- `vins_id` (Number)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends"></a>
|
||||||
|
### Nested Schema for `items.backends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `algorithm` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--server_default_settings))
|
||||||
|
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--server_default_settings"></a>
|
||||||
|
### Nested Schema for `items.backends.server_default_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--servers"></a>
|
||||||
|
### Nested Schema for `items.backends.servers`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `check` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers--server_settings))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--backends--servers--server_settings"></a>
|
||||||
|
### Nested Schema for `items.backends.servers.server_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--frontends"></a>
|
||||||
|
### Nested Schema for `items.frontends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend` (String)
|
||||||
|
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends--bindings))
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--frontends--bindings"></a>
|
||||||
|
### Nested Schema for `items.frontends.bindings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--primary_node"></a>
|
||||||
|
### Nested Schema for `items.primary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--items--secondary_node"></a>
|
||||||
|
### Nested Schema for `items.secondary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
87
docs/resources/image_virtual.md
Normal file
87
docs/resources/image_virtual.md
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_image_virtual Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_image_virtual (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `link_to` (Number) ID of real image to link this virtual image to upon creation
|
||||||
|
- `name` (String) Name of the rescue disk
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `permanently` (Boolean) whether to completely delete the image
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `account_id` (Number)
|
||||||
|
- `acl` (String)
|
||||||
|
- `architecture` (String)
|
||||||
|
- `boot_type` (String)
|
||||||
|
- `bootable` (Boolean)
|
||||||
|
- `ckey` (String)
|
||||||
|
- `compute_ci_id` (Number)
|
||||||
|
- `deleted_time` (String)
|
||||||
|
- `desc` (String)
|
||||||
|
- `drivers` (List of String)
|
||||||
|
- `enabled` (Boolean)
|
||||||
|
- `gid` (Number)
|
||||||
|
- `guid` (Number)
|
||||||
|
- `history` (List of Object) (see [below for nested schema](#nestedatt--history))
|
||||||
|
- `hot_resize` (Boolean)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
- `image_id` (Number) Image id
|
||||||
|
- `image_name` (String)
|
||||||
|
- `last_modified` (Number)
|
||||||
|
- `milestones` (Number)
|
||||||
|
- `password` (String)
|
||||||
|
- `pool_name` (String)
|
||||||
|
- `provider_name` (String)
|
||||||
|
- `purge_attempts` (Number)
|
||||||
|
- `res_id` (String)
|
||||||
|
- `rescuecd` (Boolean)
|
||||||
|
- `sep_id` (Number)
|
||||||
|
- `shared_with` (List of Number)
|
||||||
|
- `size` (Number)
|
||||||
|
- `status` (String)
|
||||||
|
- `tech_status` (String)
|
||||||
|
- `type` (String)
|
||||||
|
- `unc_path` (String)
|
||||||
|
- `username` (String)
|
||||||
|
- `version` (String)
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--history"></a>
|
||||||
|
### Nested Schema for `history`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
- `id` (Number)
|
||||||
|
- `timestamp` (Number)
|
||||||
|
|
||||||
|
|
||||||
@@ -29,8 +29,12 @@ description: |-
|
|||||||
|
|
||||||
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
||||||
- `description` (String) Optional text description of this compute instance.
|
- `description` (String) Optional text description of this compute instance.
|
||||||
|
- `detach_disks` (Boolean)
|
||||||
- `extra_disks` (Set of Number) Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.
|
- `extra_disks` (Set of Number) Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.
|
||||||
|
- `ipa_type` (String) compute purpose
|
||||||
|
- `is` (String) system name
|
||||||
- `network` (Block Set, Max: 8) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network))
|
- `network` (Block Set, Max: 8) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network))
|
||||||
|
- `permanently` (Boolean)
|
||||||
- `pool` (String) Pool to use if sepId is set, can be also empty if needed to be chosen by system.
|
- `pool` (String) Pool to use if sepId is set, can be also empty if needed to be chosen by system.
|
||||||
- `sep_id` (Number) ID of SEP to create bootDisk on. Uses image's sepId if not set.
|
- `sep_id` (Number) ID of SEP to create bootDisk on. Uses image's sepId if not set.
|
||||||
- `started` (Boolean) Is compute started.
|
- `started` (Boolean) Is compute started.
|
||||||
|
|||||||
176
docs/resources/lb.md
Normal file
176
docs/resources/lb.md
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `extnet_id` (Number)
|
||||||
|
- `name` (String)
|
||||||
|
- `rg_id` (Number)
|
||||||
|
- `start` (Boolean)
|
||||||
|
- `vins_id` (Number)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `config_reset` (Boolean)
|
||||||
|
- `desc` (String)
|
||||||
|
- `enable` (Boolean)
|
||||||
|
- `permanently` (Boolean)
|
||||||
|
- `restart` (Boolean)
|
||||||
|
- `restore` (Boolean)
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `backends` (List of Object) (see [below for nested schema](#nestedatt--backends))
|
||||||
|
- `created_by` (String)
|
||||||
|
- `created_time` (Number)
|
||||||
|
- `deleted_by` (String)
|
||||||
|
- `deleted_time` (Number)
|
||||||
|
- `dp_api_user` (String)
|
||||||
|
- `frontends` (List of Object) (see [below for nested schema](#nestedatt--frontends))
|
||||||
|
- `gid` (Number)
|
||||||
|
- `guid` (Number)
|
||||||
|
- `ha_mode` (Boolean)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
- `image_id` (Number)
|
||||||
|
- `lb_id` (Number)
|
||||||
|
- `milestones` (Number)
|
||||||
|
- `primary_node` (List of Object) (see [below for nested schema](#nestedatt--primary_node))
|
||||||
|
- `rg_name` (String)
|
||||||
|
- `secondary_node` (List of Object) (see [below for nested schema](#nestedatt--secondary_node))
|
||||||
|
- `status` (String)
|
||||||
|
- `tech_status` (String)
|
||||||
|
- `updated_by` (String)
|
||||||
|
- `updated_time` (Number)
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--backends"></a>
|
||||||
|
### Nested Schema for `backends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `algorithm` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--server_default_settings))
|
||||||
|
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--server_default_settings"></a>
|
||||||
|
### Nested Schema for `backends.server_default_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--servers"></a>
|
||||||
|
### Nested Schema for `backends.servers`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `check` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers--server_settings))
|
||||||
|
|
||||||
|
<a id="nestedobjatt--backends--servers--server_settings"></a>
|
||||||
|
### Nested Schema for `backends.servers.server_settings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `guid` (String)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--frontends"></a>
|
||||||
|
### Nested Schema for `frontends`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend` (String)
|
||||||
|
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--frontends--bindings))
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--frontends--bindings"></a>
|
||||||
|
### Nested Schema for `frontends.bindings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--primary_node"></a>
|
||||||
|
### Nested Schema for `primary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--secondary_node"></a>
|
||||||
|
### Nested Schema for `secondary_node`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `backend_ip` (String)
|
||||||
|
- `compute_id` (Number)
|
||||||
|
- `frontend_ip` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `mgmt_ip` (String)
|
||||||
|
- `network_id` (Number)
|
||||||
|
|
||||||
|
|
||||||
88
docs/resources/lb_backend.md
Normal file
88
docs/resources/lb_backend.md
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_backend Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_backend (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||||
|
- `name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `algorithm` (String)
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `servers` (Block List) (see [below for nested schema](#nestedblock--servers))
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
|
||||||
|
<a id="nestedblock--servers"></a>
|
||||||
|
### Nested Schema for `servers`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `check` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
- `server_settings` (Block List) (see [below for nested schema](#nestedblock--servers--server_settings))
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
|
||||||
|
<a id="nestedblock--servers--server_settings"></a>
|
||||||
|
### Nested Schema for `servers.server_settings`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
55
docs/resources/lb_backend_server.md
Normal file
55
docs/resources/lb_backend_server.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_backend_server Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_backend_server (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `address` (String) IP address of the server.
|
||||||
|
- `backend_name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||||
|
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||||
|
- `name` (String) Must be unique among all servers defined for this backend - name of the server definition to add.
|
||||||
|
- `port` (Number) Port number on the server
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `check` (String) set to disabled if this server should be used regardless of its state.
|
||||||
|
- `downinter` (Number)
|
||||||
|
- `fall` (Number)
|
||||||
|
- `inter` (Number)
|
||||||
|
- `maxconn` (Number)
|
||||||
|
- `maxqueue` (Number)
|
||||||
|
- `rise` (Number)
|
||||||
|
- `slowstart` (Number)
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
- `weight` (Number)
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
56
docs/resources/lb_frontend.md
Normal file
56
docs/resources/lb_frontend.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_frontend Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_frontend (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `backend_name` (String)
|
||||||
|
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||||
|
- `name` (String)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `bindings` (List of Object) (see [below for nested schema](#nestedatt--bindings))
|
||||||
|
- `guid` (String)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--bindings"></a>
|
||||||
|
### Nested Schema for `bindings`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `guid` (String)
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
|
||||||
46
docs/resources/lb_frontend_bind.md
Normal file
46
docs/resources/lb_frontend_bind.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_lb_frontend_bind Resource - decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_lb_frontend_bind (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `address` (String)
|
||||||
|
- `frontend_name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||||
|
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||||
|
- `name` (String)
|
||||||
|
- `port` (Number)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `guid` (String)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `create` (String)
|
||||||
|
- `default` (String)
|
||||||
|
- `delete` (String)
|
||||||
|
- `read` (String)
|
||||||
|
- `update` (String)
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet"
|
"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/image"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"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/locations"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
|
"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/snapshot"
|
||||||
@@ -69,6 +70,9 @@ func NewDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||||
"decort_image_list": image.DataSourceImageList(),
|
"decort_image_list": image.DataSourceImageList(),
|
||||||
"decort_image": image.DataSourceImage(),
|
"decort_image": image.DataSourceImage(),
|
||||||
|
"decort_lb": lb.DataSourceLB(),
|
||||||
|
"decort_lb_list": lb.DataSourceLBList(),
|
||||||
|
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||||
// "decort_pfw": dataSourcePfw(),
|
// "decort_pfw": dataSourcePfw(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
|
"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/k8s"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"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/pfw"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
|
"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/snapshot"
|
||||||
@@ -35,18 +36,23 @@ import (
|
|||||||
|
|
||||||
func NewRersourcesMap() map[string]*schema.Resource {
|
func NewRersourcesMap() map[string]*schema.Resource {
|
||||||
return map[string]*schema.Resource{
|
return map[string]*schema.Resource{
|
||||||
"decort_resgroup": rg.ResourceResgroup(),
|
"decort_resgroup": rg.ResourceResgroup(),
|
||||||
"decort_kvmvm": kvmvm.ResourceCompute(),
|
"decort_kvmvm": kvmvm.ResourceCompute(),
|
||||||
"decort_disk": disks.ResourceDisk(),
|
"decort_disk": disks.ResourceDisk(),
|
||||||
"decort_vins": vins.ResourceVins(),
|
"decort_vins": vins.ResourceVins(),
|
||||||
"decort_pfw": pfw.ResourcePfw(),
|
"decort_pfw": pfw.ResourcePfw(),
|
||||||
"decort_k8s": k8s.ResourceK8s(),
|
"decort_k8s": k8s.ResourceK8s(),
|
||||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||||
"decort_account": account.ResourceAccount(),
|
"decort_account": account.ResourceAccount(),
|
||||||
"decort_bservice": bservice.ResourceBasicService(),
|
"decort_bservice": bservice.ResourceBasicService(),
|
||||||
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
||||||
"decort_image": image.ResourceImage(),
|
"decort_image": image.ResourceImage(),
|
||||||
"decort_image_virtual": image.ResourceImageVirtual(),
|
"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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ func ResourceAccount() *schema.Resource {
|
|||||||
DeleteContext: resourceAccountDelete,
|
DeleteContext: resourceAccountDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ func ResourceBasicService() *schema.Resource {
|
|||||||
DeleteContext: resourceBasicServiceDelete,
|
DeleteContext: resourceBasicServiceDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -616,7 +616,7 @@ func ResourceBasicServiceGroup() *schema.Resource {
|
|||||||
DeleteContext: resourceBasicServiceGroupDelete,
|
DeleteContext: resourceBasicServiceGroupDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
|
|||||||
DeleteContext: resourceDiskDelete,
|
DeleteContext: resourceDiskDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
|||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
const imageCreateAPI = "/restmachine/cloudapi/image/createImage"
|
const imageCreateAPI = "/restmachine/cloudapi/image/create"
|
||||||
const imageCreateVirtualAPI = "/restmachine/cloudapi/image/createVirtual"
|
const imageCreateVirtualAPI = "/restmachine/cloudapi/image/createVirtual"
|
||||||
const imageGetAPI = "/restmachine/cloudapi/image/get"
|
const imageGetAPI = "/restmachine/cloudapi/image/get"
|
||||||
const imageListGetAPI = "/restmachine/cloudapi/image/list"
|
const imageListGetAPI = "/restmachine/cloudapi/image/list"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ package image
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -94,11 +95,25 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
urlValues.Add("architecture", architecture.(string))
|
urlValues.Add("architecture", architecture.(string))
|
||||||
}
|
}
|
||||||
|
/* uncomment then OK
|
||||||
imageId, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
imageId, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
//innovation
|
||||||
|
res, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
i := make([]interface{}, 0)
|
||||||
|
err = json.Unmarshal([]byte(res), &i)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
imageId := strconv.Itoa(int(i[1].(float64)))
|
||||||
|
// end innovation
|
||||||
|
|
||||||
d.SetId(imageId)
|
d.SetId(imageId)
|
||||||
d.Set("image_id", imageId)
|
d.Set("image_id", imageId)
|
||||||
@@ -229,7 +244,7 @@ func ResourceImage() *schema.Resource {
|
|||||||
DeleteContext: resourceImageDelete,
|
DeleteContext: resourceImageDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ func ResourceImageVirtual() *schema.Resource {
|
|||||||
DeleteContext: resourceImageDelete,
|
DeleteContext: resourceImageDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
|
|||||||
DeleteContext: resourceK8sDelete,
|
DeleteContext: resourceK8sDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
|
|||||||
DeleteContext: resourceK8sWgDelete,
|
DeleteContext: resourceK8sWgDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -44,3 +44,4 @@ const ComputeStopAPI = "/restmachine/cloudapi/compute/stop"
|
|||||||
const ComputeResizeAPI = "/restmachine/cloudapi/compute/resize"
|
const ComputeResizeAPI = "/restmachine/cloudapi/compute/resize"
|
||||||
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
|
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
|
||||||
const ComputeDeleteAPI = "/restmachine/cloudapi/compute/delete"
|
const ComputeDeleteAPI = "/restmachine/cloudapi/compute/delete"
|
||||||
|
const ComputeUpdateAPI = "/restmachine/cloudapi/compute/update"
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
urlValues.Add("pool", pool.(string))
|
urlValues.Add("pool", pool.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ipaType, ok := d.GetOk("ipa_type"); ok {
|
||||||
|
urlValues.Add("ipaType", ipaType.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if IS, ok := d.GetOk("is"); ok {
|
||||||
|
urlValues.Add("IS", IS.(string))
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sshKeysVal, sshKeysSet := d.GetOk("ssh_keys")
|
sshKeysVal, sshKeysSet := d.GetOk("ssh_keys")
|
||||||
if sshKeysSet {
|
if sshKeysSet {
|
||||||
@@ -287,6 +295,16 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange("description") || d.HasChange("name") {
|
||||||
|
updateParams := &url.Values{}
|
||||||
|
updateParams.Add("computeId", d.Id())
|
||||||
|
updateParams.Add("name", d.Get("name").(string))
|
||||||
|
updateParams.Add("desc", d.Get("description").(string))
|
||||||
|
if _, err := c.DecortAPICall(ctx, "POST", ComputeUpdateAPI, updateParams); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if d.HasChange("started") {
|
if d.HasChange("started") {
|
||||||
params := &url.Values{}
|
params := &url.Values{}
|
||||||
params.Add("computeId", d.Id())
|
params.Add("computeId", d.Id())
|
||||||
@@ -318,8 +336,8 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
params := &url.Values{}
|
params := &url.Values{}
|
||||||
params.Add("computeId", d.Id())
|
params.Add("computeId", d.Id())
|
||||||
params.Add("permanently", "1")
|
params.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
|
||||||
params.Add("detachDisks", "1")
|
params.Add("detachDisks", strconv.FormatBool(d.Get("detach_disks").(bool)))
|
||||||
|
|
||||||
if _, err := c.DecortAPICall(ctx, "POST", ComputeDeleteAPI, params); err != nil {
|
if _, err := c.DecortAPICall(ctx, "POST", ComputeDeleteAPI, params); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -338,7 +356,7 @@ func ResourceCompute() *schema.Resource {
|
|||||||
DeleteContext: resourceComputeDelete,
|
DeleteContext: resourceComputeDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
@@ -501,6 +519,26 @@ func ResourceCompute() *schema.Resource {
|
|||||||
Default: true,
|
Default: true,
|
||||||
Description: "Is compute started.",
|
Description: "Is compute started.",
|
||||||
},
|
},
|
||||||
|
"detach_disks": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
},
|
||||||
|
"permanently": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
},
|
||||||
|
"is": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "system name",
|
||||||
|
},
|
||||||
|
"ipa_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "compute purpose",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,12 +267,12 @@ func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
// and RG ID
|
// and RG ID
|
||||||
computeName, argSet := d.GetOk("name")
|
computeName, argSet := d.GetOk("name")
|
||||||
if !argSet {
|
if !argSet {
|
||||||
return "", fmt.Errorf("Cannot locate compute instance if name is empty and no compute ID specified")
|
return "", fmt.Errorf("cannot locate compute instance if name is empty and no compute ID specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
rgId, argSet := d.GetOk("rg_id")
|
rgId, argSet := d.GetOk("rg_id")
|
||||||
if !argSet {
|
if !argSet {
|
||||||
return "", fmt.Errorf("Cannot locate compute by name %s if no resource group ID is set", computeName.(string))
|
return "", fmt.Errorf("cannot locate compute by name %s if no resource group ID is set", computeName.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
urlValues.Add("rgId", fmt.Sprintf("%d", rgId))
|
urlValues.Add("rgId", fmt.Sprintf("%d", rgId))
|
||||||
|
|||||||
57
internal/service/cloudapi/lb/api.go
Normal file
57
internal/service/cloudapi/lb/api.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
const lbListAPI = "/restmachine/cloudapi/lb/list"
|
||||||
|
const lbListDeletedAPI = "/restmachine/cloudapi/lb/listDeleted"
|
||||||
|
const lbGetAPI = "/restmachine/cloudapi/lb/get"
|
||||||
|
const lbCreateAPI = "/restmachine/cloudapi/lb/create"
|
||||||
|
const lbDeleteAPI = "/restmachine/cloudapi/lb/delete"
|
||||||
|
const lbDisableAPI = "/restmachine/cloudapi/lb/disable"
|
||||||
|
const lbEnableAPI = "/restmachine/cloudapi/lb/enable"
|
||||||
|
const lbUpdateAPI = "/restmachine/cloudapi/lb/update"
|
||||||
|
const lbStartAPI = "/restmachine/cloudapi/lb/start"
|
||||||
|
const lbStopAPI = "/restmachine/cloudapi/lb/stop"
|
||||||
|
const lbRestartAPI = "/restmachine/cloudapi/lb/restart"
|
||||||
|
const lbRestoreAPI = "/restmachine/cloudapi/lb/restore"
|
||||||
|
const lbConfigResetAPI = "/restmachine/cloudapi/lb/configReset"
|
||||||
|
const lbBackendCreateAPI = "/restmachine/cloudapi/lb/backendCreate"
|
||||||
|
const lbBackendDeleteAPI = "/restmachine/cloudapi/lb/backendDelete"
|
||||||
|
const lbBackendUpdateAPI = "/restmachine/cloudapi/lb/backendUpdate"
|
||||||
|
const lbBackendServerAddAPI = "/restmachine/cloudapi/lb/backendServerAdd"
|
||||||
|
const lbBackendServerDeleteAPI = "/restmachine/cloudapi/lb/backendServerDelete"
|
||||||
|
const lbBackendServerUpdateAPI = "/restmachine/cloudapi/lb/backendServerUpdate"
|
||||||
|
const lbFrontendCreateAPI = "/restmachine/cloudapi/lb/frontendCreate"
|
||||||
|
const lbFrontendDeleteAPI = "/restmachine/cloudapi/lb/frontendDelete"
|
||||||
|
const lbFrontendBindAPI = "/restmachine/cloudapi/lb/frontendBind"
|
||||||
|
const lbFrontendBindDeleteAPI = "/restmachine/cloudapi/lb/frontendBindDelete"
|
||||||
|
const lbFrontendBindUpdateAPI = "/restmachine/cloudapi/lb/frontendBindingUpdate"
|
||||||
96
internal/service/cloudapi/lb/data_source_lb.go
Normal file
96
internal/service/cloudapi/lb/data_source_lb.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenLB(d *schema.ResourceData, lb *LoadBalancer) {
|
||||||
|
d.Set("ha_mode", lb.HAMode)
|
||||||
|
d.Set("backends", flattenLBBackends(lb.Backends))
|
||||||
|
d.Set("created_by", lb.CreatedBy)
|
||||||
|
d.Set("created_time", lb.CreatedTime)
|
||||||
|
d.Set("deleted_by", lb.DeletedBy)
|
||||||
|
d.Set("deleted_time", lb.DeletedTime)
|
||||||
|
d.Set("desc", lb.Description)
|
||||||
|
d.Set("dp_api_user", lb.DPAPIUser)
|
||||||
|
d.Set("extnet_id", lb.ExtnetId)
|
||||||
|
d.Set("frontends", flattenFrontends(lb.Frontends))
|
||||||
|
d.Set("gid", lb.GID)
|
||||||
|
d.Set("guid", lb.GUID)
|
||||||
|
d.Set("image_id", lb.ImageId)
|
||||||
|
d.Set("milestones", lb.Milestones)
|
||||||
|
d.Set("name", lb.Name)
|
||||||
|
d.Set("primary_node", flattenNode(lb.PrimaryNode))
|
||||||
|
d.Set("rg_id", lb.RGID)
|
||||||
|
d.Set("rg_name", lb.RGName)
|
||||||
|
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
|
||||||
|
d.Set("status", lb.Status)
|
||||||
|
d.Set("tech_status", lb.TechStatus)
|
||||||
|
d.Set("updated_by", lb.UpdatedBy)
|
||||||
|
d.Set("updated_time", lb.UpdatedTime)
|
||||||
|
d.Set("vins_id", lb.VinsId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.FormatUint(lb.ID, 10))
|
||||||
|
|
||||||
|
flattenLB(d, lb)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceLB() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceLBRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dsLBSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
103
internal/service/cloudapi/lb/data_source_lb_list.go
Normal file
103
internal/service/cloudapi/lb/data_source_lb_list.go
Normal 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>
|
||||||
|
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenLBList(lbl LBList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0, len(lbl))
|
||||||
|
for _, lb := range lbl {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"ha_mode": lb.HAMode,
|
||||||
|
"backends": flattenLBBackends(lb.Backends),
|
||||||
|
"created_by": lb.CreatedBy,
|
||||||
|
"created_time": lb.CreatedTime,
|
||||||
|
"deleted_by": lb.DeletedBy,
|
||||||
|
"deleted_time": lb.DeletedTime,
|
||||||
|
"desc": lb.Description,
|
||||||
|
"dp_api_user": lb.DPAPIUser,
|
||||||
|
"dp_api_password": lb.DPAPIPassword,
|
||||||
|
"extnet_id": lb.ExtnetId,
|
||||||
|
"frontends": flattenFrontends(lb.Frontends),
|
||||||
|
"gid": lb.GID,
|
||||||
|
"guid": lb.GUID,
|
||||||
|
"image_id": lb.ImageId,
|
||||||
|
"milestones": lb.Milestones,
|
||||||
|
"name": lb.Name,
|
||||||
|
"primary_node": flattenNode(lb.PrimaryNode),
|
||||||
|
"rg_id": lb.RGID,
|
||||||
|
"rg_name": lb.RGName,
|
||||||
|
"secondary_node": flattenNode(lb.SecondaryNode),
|
||||||
|
"status": lb.Status,
|
||||||
|
"tech_status": lb.TechStatus,
|
||||||
|
"updated_by": lb.UpdatedBy,
|
||||||
|
"updated_time": lb.UpdatedTime,
|
||||||
|
"vins_id": lb.VinsId,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenLBList(lbList))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceLBList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceLBListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dsLBListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
68
internal/service/cloudapi/lb/data_source_lb_list_deleted.go
Normal file
68
internal/service/cloudapi/lb/data_source_lb_list_deleted.go
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenLBList(lbList))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceLBListDeleted() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceLBListDeletedRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dsLBListDeletedSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
128
internal/service/cloudapi/lb/flattens.go
Normal file
128
internal/service/cloudapi/lb/flattens.go
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
func flattenNode(node Node) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0)
|
||||||
|
n := map[string]interface{}{
|
||||||
|
"backend_ip": node.BackendIp,
|
||||||
|
"compute_id": node.ComputeId,
|
||||||
|
"frontend_ip": node.FrontendIp,
|
||||||
|
"guid": node.GUID,
|
||||||
|
"mgmt_ip": node.MGMTIp,
|
||||||
|
"network_id": node.NetworkId,
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = append(temp, n)
|
||||||
|
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattendBindings(bs []Binding) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0, len(bs))
|
||||||
|
for _, b := range bs {
|
||||||
|
t := map[string]interface{}{
|
||||||
|
"address": b.Address,
|
||||||
|
"guid": b.GUID,
|
||||||
|
"name": b.Name,
|
||||||
|
"port": b.Port,
|
||||||
|
}
|
||||||
|
temp = append(temp, t)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenFrontends(fs []Frontend) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0, len(fs))
|
||||||
|
for _, f := range fs {
|
||||||
|
t := map[string]interface{}{
|
||||||
|
"backend": f.Backend,
|
||||||
|
"bindings": flattendBindings(f.Bindings),
|
||||||
|
"guid": f.GUID,
|
||||||
|
"name": f.Name,
|
||||||
|
}
|
||||||
|
temp = append(temp, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenServers(servers []Server) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0, len(servers))
|
||||||
|
for _, server := range servers {
|
||||||
|
t := map[string]interface{}{
|
||||||
|
"address": server.Address,
|
||||||
|
"check": server.Check,
|
||||||
|
"guid": server.GUID,
|
||||||
|
"name": server.Name,
|
||||||
|
"port": server.Port,
|
||||||
|
"server_settings": flattenServerSettings(server.ServerSettings),
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = append(temp, t)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenServerSettings(defSet ServerSettings) []map[string]interface{} {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"downinter": defSet.DownInter,
|
||||||
|
"fall": defSet.Fall,
|
||||||
|
"guid": defSet.GUID,
|
||||||
|
"inter": defSet.Inter,
|
||||||
|
"maxconn": defSet.MaxConn,
|
||||||
|
"maxqueue": defSet.MaxQueue,
|
||||||
|
"rise": defSet.Rise,
|
||||||
|
"slowstart": defSet.SlowStart,
|
||||||
|
"weight": defSet.Weight,
|
||||||
|
}
|
||||||
|
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenLBBackends(backends []Backend) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0, len(backends))
|
||||||
|
for _, item := range backends {
|
||||||
|
t := map[string]interface{}{
|
||||||
|
"algorithm": item.Algorithm,
|
||||||
|
"guid": item.GUID,
|
||||||
|
"name": item.Name,
|
||||||
|
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
|
||||||
|
"servers": flattenServers(item.Servers),
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = append(temp, t)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
101
internal/service/cloudapi/lb/lb_data_subresource.go
Normal file
101
internal/service/cloudapi/lb/lb_data_subresource.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func dsLBSchemaMake() map[string]*schema.Schema {
|
||||||
|
sch := createLBSchema()
|
||||||
|
sch["lb_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
return sch
|
||||||
|
}
|
||||||
|
|
||||||
|
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 0,
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 0,
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dsLBItemSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"includedeleted": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 0,
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 0,
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dsLBItemSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dsLBItemSchemaMake() map[string]*schema.Schema {
|
||||||
|
sch := createLBSchema()
|
||||||
|
sch["dp_api_password"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
}
|
||||||
|
return sch
|
||||||
|
}
|
||||||
91
internal/service/cloudapi/lb/lb_resource_subresource.go
Normal file
91
internal/service/cloudapi/lb/lb_resource_subresource.go
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||||
|
sch := createLBSchema()
|
||||||
|
sch["rg_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
sch["name"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["extnet_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["vins_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
sch["start"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Required: true,
|
||||||
|
}
|
||||||
|
sch["desc"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["enable"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["restart"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["restore"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["config_reset"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
sch["permanently"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
return sch
|
||||||
|
}
|
||||||
367
internal/service/cloudapi/lb/lb_schema.go
Normal file
367
internal/service/cloudapi/lb/lb_schema.go
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func createLBSchema() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"ha_mode": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"backends": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"algorithm": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"server_default_settings": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"downinter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"fall": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"inter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxconn": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxqueue": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rise": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"slowstart": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"servers": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"check": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"server_settings": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"downinter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"fall": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"inter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxconn": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxqueue": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rise": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"slowstart": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"dp_api_user": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extnet_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"frontends": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"backend": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"bindings": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"image_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"primary_node": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"backend_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"frontend_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"mgmt_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"secondary_node": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"backend_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"frontend_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"mgmt_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
120
internal/service/cloudapi/lb/models.go
Normal file
120
internal/service/cloudapi/lb/models.go
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
type LoadBalancer struct {
|
||||||
|
HAMode bool `json:"HAmode"`
|
||||||
|
ACL interface{} `json:"acl"`
|
||||||
|
Backends []Backend `json:"backends"`
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
DPAPIUser string `json:"dpApiUser"`
|
||||||
|
ExtnetId uint64 `json:"extnetId"`
|
||||||
|
Frontends []Frontend `json:"frontends"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
ImageId uint64 `json:"imageId"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
PrimaryNode Node `json:"primaryNode"`
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
SecondaryNode Node `json:"secondaryNode"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
VinsId uint64 `json:"vinsId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoadBalancerDetailed struct {
|
||||||
|
DPAPIPassword string `json:"dpApiPassword"`
|
||||||
|
LoadBalancer
|
||||||
|
}
|
||||||
|
|
||||||
|
type Backend struct {
|
||||||
|
Algorithm string `json:"algorithm"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
ServerDefaultSettings ServerSettings `json:"serverDefaultSettings"`
|
||||||
|
Servers []Server `json:"servers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LBList []LoadBalancerDetailed
|
||||||
|
|
||||||
|
type ServerSettings struct {
|
||||||
|
Inter uint64 `json:"inter"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
DownInter uint64 `json:"downinter"`
|
||||||
|
Rise uint `json:"rise"`
|
||||||
|
Fall uint `json:"fall"`
|
||||||
|
SlowStart uint64 `json:"slowstart"`
|
||||||
|
MaxConn uint `json:"maxconn"`
|
||||||
|
MaxQueue uint `json:"maxqueue"`
|
||||||
|
Weight uint `json:"weight"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
Address string `json:"address"`
|
||||||
|
Check string `json:"check"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Port uint `json:"port"`
|
||||||
|
ServerSettings ServerSettings `json:"serverSettings"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Node struct {
|
||||||
|
BackendIp string `json:"backendIp"`
|
||||||
|
ComputeId uint64 `json:"computeId"`
|
||||||
|
FrontendIp string `json:"frontendIp"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
MGMTIp string `json:"mgmtIp"`
|
||||||
|
NetworkId uint64 `json:"networkId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Frontend struct {
|
||||||
|
Backend string `json:"backend"`
|
||||||
|
Bindings []Binding `json:"bindings"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Binding struct {
|
||||||
|
Address string `json:"address"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Port uint `json:"port"`
|
||||||
|
}
|
||||||
281
internal/service/cloudapi/lb/resource_lb.go
Normal file
281
internal/service/cloudapi/lb/resource_lb.go
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBCreate")
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("name", d.Get("name").(string))
|
||||||
|
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
|
||||||
|
urlValues.Add("extnetId", strconv.Itoa(d.Get("extnet_id").(int)))
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
urlValues.Add("start", strconv.FormatBool((d.Get("start").(bool))))
|
||||||
|
|
||||||
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
|
urlValues.Add("desc", desc.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
lbId, err := c.DecortAPICall(ctx, "POST", lbCreateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(lbId)
|
||||||
|
d.Set("lb_id", lbId)
|
||||||
|
|
||||||
|
_, err = utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics := resourceLBRead(ctx, d, m)
|
||||||
|
if diagnostics != nil {
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
|
||||||
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
|
api := lbDisableAPI
|
||||||
|
if enable.(bool) {
|
||||||
|
api = lbEnableAPI
|
||||||
|
}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBRead")
|
||||||
|
|
||||||
|
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if lb == nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("ha_mode", lb.HAMode)
|
||||||
|
d.Set("backends", flattenLBBackends(lb.Backends))
|
||||||
|
d.Set("created_by", lb.CreatedBy)
|
||||||
|
d.Set("created_time", lb.CreatedTime)
|
||||||
|
d.Set("deleted_by", lb.DeletedBy)
|
||||||
|
d.Set("deleted_time", lb.DeletedTime)
|
||||||
|
d.Set("desc", lb.Description)
|
||||||
|
d.Set("dp_api_user", lb.DPAPIUser)
|
||||||
|
d.Set("extnet_id", lb.ExtnetId)
|
||||||
|
d.Set("frontends", flattenFrontends(lb.Frontends))
|
||||||
|
d.Set("gid", lb.GID)
|
||||||
|
d.Set("guid", lb.GUID)
|
||||||
|
d.Set("lb_id", lb.ID)
|
||||||
|
d.Set("image_id", lb.ImageId)
|
||||||
|
d.Set("milestones", lb.Milestones)
|
||||||
|
d.Set("name", lb.Name)
|
||||||
|
d.Set("primary_node", flattenNode(lb.PrimaryNode))
|
||||||
|
d.Set("rg_id", lb.RGID)
|
||||||
|
d.Set("rg_name", lb.RGName)
|
||||||
|
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
|
||||||
|
d.Set("status", lb.Status)
|
||||||
|
d.Set("tech_status", lb.TechStatus)
|
||||||
|
d.Set("updated_by", lb.UpdatedBy)
|
||||||
|
d.Set("updated_time", lb.UpdatedTime)
|
||||||
|
d.Set("vins_id", lb.VinsId)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBDelete")
|
||||||
|
|
||||||
|
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
|
if lb == nil {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
|
urlValues.Add("permanently", strconv.FormatBool(permanently.(bool)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", lbDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBEdit")
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
if d.HasChange("enable") {
|
||||||
|
api := lbDisableAPI
|
||||||
|
enable := d.Get("enable").(bool)
|
||||||
|
if enable {
|
||||||
|
api = lbEnableAPI
|
||||||
|
}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("start") {
|
||||||
|
api := lbStopAPI
|
||||||
|
start := d.Get("start").(bool)
|
||||||
|
if start {
|
||||||
|
api = lbStartAPI
|
||||||
|
}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("desc") {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("desc", d.Get("desc").(string))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbUpdateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("restart") {
|
||||||
|
restart := d.Get("restart").(bool)
|
||||||
|
if restart {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbRestartAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("restore") {
|
||||||
|
restore := d.Get("restore").(bool)
|
||||||
|
if restore {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbRestoreAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("config_reset") {
|
||||||
|
cfgReset := d.Get("config_reset").(bool)
|
||||||
|
if cfgReset {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbConfigResetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: перенести backend и frontend из ресурсов сюда
|
||||||
|
|
||||||
|
return resourceLBRead(ctx, d, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceLB() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceLBCreate,
|
||||||
|
ReadContext: resourceLBRead,
|
||||||
|
UpdateContext: resourceLBEdit,
|
||||||
|
DeleteContext: resourceLBDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: lbResourceSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
373
internal/service/cloudapi/lb/resource_lb_backend.go
Normal file
373
internal/service/cloudapi/lb/resource_lb_backend.go
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendCreate")
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("backendName", d.Get("name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
if algorithm, ok := d.GetOk("algorithm"); ok {
|
||||||
|
urlValues.Add("algorithm", algorithm.(string))
|
||||||
|
}
|
||||||
|
if inter, ok := d.GetOk("inter"); ok {
|
||||||
|
urlValues.Add("inter", strconv.Itoa(inter.(int)))
|
||||||
|
}
|
||||||
|
if downinter, ok := d.GetOk("downinter"); ok {
|
||||||
|
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
|
||||||
|
}
|
||||||
|
if rise, ok := d.GetOk("rise"); ok {
|
||||||
|
urlValues.Add("rise", strconv.Itoa(rise.(int)))
|
||||||
|
}
|
||||||
|
if fall, ok := d.GetOk("fall"); ok {
|
||||||
|
urlValues.Add("fall", strconv.Itoa(fall.(int)))
|
||||||
|
}
|
||||||
|
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||||
|
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
|
||||||
|
}
|
||||||
|
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||||
|
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
|
||||||
|
}
|
||||||
|
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||||
|
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
|
||||||
|
}
|
||||||
|
if weight, ok := d.GetOk("weight"); ok {
|
||||||
|
urlValues.Add("weight", strconv.Itoa(weight.(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbBackendCreateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics := resourceLBBackendRead(ctx, d, m)
|
||||||
|
if diagnostics != nil {
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendRead")
|
||||||
|
|
||||||
|
b, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
|
if b == nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||||
|
|
||||||
|
d.Set("lb_id", lbId)
|
||||||
|
d.Set("name", b.Name)
|
||||||
|
d.Set("algorithm", b.Algorithm)
|
||||||
|
d.Set("guid", b.GUID)
|
||||||
|
d.Set("downinter", b.ServerDefaultSettings.DownInter)
|
||||||
|
d.Set("fall", b.ServerDefaultSettings.Fall)
|
||||||
|
d.Set("inter", b.ServerDefaultSettings.Inter)
|
||||||
|
d.Set("maxconn", b.ServerDefaultSettings.MaxConn)
|
||||||
|
d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue)
|
||||||
|
d.Set("rise", b.ServerDefaultSettings.Rise)
|
||||||
|
d.Set("slowstart", b.ServerDefaultSettings.SlowStart)
|
||||||
|
d.Set("weight", b.ServerDefaultSettings.Weight)
|
||||||
|
d.Set("servers", flattenServers(b.Servers))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendDelete")
|
||||||
|
|
||||||
|
lb, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
|
if lb == nil {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("backendName", d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", lbBackendDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendEdit")
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
urlValues.Add("backendName", d.Get("name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
if d.HasChange("algorithm") {
|
||||||
|
urlValues.Add("algorithm", d.Get("algorithm").(string))
|
||||||
|
}
|
||||||
|
if d.HasChange("inter") {
|
||||||
|
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("downinter") {
|
||||||
|
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("rise") {
|
||||||
|
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("fall") {
|
||||||
|
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("slowstart") {
|
||||||
|
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("maxconn") {
|
||||||
|
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("maxqueue") {
|
||||||
|
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("weight") {
|
||||||
|
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbBackendUpdateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: перенести servers сюда
|
||||||
|
|
||||||
|
return resourceLBBackendRead(ctx, d, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceLBBackend() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceLBBackendCreate,
|
||||||
|
ReadContext: resourceLBBackendRead,
|
||||||
|
UpdateContext: resourceLBBackendEdit,
|
||||||
|
DeleteContext: resourceLBBackendDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of the LB instance to backendCreate",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
|
},
|
||||||
|
"algorithm": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"roundrobin", "static-rr", "leastconn"}, false),
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"downinter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"fall": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"inter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxconn": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxqueue": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rise": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"slowstart": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"servers": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"check": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"server_settings": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"downinter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"fall": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"inter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxconn": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxqueue": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rise": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"slowstart": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
314
internal/service/cloudapi/lb/resource_lb_backend_server.go
Normal file
314
internal/service/cloudapi/lb/resource_lb_backend_server.go
Normal file
@@ -0,0 +1,314 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendServerCreate")
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||||
|
urlValues.Add("serverName", d.Get("name").(string))
|
||||||
|
urlValues.Add("address", d.Get("address").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
|
||||||
|
|
||||||
|
if check, ok := d.GetOk("check"); ok {
|
||||||
|
urlValues.Add("check", check.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if inter, ok := d.GetOk("inter"); ok {
|
||||||
|
urlValues.Add("inter", strconv.Itoa(inter.(int)))
|
||||||
|
}
|
||||||
|
if downinter, ok := d.GetOk("downinter"); ok {
|
||||||
|
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
|
||||||
|
}
|
||||||
|
if rise, ok := d.GetOk("rise"); ok {
|
||||||
|
urlValues.Add("rise", strconv.Itoa(rise.(int)))
|
||||||
|
}
|
||||||
|
if fall, ok := d.GetOk("fall"); ok {
|
||||||
|
urlValues.Add("fall", strconv.Itoa(fall.(int)))
|
||||||
|
}
|
||||||
|
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||||
|
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
|
||||||
|
}
|
||||||
|
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||||
|
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
|
||||||
|
}
|
||||||
|
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||||
|
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
|
||||||
|
}
|
||||||
|
if weight, ok := d.GetOk("weight"); ok {
|
||||||
|
urlValues.Add("weight", strconv.Itoa(weight.(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("backend_name").(string) + "-" + d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics := resourceLBBackendServerRead(ctx, d, m)
|
||||||
|
if diagnostics != nil {
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendServerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendServerRead")
|
||||||
|
|
||||||
|
s, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
|
if s == nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||||
|
backendName := strings.Split(d.Id(), "-")[1]
|
||||||
|
|
||||||
|
d.Set("lb_id", lbId)
|
||||||
|
d.Set("backend_name", backendName)
|
||||||
|
d.Set("name", s.Name)
|
||||||
|
d.Set("port", s.Port)
|
||||||
|
d.Set("address", s.Address)
|
||||||
|
d.Set("check", s.Check)
|
||||||
|
d.Set("guid", s.GUID)
|
||||||
|
d.Set("downinter", s.ServerSettings.DownInter)
|
||||||
|
d.Set("fall", s.ServerSettings.Fall)
|
||||||
|
d.Set("inter", s.ServerSettings.Inter)
|
||||||
|
d.Set("maxconn", s.ServerSettings.MaxConn)
|
||||||
|
d.Set("maxqueue", s.ServerSettings.MaxQueue)
|
||||||
|
d.Set("rise", s.ServerSettings.Rise)
|
||||||
|
d.Set("slowstart", s.ServerSettings.SlowStart)
|
||||||
|
d.Set("weight", s.ServerSettings.Weight)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendServerDelete")
|
||||||
|
|
||||||
|
lb, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
|
if lb == nil {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("serverName", d.Get("name").(string))
|
||||||
|
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||||
|
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", lbBackendServerDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBBackendServerEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBBackendServerEdit")
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("serverName", d.Get("name").(string))
|
||||||
|
urlValues.Add("address", d.Get("address").(string))
|
||||||
|
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
|
||||||
|
|
||||||
|
if d.HasChange("check") {
|
||||||
|
urlValues.Add("check", d.Get("check").(string))
|
||||||
|
}
|
||||||
|
if d.HasChange("inter") {
|
||||||
|
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("downinter") {
|
||||||
|
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("rise") {
|
||||||
|
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("fall") {
|
||||||
|
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("slowstart") {
|
||||||
|
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("maxconn") {
|
||||||
|
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("maxqueue") {
|
||||||
|
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
|
||||||
|
}
|
||||||
|
if d.HasChange("weight") {
|
||||||
|
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerUpdateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: перенести servers сюда
|
||||||
|
|
||||||
|
return resourceLBBackendServerRead(ctx, d, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceLBBackendServer() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceLBBackendServerCreate,
|
||||||
|
ReadContext: resourceLBBackendServerRead,
|
||||||
|
UpdateContext: resourceLBBackendServerEdit,
|
||||||
|
DeleteContext: resourceLBBackendServerDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of the LB instance to backendCreate",
|
||||||
|
},
|
||||||
|
"backend_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "IP address of the server.",
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Port number on the server",
|
||||||
|
},
|
||||||
|
"check": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"disabled", "enabled"}, false),
|
||||||
|
Description: "set to disabled if this server should be used regardless of its state.",
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"downinter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"fall": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"inter": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxconn": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"maxqueue": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rise": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"slowstart": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
192
internal/service/cloudapi/lb/resource_lb_frontend.go
Normal file
192
internal/service/cloudapi/lb/resource_lb_frontend.go
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendCreate")
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("frontendName", d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbFrontendCreateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics := resourceLBFrontendRead(ctx, d, m)
|
||||||
|
if diagnostics != nil {
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendRead")
|
||||||
|
|
||||||
|
f, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
|
if f == nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||||
|
d.Set("lb_id", lbId)
|
||||||
|
d.Set("backend_name", f.Backend)
|
||||||
|
d.Set("name", f.Name)
|
||||||
|
d.Set("guid", f.GUID)
|
||||||
|
d.Set("bindings", flattendBindings(f.Bindings))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendDelete")
|
||||||
|
|
||||||
|
lb, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
|
if lb == nil {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("frontendName", d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", lbFrontendDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
|
||||||
|
//TODO: перенести bindings сюда
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceLBFrontend() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceLBFrontendCreate,
|
||||||
|
ReadContext: resourceLBFrontendRead,
|
||||||
|
UpdateContext: resourceLBFrontendEdit,
|
||||||
|
DeleteContext: resourceLBFrontendDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of the LB instance to backendCreate",
|
||||||
|
},
|
||||||
|
"backend_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"bindings": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
201
internal/service/cloudapi/lb/resource_lb_frontend_bind.go
Normal file
201
internal/service/cloudapi/lb/resource_lb_frontend_bind.go
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendBindCreate")
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||||
|
urlValues.Add("bindingName", d.Get("name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("bindingAddress", d.Get("address").(string))
|
||||||
|
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("frontend_name").(string) + "-" + d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics := resourceLBFrontendBindRead(ctx, d, m)
|
||||||
|
if diagnostics != nil {
|
||||||
|
return diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendBindRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendBindRead")
|
||||||
|
|
||||||
|
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
|
if b == nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||||
|
frontendName := strings.Split(d.Id(), "-")[1]
|
||||||
|
|
||||||
|
d.Set("lb_id", lbId)
|
||||||
|
d.Set("frontend_name", frontendName)
|
||||||
|
d.Set("name", b.Name)
|
||||||
|
d.Set("address", b.Address)
|
||||||
|
d.Set("guid", b.GUID)
|
||||||
|
d.Set("port", b.Port)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendBindDelete")
|
||||||
|
|
||||||
|
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
|
if b == nil {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
urlValues.Add("bindingName", d.Get("name").(string))
|
||||||
|
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||||
|
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", lbFrontendBindDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId("")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func resourceLBFrontendBindEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceLBFrontendBindEdit")
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||||
|
urlValues.Add("bindingName", d.Get("name").(string))
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
|
||||||
|
if d.HasChange("address") {
|
||||||
|
urlValues.Add("bindingAddress", d.Get("address").(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("port") {
|
||||||
|
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindUpdateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resourceLBFrontendBindRead(ctx, d, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ResourceLBFrontendBind() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
CreateContext: resourceLBFrontendBindCreate,
|
||||||
|
ReadContext: resourceLBFrontendBindRead,
|
||||||
|
UpdateContext: resourceLBFrontendBindEdit,
|
||||||
|
DeleteContext: resourceLBFrontendBindDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of the LB instance to backendCreate",
|
||||||
|
},
|
||||||
|
"frontend_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
70
internal/service/cloudapi/lb/utility_lb.go
Normal file
70
internal/service/cloudapi/lb/utility_lb.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*LoadBalancer, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
if (d.Get("lb_id").(int)) != 0 {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
} else {
|
||||||
|
urlValues.Add("lbId", d.Id())
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := &LoadBalancer{}
|
||||||
|
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||||
|
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
return lb, nil
|
||||||
|
}
|
||||||
82
internal/service/cloudapi/lb/utility_lb_backend.go
Normal file
82
internal/service/cloudapi/lb/utility_lb_backend.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBBackendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Backend, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
bName := d.Get("name").(string)
|
||||||
|
|
||||||
|
if (d.Get("lb_id").(int)) != 0 {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
} else {
|
||||||
|
parameters := strings.Split(d.Id(), "-")
|
||||||
|
urlValues.Add("lbId", parameters[0])
|
||||||
|
bName = parameters[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := &LoadBalancer{}
|
||||||
|
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||||
|
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
backends := lb.Backends
|
||||||
|
for _, b := range backends {
|
||||||
|
if b.Name == bName {
|
||||||
|
return &b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
|
||||||
|
}
|
||||||
95
internal/service/cloudapi/lb/utility_lb_backend_server.go
Normal file
95
internal/service/cloudapi/lb/utility_lb_backend_server.go
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBBackendServerCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Server, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
bName := d.Get("backend_name").(string)
|
||||||
|
sName := d.Get("name").(string)
|
||||||
|
|
||||||
|
if (d.Get("lb_id").(int)) != 0 {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
} else {
|
||||||
|
parameters := strings.Split(d.Id(), "-")
|
||||||
|
urlValues.Add("lbId", parameters[0])
|
||||||
|
bName = parameters[1]
|
||||||
|
sName = parameters[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := &LoadBalancer{}
|
||||||
|
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||||
|
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
backend := &Backend{}
|
||||||
|
backends := lb.Backends
|
||||||
|
for i, b := range backends {
|
||||||
|
if b.Name == bName {
|
||||||
|
backend = &backends[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if backend.Name == "" {
|
||||||
|
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range backend.Servers {
|
||||||
|
if s.Name == sName {
|
||||||
|
return &s, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("can not find server with name: %s for backend: %s for lb: %d", sName, bName, lb.ID)
|
||||||
|
}
|
||||||
82
internal/service/cloudapi/lb/utility_lb_frontend.go
Normal file
82
internal/service/cloudapi/lb/utility_lb_frontend.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBFrontendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Frontend, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
fName := d.Get("name").(string)
|
||||||
|
|
||||||
|
if (d.Get("lb_id").(int)) != 0 {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
} else {
|
||||||
|
parameters := strings.Split(d.Id(), "-")
|
||||||
|
urlValues.Add("lbId", parameters[0])
|
||||||
|
fName = parameters[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := &LoadBalancer{}
|
||||||
|
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||||
|
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
frontends := lb.Frontends
|
||||||
|
for _, f := range frontends {
|
||||||
|
if f.Name == fName {
|
||||||
|
return &f, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
|
||||||
|
}
|
||||||
95
internal/service/cloudapi/lb/utility_lb_frontend_bind.go
Normal file
95
internal/service/cloudapi/lb/utility_lb_frontend_bind.go
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBFrontendBindCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Binding, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
fName := d.Get("frontend_name").(string)
|
||||||
|
bName := d.Get("name").(string)
|
||||||
|
|
||||||
|
if (d.Get("lb_id").(int)) != 0 {
|
||||||
|
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||||
|
} else {
|
||||||
|
parameters := strings.Split(d.Id(), "-")
|
||||||
|
urlValues.Add("lbId", parameters[0])
|
||||||
|
fName = parameters[1]
|
||||||
|
bName = parameters[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := &LoadBalancer{}
|
||||||
|
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||||
|
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
frontend := &Frontend{}
|
||||||
|
frontends := lb.Frontends
|
||||||
|
for i, f := range frontends {
|
||||||
|
if f.Name == fName {
|
||||||
|
frontend = &frontends[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if frontend.Name == "" {
|
||||||
|
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, b := range frontend.Bindings {
|
||||||
|
if b.Name == bName {
|
||||||
|
return &b, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("can not find bind with name: %s for frontend: %s for lb: %d", bName, fName, lb.ID)
|
||||||
|
}
|
||||||
74
internal/service/cloudapi/lb/utility_lb_list.go
Normal file
74
internal/service/cloudapi/lb/utility_lb_list.go
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
|
||||||
|
lbList := LBList{}
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||||
|
urlValues.Add("includedeleted", strconv.FormatBool((includedeleted.(bool))))
|
||||||
|
}
|
||||||
|
|
||||||
|
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("utilityLBListCheckPresence: load lb list")
|
||||||
|
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(lbListRaw), &lbList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return lbList, nil
|
||||||
|
}
|
||||||
70
internal/service/cloudapi/lb/utility_lb_list_deleted.go
Normal file
70
internal/service/cloudapi/lb/utility_lb_list_deleted.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
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 lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
|
||||||
|
lbList := LBList{}
|
||||||
|
c := m.(*controller.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("utilityLBListDeletedCheckPresence: load lb list")
|
||||||
|
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListDeletedAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(lbListRaw), &lbList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return lbList, nil
|
||||||
|
}
|
||||||
@@ -181,7 +181,7 @@ func ResourcePfw() *schema.Resource {
|
|||||||
DeleteContext: resourcePfwDelete,
|
DeleteContext: resourcePfwDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
|
|||||||
DeleteContext: resourceResgroupDelete,
|
DeleteContext: resourceResgroupDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
|
|||||||
DeleteContext: resourceSnapshotDelete,
|
DeleteContext: resourceSnapshotDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
|
|||||||
DeleteContext: resourceVinsDelete,
|
DeleteContext: resourceVinsDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ func ResourceAccount() *schema.Resource {
|
|||||||
DeleteContext: resourceAccountDelete,
|
DeleteContext: resourceAccountDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
|
|||||||
DeleteContext: resourceDiskDelete,
|
DeleteContext: resourceDiskDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ func ResourceCDROMImage() *schema.Resource {
|
|||||||
DeleteContext: resourceCDROMImageDelete,
|
DeleteContext: resourceCDROMImageDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ func ResourceDeleteImages() *schema.Resource {
|
|||||||
DeleteContext: resourceDeleteListImages,
|
DeleteContext: resourceDeleteListImages,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ func ResourceImage() *schema.Resource {
|
|||||||
DeleteContext: resourceImageDelete,
|
DeleteContext: resourceImageDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ func ResourceVirtualImage() *schema.Resource {
|
|||||||
DeleteContext: resourceImageDelete,
|
DeleteContext: resourceImageDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
|
|||||||
DeleteContext: resourceK8sDelete,
|
DeleteContext: resourceK8sDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
|
|||||||
DeleteContext: resourceK8sWgDelete,
|
DeleteContext: resourceK8sWgDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ func ResourceCompute() *schema.Resource {
|
|||||||
DeleteContext: resourceComputeDelete,
|
DeleteContext: resourceComputeDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ func ResourcePcidevice() *schema.Resource {
|
|||||||
DeleteContext: resourcePcideviceDelete,
|
DeleteContext: resourcePcideviceDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ func ResourcePfw() *schema.Resource {
|
|||||||
DeleteContext: resourcePfwDelete,
|
DeleteContext: resourcePfwDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
|
|||||||
DeleteContext: resourceResgroupDelete,
|
DeleteContext: resourceResgroupDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ func ResourceSep() *schema.Resource {
|
|||||||
DeleteContext: resourceSepDelete,
|
DeleteContext: resourceSepDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ func ResourceSepConfig() *schema.Resource {
|
|||||||
DeleteContext: resourceSepConfigDelete,
|
DeleteContext: resourceSepConfigDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
|
|||||||
DeleteContext: resourceSnapshotDelete,
|
DeleteContext: resourceSnapshotDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
|
|||||||
DeleteContext: resourceVinsDelete,
|
DeleteContext: resourceVinsDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
# Примеры применения ресурсов terraform-provider-decort
|
# Примеры применения ресурсов terraform-provider-decort
|
||||||
|
|
||||||
Каждый файл снабжен комментариями, которые кратко описывают возможности и параметры ресурса.
|
Каждый файл снабжен комментариями, которые кратко описывают возможности и параметры ресурса.
|
||||||
Для успешной работы необходим установленный terraform.
|
Для успешной работы необходим установленный terraform.
|
||||||
|
|
||||||
## Ресурсы в примерах
|
## Ресурсы в примерах
|
||||||
|
|
||||||
- cloudapi:
|
- cloudapi:
|
||||||
- data:
|
- data:
|
||||||
- image
|
- image
|
||||||
@@ -37,6 +40,9 @@
|
|||||||
- vins_list
|
- vins_list
|
||||||
- locations_list
|
- locations_list
|
||||||
- location_url
|
- location_url
|
||||||
|
- lb
|
||||||
|
- lb_list
|
||||||
|
- lb_list_deleted
|
||||||
- resources:
|
- resources:
|
||||||
- image
|
- image
|
||||||
- virtual_image
|
- virtual_image
|
||||||
@@ -49,6 +55,11 @@
|
|||||||
- account
|
- account
|
||||||
- bservice
|
- bservice
|
||||||
- bservice_group
|
- bservice_group
|
||||||
|
- lb
|
||||||
|
- lb_frontend
|
||||||
|
- lb_backend
|
||||||
|
- lb_frontend_bind
|
||||||
|
- lb_backend_server
|
||||||
- cloudbroker:
|
- cloudbroker:
|
||||||
- data:
|
- data:
|
||||||
- grid
|
- grid
|
||||||
@@ -94,13 +105,14 @@
|
|||||||
- vins
|
- vins
|
||||||
|
|
||||||
## Как пользоваться примерами
|
## Как пользоваться примерами
|
||||||
|
|
||||||
1. Установить terraform
|
1. Установить terraform
|
||||||
2. Установить terraform-provider-decort с помощью команды `terraform init` (выполняется автоматически), либо вручную.
|
2. Установить terraform-provider-decort с помощью команды `terraform init` (выполняется автоматически), либо вручную.
|
||||||
3. Заменить параметр *controller_url* на ваш.
|
3. Заменить параметр _controller_url_ на ваш.
|
||||||
4. Заменить параметр *oauth2* на ваш.
|
4. Заменить параметр _oauth2_ на ваш.
|
||||||
5. Добавить ключи
|
5. Добавить ключи
|
||||||
*DECORT_APP_SECRET* и *DECORT_APP_ID*
|
_DECORT_APP_SECRET_ и _DECORT_APP_ID_
|
||||||
в качестве переменных окружения, либо
|
в качестве переменных окружения, либо
|
||||||
можно добавить `app_id` и `app_secret`
|
можно добавить `app_id` и `app_secret`
|
||||||
в блок `provider`,что небезопасно, т.к. данные
|
в блок `provider`,что небезопасно, т.к. данные
|
||||||
могут быть похищены при передачи файла.
|
могут быть похищены при передачи файла.
|
||||||
|
|||||||
37
samples/cloudapi/data_lb/main.tf
Normal file
37
samples/cloudapi/data_lb/main.tf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение информации о load balancer (балансировщик нагрузок)
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_lb" "lb" {
|
||||||
|
#id балансировщика нагрузок
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
lb_id = 238
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_lb.lb
|
||||||
|
}
|
||||||
52
samples/cloudapi/data_lb_list/main.tf
Normal file
52
samples/cloudapi/data_lb_list/main.tf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка load balancer (балансировщиков нагрузки)
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_lb_list" "lbl" {
|
||||||
|
#флаг влючения в результат удаленных балансироващиков нагрузки
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#значение по-умолчанию - false
|
||||||
|
#если не задан - выводятся все доступные неудаленные балансировщики
|
||||||
|
#includedeleted = true
|
||||||
|
|
||||||
|
#номер страницы для отображения
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
#page = 1
|
||||||
|
|
||||||
|
#размер страницы
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
#size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_lb_list.lbl
|
||||||
|
}
|
||||||
45
samples/cloudapi/data_lb_list_deleted/main.tf
Normal file
45
samples/cloudapi/data_lb_list_deleted/main.tf
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка удаленных load balancer (балансировщиков нагрузок)
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_lb_list_deleted" "lbld" {
|
||||||
|
#номер страницы для отображения
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
#page = 1
|
||||||
|
|
||||||
|
#размер страницы
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
#size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_lb_list_deleted.lbld
|
||||||
|
}
|
||||||
80
samples/cloudapi/resource_kvmvm/main.tf
Normal file
80
samples/cloudapi/resource_kvmvm/main.tf
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Работа с ресурсом kvmvm (compute)
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать compute
|
||||||
|
2. Редактировать compute
|
||||||
|
3. Удалять compute
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_kvmvm" "comp" {
|
||||||
|
#имя compute
|
||||||
|
#обязательный параметр
|
||||||
|
#мб изменен
|
||||||
|
#тип - строка
|
||||||
|
name = "test-tf-compute-update-new"
|
||||||
|
|
||||||
|
#id resource group
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
rg_id = 1111
|
||||||
|
|
||||||
|
#тип драйвера для compute
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
driver = "KVM_X86"
|
||||||
|
|
||||||
|
#число cpu
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
cpu = 1
|
||||||
|
|
||||||
|
#кол-во оперативной памяти, МБ
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
ram = 2048
|
||||||
|
|
||||||
|
#id образа диска для создания compute
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
image_id = 111
|
||||||
|
|
||||||
|
#размер загрузочного диска
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
boot_disk_size = 20
|
||||||
|
|
||||||
|
#описание compute
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - строка
|
||||||
|
description = "test update description in tf words update"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_kvmvm.comp
|
||||||
|
}
|
||||||
108
samples/cloudapi/resource_lb/main.tf
Normal file
108
samples/cloudapi/resource_lb/main.tf
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса load balancer
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать load balancer
|
||||||
|
2. Редактировать load balancer
|
||||||
|
3. Удалять load balancer
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_lb" "lb" {
|
||||||
|
#id ресурсной группы для со
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
rg_id = 1111
|
||||||
|
|
||||||
|
#наименование load balancer
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
name = "tf-test-lb"
|
||||||
|
|
||||||
|
#id внешней сети
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
extnet_id = 6
|
||||||
|
|
||||||
|
#id виртуальной сети
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
vins_id = 758
|
||||||
|
|
||||||
|
#флаг запуска load balancer
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#по умолчанию - true
|
||||||
|
#если load balancer был в статусе "stopped" (start = false),
|
||||||
|
#то для успешного старта, он должен быть доступен (enable = true)
|
||||||
|
start = true
|
||||||
|
|
||||||
|
#описание
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - строка
|
||||||
|
#desc = "temp super lb for testing tf provider"
|
||||||
|
|
||||||
|
#флаг доступности load balancer
|
||||||
|
#необязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#enable = true
|
||||||
|
|
||||||
|
#флаг перезапуска load balancer
|
||||||
|
#необязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#перезагрузка срабатывает только при изменении флага с false на true
|
||||||
|
#restart = false
|
||||||
|
|
||||||
|
#флаг сброса конфигурации load balancer
|
||||||
|
#необязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#сброс срабатывает только при изменении флага с false на true
|
||||||
|
#config_reset = false
|
||||||
|
|
||||||
|
#флаг моментального удаления load balancer
|
||||||
|
#необязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#по умолчанию - false
|
||||||
|
#применяется при выполнении команды terraform destroy
|
||||||
|
#permanently = false
|
||||||
|
|
||||||
|
#флаг восстановления load balancer
|
||||||
|
#необязательный параметр
|
||||||
|
#тип - булев тип
|
||||||
|
#восстановить можно load balancer, удаленным с флагом permanently = false
|
||||||
|
#restore = true
|
||||||
|
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "5m"
|
||||||
|
read = "5m"
|
||||||
|
update = "5m"
|
||||||
|
delete = "5m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_lb.lb
|
||||||
|
}
|
||||||
115
samples/cloudapi/resource_lb_backend/main.tf
Normal file
115
samples/cloudapi/resource_lb_backend/main.tf
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса load balancer backend
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать backend
|
||||||
|
2. Редактировать backend
|
||||||
|
3. Удалять backend
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_lb_backend" "lb" {
|
||||||
|
#id балансировщика нагрузок
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
lb_id = 668
|
||||||
|
|
||||||
|
#имя бекенда для создания сервера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
name = "testBackend"
|
||||||
|
|
||||||
|
#алгоритм балансировки
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - строка
|
||||||
|
#по умолчанию - "roundrobin"
|
||||||
|
#доступные значения - "roundrobin", "static-rr", "leastconn"
|
||||||
|
#algorithm = "roundrobin"
|
||||||
|
|
||||||
|
#-------------------
|
||||||
|
#настройки для серверов по умолчанию
|
||||||
|
#-------------------
|
||||||
|
|
||||||
|
#интервал между проверками, в миллисекундах
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 5000
|
||||||
|
#inter = 5000
|
||||||
|
|
||||||
|
#интервал между проверками доступности сервера после восстановления, в миллисекундах
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 1000
|
||||||
|
#downinter = 1000
|
||||||
|
|
||||||
|
#кол-во проверок, которые сервер должен успешно пройти
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 2
|
||||||
|
#rise = 2
|
||||||
|
|
||||||
|
#кол-во проверок, которые сервер может не пройти и после этого получить статус "unavailable"
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 2
|
||||||
|
#fall = 2
|
||||||
|
|
||||||
|
#кол-во миллисекунд - время между получением сервера статуса "available" и открытием соединений
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 60000
|
||||||
|
#slowstart = 60000
|
||||||
|
|
||||||
|
#максимальное кол-во соединений сервера, при достижении этого кол-ва, сервер выходит из схемы балансирования
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 250
|
||||||
|
#maxconn = 250
|
||||||
|
|
||||||
|
#максимальное кол-во соединений в очереди серевера, при достижении этого кол-ва, соединения будут перенаправлены на другой сервер
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 256
|
||||||
|
#maxqueue = 256
|
||||||
|
|
||||||
|
#вес сервера для балансировки
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#мин - 0
|
||||||
|
#макс - 255
|
||||||
|
#по умолчанию - 100
|
||||||
|
#weight = 100
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "5m"
|
||||||
|
read = "5m"
|
||||||
|
update = "5m"
|
||||||
|
delete = "5m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_lb_backend.lb
|
||||||
|
}
|
||||||
126
samples/cloudapi/resource_lb_backend_server/main.tf
Normal file
126
samples/cloudapi/resource_lb_backend_server/main.tf
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса load balancer backend server
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать server
|
||||||
|
2. Редактировать server
|
||||||
|
3. Удалять server
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_lb_backend_server" "lb" {
|
||||||
|
#id балансировщика нагрузок
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
lb_id = 668
|
||||||
|
|
||||||
|
#имя бекенда для создания сервера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
backend_name = "testBackend"
|
||||||
|
|
||||||
|
#имя сервера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
name = "testServer"
|
||||||
|
|
||||||
|
#ip адрес сервера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
address = "192.168.5.33"
|
||||||
|
|
||||||
|
#порт сервера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
port = 6553
|
||||||
|
|
||||||
|
#проверка доступности сервера
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - строка
|
||||||
|
#по умолчанию - "enabled"
|
||||||
|
#доступные значения - "disabled", "enabled"
|
||||||
|
#check = "enabled"
|
||||||
|
|
||||||
|
#интервал между проверками, в миллисекундах
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 5000
|
||||||
|
#inter = 5000
|
||||||
|
|
||||||
|
#интервал между проверками доступности сервера после восстановления, в миллисекундах
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 1000
|
||||||
|
#downinter = 1000
|
||||||
|
|
||||||
|
#кол-во проверок, которые сервер должен успешно пройти
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 2
|
||||||
|
#rise = 2
|
||||||
|
|
||||||
|
#кол-во проверок, которые сервер может не пройти и после этого получить статус "unavailable"
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 2
|
||||||
|
#fall = 2
|
||||||
|
|
||||||
|
#кол-во миллисекунд - время между получением сервера статуса "available" и открытием соединений
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 60000
|
||||||
|
#slowstart = 60000
|
||||||
|
|
||||||
|
#максимальное кол-во соединений сервера, при достижении этого кол-ва, сервер выходит из схемы балансирования
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 250
|
||||||
|
#maxconn = 250
|
||||||
|
|
||||||
|
#максимальное кол-во соединений в очереди серевера, при достижении этого кол-ва, соединения будут перенаправлены на другой сервер
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#по умолчанию - 256
|
||||||
|
#maxqueue = 256
|
||||||
|
|
||||||
|
#вес сервера для балансировки
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
#мин - 0
|
||||||
|
#макс - 255
|
||||||
|
#по умолчанию - 100
|
||||||
|
#weight = 100
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "5m"
|
||||||
|
read = "5m"
|
||||||
|
update = "5m"
|
||||||
|
delete = "5m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_lb_backend_server.lb
|
||||||
|
}
|
||||||
58
samples/cloudapi/resource_lb_frontend/main.tf
Normal file
58
samples/cloudapi/resource_lb_frontend/main.tf
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса load balancer frontend
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать frontend
|
||||||
|
2. Удалять frontend
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_lb_frontend" "lb" {
|
||||||
|
#id балансировщика нагрузок
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
lb_id = 668
|
||||||
|
|
||||||
|
#имя бекенда для создания фронтенда
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
backend_name = "testBackend"
|
||||||
|
|
||||||
|
#имя фронтенда
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
name = "testFrontend"
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "5m"
|
||||||
|
read = "5m"
|
||||||
|
update = "5m"
|
||||||
|
delete = "5m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_lb_frontend.lb
|
||||||
|
}
|
||||||
69
samples/cloudapi/resource_lb_frontend_bind/main.tf
Normal file
69
samples/cloudapi/resource_lb_frontend_bind/main.tf
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса load balancer frontend bind (привязка фронтенда балансировщика нагрузок)
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать привязку
|
||||||
|
2. Редактировать привязку
|
||||||
|
3. Удалять привязку
|
||||||
|
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||||
|
/*
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
decort = {
|
||||||
|
version = "1.1"
|
||||||
|
source = "digitalenergy.online/decort/decort"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
provider "decort" {
|
||||||
|
authenticator = "oauth2"
|
||||||
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "decort_lb_frontend_bind" "lb" {
|
||||||
|
#id балансировщика нагрузок
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
lb_id = 668
|
||||||
|
|
||||||
|
#имя фронтенда для создания привязки
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
frontend_name = "testFrontend"
|
||||||
|
|
||||||
|
#наименование привязки
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
name = "testBinding"
|
||||||
|
|
||||||
|
#адрес привязки фронтенда
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
address = "111.111.111.111"
|
||||||
|
|
||||||
|
#порт для привязки фронтенда
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
port = 1111
|
||||||
|
|
||||||
|
timeouts {
|
||||||
|
create = "5m"
|
||||||
|
read = "5m"
|
||||||
|
update = "5m"
|
||||||
|
delete = "5m"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_lb_frontend_bind.lb
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user