Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71ddaa3345 | ||
|
|
775a0b5adb | ||
|
|
1a983e945b | ||
|
|
b152359706 | ||
| a844f6cc30 | |||
|
|
8e6b5a9bab | ||
|
|
cd4695ee68 |
@@ -1,10 +1,3 @@
|
||||
### Bug fixes
|
||||
- fatal error when trying to retrieve compute boot disk if former does not have one
|
||||
- ignored timeouts
|
||||
- wrong handling of errors when attaching network interfaces and disks to kvmvm
|
||||
|
||||
### New features
|
||||
- parameter iotune in disk
|
||||
- migrated to terraform SDKv2
|
||||
- admin mode (activated by environment variable DECORT\_ADMIN\_MODE) for resources: account, k8s, image, disk, resgroup, kvmvm, vins
|
||||
- parameters sep\_id and pool in kvmvm
|
||||
- error naming lb resources
|
||||
|
||||
7
Makefile
7
Makefile
@@ -4,6 +4,7 @@ NAMESPACE=decort
|
||||
NAME=terraform-provider-decort
|
||||
#BINARY=terraform-provider-${NAME}
|
||||
BINARY=${NAME}.exe
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=1.1
|
||||
#OS_ARCH=darwin_amd64
|
||||
@@ -14,8 +15,14 @@ default: install
|
||||
lint:
|
||||
golangci-lint run --timeout 600s
|
||||
|
||||
st:
|
||||
go build -o ${BINARY} ${MAINPATH}
|
||||
cp ${BINARY} ${WORKPATH}
|
||||
rm ${BINARY}
|
||||
|
||||
build:
|
||||
go build -o ${BINARY} ${MAINPATH}
|
||||
|
||||
release:
|
||||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
|
||||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
|
||||
|
||||
60
README.md
60
README.md
@@ -1,22 +1,27 @@
|
||||
# terraform-provider-decort
|
||||
|
||||
Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT)
|
||||
|
||||
Внимание: провайдер версии 3.x разработан для DECORT API 3.8.x.
|
||||
Для более старых версий можно использовать:
|
||||
|
||||
- DECORT API 3.7.x - версия провайдера rc-1.25
|
||||
- DECORT API 3.6.x - версия провайдера rc-1.10
|
||||
- DECORT API до 3.6.0 - terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
||||
|
||||
## Режимы работы
|
||||
|
||||
Провайдер позволяет работать в двух режимах:
|
||||
|
||||
- Режим пользователя,
|
||||
- Режим администратора.
|
||||
Для переключения между режимами используйте флаг DECORT_ADMIN_MODE.
|
||||
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
Для переключения между режимами используйте флаг DECORT_ADMIN_MODE.
|
||||
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
## Возможности провайдера
|
||||
- Работа с Compute instances,
|
||||
- Работа с disks,
|
||||
|
||||
- Работа с Compute instances,
|
||||
- Работа с disks,
|
||||
- Работа с k8s,
|
||||
- Работа с image,
|
||||
- Работа с reource groups,
|
||||
@@ -29,18 +34,23 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
||||
- Работа с vgpu,
|
||||
- Работа с bservice,
|
||||
- Работа с extnets,
|
||||
- Работа с locations.
|
||||
- Работа с locations,
|
||||
- Работа с load balancer.
|
||||
|
||||
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
## Начало
|
||||
Старт возможен по двум путям:
|
||||
|
||||
Старт возможен по двум путям:
|
||||
|
||||
1. Установка через собранные пакеты.
|
||||
2. Ручная установка.
|
||||
|
||||
### Установка через собранные пакеты.
|
||||
|
||||
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||
2. Создайте файл `main.tf` и добавьте в него следующий блок.
|
||||
|
||||
```terraform
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
@@ -51,45 +61,62 @@ provider "decort" {
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
```
|
||||
|
||||
3. Выполните команду
|
||||
|
||||
```
|
||||
terraform init
|
||||
```
|
||||
|
||||
Провайдер автоматически будет установлен на ваш компьютер из terraform registry.
|
||||
|
||||
### Ручная установка
|
||||
|
||||
1. Скачайте и установите Go по ссылке: https://go.dev/dl/
|
||||
2. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
|
||||
3. Склонируйте репозиторий с провайдером, выполнив команду:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/rudecs/terraform-provider-decort.git
|
||||
```
|
||||
|
||||
4. Перейдите в скачанную папку с провайдером и выполните команду
|
||||
|
||||
```bash
|
||||
go build -o terraform-provider-decort
|
||||
```
|
||||
|
||||
Если вы знаете как устроен _makefile_, то можно изменить в файле `Makefile` параметры под вашу ОС и выполнить команду
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
5. Полученный файл необходимо поместить:
|
||||
Linux:
|
||||
Linux:
|
||||
|
||||
```bash
|
||||
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
|
||||
```
|
||||
|
||||
Windows:
|
||||
|
||||
```powershell
|
||||
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
|
||||
```
|
||||
|
||||
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
|
||||
Где:
|
||||
|
||||
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online
|
||||
- namespace - пространство имен хоста, например decort
|
||||
- namespace - пространство имен хоста, например decort
|
||||
- type - тип провайдера, может совпадать с пространством имен, например, decort
|
||||
- version - версия провайдера, например 1.2
|
||||
- target - версия ОС, например windows_amd64
|
||||
|
||||
6. После этого, создайте файл `main.tf`.
|
||||
7. Добавьте в него следующий блок
|
||||
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
@@ -100,32 +127,39 @@ terraform {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
В поле `version` указывается версия провайдера.
|
||||
Обязательный параметр
|
||||
Тип поля - строка
|
||||
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
|
||||
|
||||
В поле `source` помещается путь до репозитория с версией вида:
|
||||
|
||||
```bash
|
||||
${host_name}/${namespace}/${type}
|
||||
```
|
||||
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
||||
|
||||
8. В консоле выполнить команду
|
||||
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер.
|
||||
|
||||
8. В консоле выполнить команду
|
||||
|
||||
```bash
|
||||
terraform init
|
||||
```
|
||||
|
||||
9. Если все прошло хорошо - ошибок не будет.
|
||||
9. Если все прошло хорошо - ошибок не будет.
|
||||
|
||||
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
|
||||
|
||||
## Примеры работы
|
||||
|
||||
Примеры работы можно найти:
|
||||
|
||||
- На вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
- В папке `samples`
|
||||
- В папке `samples`
|
||||
|
||||
Схемы к terraform'у доступны:
|
||||
- В папке `docs`
|
||||
|
||||
- В папке `docs`
|
||||
|
||||
Хорошей работы!
|
||||
|
||||
57
README_EN.md
57
README_EN.md
@@ -1,22 +1,26 @@
|
||||
# terraform-provider-decort
|
||||
|
||||
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:
|
||||
|
||||
- DECORT API 3.7.x versions - provider verion rc-1.25
|
||||
- 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)
|
||||
|
||||
## Working modes
|
||||
|
||||
The provider support two working modes:
|
||||
|
||||
- User mode,
|
||||
- Administator mode.
|
||||
Use flag DECORT_ADMIN_MODE for swithcing beetwen modes.
|
||||
See user guide at https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
Use flag DECORT_ADMIN_MODE for swithcing beetwen modes.
|
||||
See user guide at https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
## Features
|
||||
- Work with Compute instances,
|
||||
- Work with disks,
|
||||
|
||||
- Work with Compute instances,
|
||||
- Work with disks,
|
||||
- Work with k8s,
|
||||
- Work with image,
|
||||
- Work with reource groups,
|
||||
@@ -29,21 +33,25 @@ See user guide at https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
- Work with vgpu,
|
||||
- Work with bservice,
|
||||
- Work with extnets,
|
||||
- Work with locations.
|
||||
- Work with locations,
|
||||
- Work with load balancers.
|
||||
|
||||
This provider supports Import operations on pre-existing resources.
|
||||
|
||||
See user guide at https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
|
||||
## Get Started
|
||||
Two ways for starting:
|
||||
|
||||
Two ways for starting:
|
||||
|
||||
1. Installing via binary packages
|
||||
2. Manual installing
|
||||
|
||||
### Installing via binary packages
|
||||
|
||||
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.
|
||||
|
||||
```terraform
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
@@ -54,45 +62,62 @@ provider "decort" {
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
```
|
||||
|
||||
3. Execute next command
|
||||
|
||||
```
|
||||
terraform init
|
||||
```
|
||||
|
||||
The Provider will automatically install on your computer from the terrafrom registry.
|
||||
|
||||
### Manual installing
|
||||
|
||||
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
|
||||
3. Clone provider's repo:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/rudecs/terraform-provider-decort.git
|
||||
```
|
||||
|
||||
4. Change directory to clone provider's and execute next command
|
||||
|
||||
```bash
|
||||
go build -o terraform-provider-decort
|
||||
```
|
||||
|
||||
If you have experience with _makefile_, you can change `Makefile`'s paramters and execute next command
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
5. Now move compilled file to:
|
||||
Linux:
|
||||
Linux:
|
||||
|
||||
```bash
|
||||
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
|
||||
```
|
||||
|
||||
Windows:
|
||||
|
||||
```powershell
|
||||
%APPDATA%\terraform.d\plugins\${host_name}/${namespace}/${type}/${version}/${target}
|
||||
```
|
||||
|
||||
NOTE: for Windows OS `%APP_DATA%` is a cataloge, where will place terraform files.
|
||||
Example:
|
||||
|
||||
- host_name - digitalenergy.online
|
||||
- namespace - decort
|
||||
- namespace - decort
|
||||
- type - decort
|
||||
- version - 1.2
|
||||
- target - windows_amd64
|
||||
|
||||
6. After all, create a file `main.tf`.
|
||||
7. Add to the file next code section
|
||||
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
@@ -103,18 +128,22 @@ terraform {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`version`- field for provider's version
|
||||
Required
|
||||
String
|
||||
Note: Versions in code section and in a repository must be equal!
|
||||
|
||||
`source` - path to repository with provider's version
|
||||
|
||||
```bash
|
||||
${host_name}/${namespace}/${type}
|
||||
```
|
||||
|
||||
NOTE: all paramters must be equal to the repository path!
|
||||
|
||||
8. Execute command in your terminal
|
||||
8. Execute command in your terminal
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
## Examples and Samples
|
||||
|
||||
- Examples: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
- Samples: see in repository `samples`
|
||||
- Samples: see in repository `samples`
|
||||
|
||||
Terraform schemas in:
|
||||
- See in repository `docs`
|
||||
|
||||
- See in repository `docs`
|
||||
|
||||
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.
|
||||
- `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.
|
||||
- `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))
|
||||
- `permanently` (Boolean)
|
||||
- `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.
|
||||
- `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/image"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||
@@ -69,6 +70,9 @@ func NewDataSourcesMap() map[string]*schema.Resource {
|
||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||
"decort_image_list": image.DataSourceImageList(),
|
||||
"decort_image": image.DataSourceImage(),
|
||||
"decort_lb": lb.DataSourceLB(),
|
||||
"decort_lb_list": lb.DataSourceLBList(),
|
||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||
// "decort_pfw": dataSourcePfw(),
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/pfw"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||
@@ -35,18 +36,23 @@ import (
|
||||
|
||||
func NewRersourcesMap() map[string]*schema.Resource {
|
||||
return map[string]*schema.Resource{
|
||||
"decort_resgroup": rg.ResourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.ResourceCompute(),
|
||||
"decort_disk": disks.ResourceDisk(),
|
||||
"decort_vins": vins.ResourceVins(),
|
||||
"decort_pfw": pfw.ResourcePfw(),
|
||||
"decort_k8s": k8s.ResourceK8s(),
|
||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||
"decort_account": account.ResourceAccount(),
|
||||
"decort_bservice": bservice.ResourceBasicService(),
|
||||
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
||||
"decort_image": image.ResourceImage(),
|
||||
"decort_image_virtual": image.ResourceImageVirtual(),
|
||||
"decort_resgroup": rg.ResourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.ResourceCompute(),
|
||||
"decort_disk": disks.ResourceDisk(),
|
||||
"decort_vins": vins.ResourceVins(),
|
||||
"decort_pfw": pfw.ResourcePfw(),
|
||||
"decort_k8s": k8s.ResourceK8s(),
|
||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||
"decort_account": account.ResourceAccount(),
|
||||
"decort_bservice": bservice.ResourceBasicService(),
|
||||
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
||||
"decort_image": image.ResourceImage(),
|
||||
"decort_image_virtual": image.ResourceImageVirtual(),
|
||||
"decort_lb": lb.ResourceLB(),
|
||||
"decort_lb_backend": lb.ResourceLBBackend(),
|
||||
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,7 +786,7 @@ func ResourceAccount() *schema.Resource {
|
||||
DeleteContext: resourceAccountDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -511,7 +511,7 @@ func ResourceBasicService() *schema.Resource {
|
||||
DeleteContext: resourceBasicServiceDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -616,7 +616,7 @@ func ResourceBasicServiceGroup() *schema.Resource {
|
||||
DeleteContext: resourceBasicServiceGroupDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
|
||||
DeleteContext: resourceDiskDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -31,7 +31,7 @@ Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
package image
|
||||
|
||||
const imageCreateAPI = "/restmachine/cloudapi/image/createImage"
|
||||
const imageCreateAPI = "/restmachine/cloudapi/image/create"
|
||||
const imageCreateVirtualAPI = "/restmachine/cloudapi/image/createVirtual"
|
||||
const imageGetAPI = "/restmachine/cloudapi/image/get"
|
||||
const imageListGetAPI = "/restmachine/cloudapi/image/list"
|
||||
|
||||
@@ -33,6 +33,7 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
@@ -94,11 +95,25 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
if architecture, ok := d.GetOk("architecture"); ok {
|
||||
urlValues.Add("architecture", architecture.(string))
|
||||
}
|
||||
|
||||
/* uncomment then OK
|
||||
imageId, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
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.Set("image_id", imageId)
|
||||
@@ -229,7 +244,7 @@ func ResourceImage() *schema.Resource {
|
||||
DeleteContext: resourceImageDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -116,7 +116,7 @@ func ResourceImageVirtual() *schema.Resource {
|
||||
DeleteContext: resourceImageDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
|
||||
DeleteContext: resourceK8sDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
|
||||
DeleteContext: resourceK8sWgDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -44,3 +44,4 @@ const ComputeStopAPI = "/restmachine/cloudapi/compute/stop"
|
||||
const ComputeResizeAPI = "/restmachine/cloudapi/compute/resize"
|
||||
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
|
||||
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))
|
||||
}
|
||||
|
||||
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")
|
||||
if sshKeysSet {
|
||||
@@ -287,6 +295,16 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
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") {
|
||||
params := &url.Values{}
|
||||
params.Add("computeId", d.Id())
|
||||
@@ -318,8 +336,8 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
params := &url.Values{}
|
||||
params.Add("computeId", d.Id())
|
||||
params.Add("permanently", "1")
|
||||
params.Add("detachDisks", "1")
|
||||
params.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
|
||||
params.Add("detachDisks", strconv.FormatBool(d.Get("detach_disks").(bool)))
|
||||
|
||||
if _, err := c.DecortAPICall(ctx, "POST", ComputeDeleteAPI, params); err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -338,7 +356,7 @@ func ResourceCompute() *schema.Resource {
|
||||
DeleteContext: resourceComputeDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
@@ -501,6 +519,26 @@ func ResourceCompute() *schema.Resource {
|
||||
Default: true,
|
||||
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
|
||||
computeName, argSet := d.GetOk("name")
|
||||
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")
|
||||
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))
|
||||
|
||||
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,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
|
||||
DeleteContext: resourceResgroupDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
|
||||
DeleteContext: resourceSnapshotDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
|
||||
DeleteContext: resourceVinsDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -455,7 +455,7 @@ func ResourceAccount() *schema.Resource {
|
||||
DeleteContext: resourceAccountDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
|
||||
DeleteContext: resourceDiskDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -381,7 +381,7 @@ func ResourceCDROMImage() *schema.Resource {
|
||||
DeleteContext: resourceCDROMImageDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -126,7 +126,7 @@ func ResourceDeleteImages() *schema.Resource {
|
||||
DeleteContext: resourceDeleteListImages,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -665,7 +665,7 @@ func ResourceImage() *schema.Resource {
|
||||
DeleteContext: resourceImageDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -328,7 +328,7 @@ func ResourceVirtualImage() *schema.Resource {
|
||||
DeleteContext: resourceImageDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
|
||||
DeleteContext: resourceK8sDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
|
||||
DeleteContext: resourceK8sWgDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -338,7 +338,7 @@ func ResourceCompute() *schema.Resource {
|
||||
DeleteContext: resourceComputeDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -229,7 +229,7 @@ func ResourcePcidevice() *schema.Resource {
|
||||
DeleteContext: resourcePcideviceDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -181,7 +181,7 @@ func ResourcePfw() *schema.Resource {
|
||||
DeleteContext: resourcePfwDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
|
||||
DeleteContext: resourceResgroupDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -492,7 +492,7 @@ func ResourceSep() *schema.Resource {
|
||||
DeleteContext: resourceSepDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -188,7 +188,7 @@ func ResourceSepConfig() *schema.Resource {
|
||||
DeleteContext: resourceSepConfigDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
|
||||
DeleteContext: resourceSnapshotDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
|
||||
DeleteContext: resourceVinsDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
# Примеры применения ресурсов terraform-provider-decort
|
||||
|
||||
Каждый файл снабжен комментариями, которые кратко описывают возможности и параметры ресурса.
|
||||
Для успешной работы необходим установленный terraform.
|
||||
|
||||
## Ресурсы в примерах
|
||||
|
||||
- cloudapi:
|
||||
- data:
|
||||
- image
|
||||
@@ -37,6 +40,9 @@
|
||||
- vins_list
|
||||
- locations_list
|
||||
- location_url
|
||||
- lb
|
||||
- lb_list
|
||||
- lb_list_deleted
|
||||
- resources:
|
||||
- image
|
||||
- virtual_image
|
||||
@@ -49,6 +55,11 @@
|
||||
- account
|
||||
- bservice
|
||||
- bservice_group
|
||||
- lb
|
||||
- lb_frontend
|
||||
- lb_backend
|
||||
- lb_frontend_bind
|
||||
- lb_backend_server
|
||||
- cloudbroker:
|
||||
- data:
|
||||
- grid
|
||||
@@ -94,13 +105,14 @@
|
||||
- vins
|
||||
|
||||
## Как пользоваться примерами
|
||||
|
||||
1. Установить terraform
|
||||
2. Установить terraform-provider-decort с помощью команды `terraform init` (выполняется автоматически), либо вручную.
|
||||
3. Заменить параметр *controller_url* на ваш.
|
||||
4. Заменить параметр *oauth2* на ваш.
|
||||
5. Добавить ключи
|
||||
*DECORT_APP_SECRET* и *DECORT_APP_ID*
|
||||
в качестве переменных окружения, либо
|
||||
можно добавить `app_id` и `app_secret`
|
||||
в блок `provider`,что небезопасно, т.к. данные
|
||||
могут быть похищены при передачи файла.
|
||||
3. Заменить параметр _controller_url_ на ваш.
|
||||
4. Заменить параметр _oauth2_ на ваш.
|
||||
5. Добавить ключи
|
||||
_DECORT_APP_SECRET_ и _DECORT_APP_ID_
|
||||
в качестве переменных окружения, либо
|
||||
можно добавить `app_id` и `app_secret`
|
||||
в блок `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