Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce4b847596 |
130
CHANGELOG.md
130
CHANGELOG.md
@@ -1,128 +1,6 @@
|
|||||||
## Version 4.6.0
|
## Version 4.4.3
|
||||||
|
|
||||||
### Feature
|
|
||||||
|
|
||||||
#### general
|
|
||||||
- Add sort_by optional string field for the below data sources in cloudapi and cloudbroker:
|
|
||||||
|
|
||||||
| group | cloudapi data sources | cloudbroker data sources |
|
|
||||||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| account | decort_account_computes_list</br>decort_account_deleted_list</br>decort_account_disks_list</br>decort_account_list</br>decort_account_rg_list</br>decort_account_templates_list</br>decort_account_vins_list | decort_cb_account_computes_list</br>decort_cb_account_disks_list</br>decort_cb_account_flipgroups_list</br>decort_cb_account_list</br>decort_cb_account_list_deleted</br>decort_cb_account_rg_list</br>decort_cb_account_vins_list |
|
|
||||||
| audit | - | decort_cb_audit_list |
|
|
||||||
| bservice | decort_bservice_deleted_list</br>decort_bservice_list | - |
|
|
||||||
| disk | decort_disk_list</br>decort_disk_list_types</br>decort_disk_list_types_detailed</br>decort_disk_list_unattached</br>decort_disk_list_deleted | decort_cb_disk_list</br>decort_cb_disk_list_deleted</br>decort_cb_disk_list_types</br>decort_cb_disk_list_types_detailed</br>decort_cb_disk_list_unattached |
|
|
||||||
| extnet | decort_extnet_computes_list</br>decort_extnet_list | decort_cb_extnet_list |
|
|
||||||
| flipgroup | decort_flipgroup_list | decort_cb_flipgroup_list |
|
|
||||||
| grid | - | decort_cb_grid_list |
|
|
||||||
| image | decort_image_list | decort_cb_image_list</br>decort_cb_image_list_stacks |
|
|
||||||
| k8ci | decort_k8ci_list | decort_cb_k8ci_list</br>decort_cb_k8ci_list_deleted |
|
|
||||||
| k8s | decort_k8s_list</br>decort_k8s_list_deleted | decort_cb_k8s_list</br>decort_cb_k8s_list_deleted |
|
|
||||||
| kvmvm | decort_kvmvm_list</br>decort_kvmvm_list_deleted</br>decort_kvmvm_pci_device_list</br>decort_kvmvm_vgpu_list | decort_cb_kvmvm_list</br>decort_cb_kvmvm_list_deleted</br>decort_cb_kvmvm_pci_device_list</br>decort_cb_kvmvm_vgpu_list |
|
|
||||||
| lb | decort_lb_list</br>decort_lb_list_deleted | decort_cb_lb_list</br>decort_cb_lb_list_deleted |
|
|
||||||
| locations | decort_locations_list | - |
|
|
||||||
| rg | decort_rg_list</br>decort_rg_list_computes</br>decort_rg_list_deleted</br>decort_rg_list_lb</br>decort_rg_list_vins | decort_cb_rg_list</br>decort_cb_rg_list_computes</br>decort_cb_rg_list_deleted</br>decort_cb_rg_list_lb</br>decort_cb_rg_list_vins |
|
|
||||||
| sep | - | decort_cb_sep_list |
|
|
||||||
| stack | decort_stack_list | decort_cb_stack_list |
|
|
||||||
| vfpool | decort_vfpool_list | decort_cb_vfpool_list |
|
|
||||||
| vins | decort_vins_list</br>decort_vins_list_deleted | decort_cb_vins_list</br>decort_cb_vins_list_deleted |
|
|
||||||
|
|
||||||
#### account:
|
|
||||||
- Add available_templates optional field to resource decort_cb_account in cloudbroker/account
|
|
||||||
- Add data source decort_cb_account_available_templates_list in cloudbroker/account
|
|
||||||
- Add compute_features computed fields to data sources decort_account, decort_account_list, decort_account_deleted_list, decort_cb_account, decort_cb_account_list, decort_account_deleted_list and to resource decort_account in cloudapi/account and cloudbroker/account
|
|
||||||
- Add compute_features optional field to resource decort_cb_account in cloudbroker/account
|
|
||||||
- Add extnet_id, free_ips computed fields to data sources decort_account_vins_list and decort_cb_account_vins_list in cloudapi/account and cloudbroker/account
|
|
||||||
|
|
||||||
#### audit:
|
|
||||||
- Add guid computed field to data source decort_cb_audit_linked_jobs in cloudbroker/audit
|
|
||||||
- Delete field status_code in data source decort_cb_audit_list in cloudbroker/audit
|
|
||||||
- Add fields min_status_code and max_status_code in data source decort_cb_audit_list in cloudbroker/audit
|
|
||||||
|
|
||||||
#### bservice:
|
|
||||||
- Add validation of ram to be divisible by 128 to resource decort_bservice_group in cloudapi/bservice
|
|
||||||
|
|
||||||
#### disks:
|
|
||||||
- Add resource and data source decort_disk_replication and decort_cb_disk_replication
|
|
||||||
- Add field replication in data sources and resource decort_disk, decort_disk_list, decort_disk_list_deleted, decort_cb_disk, decort_cb_disk_list, decort_cb_disk_list_deleted
|
|
||||||
- Add node_ids optional field to resource decort_cb_disk in cloudbroker/disk
|
|
||||||
|
|
||||||
#### flipgroup:
|
|
||||||
- Add conn_id, status and account_id optional fields to data sources decort_flipgroup_list and decort_cb_flipgroup_list in cloudapi/flipgroup and cloudbroker/flipgroup
|
|
||||||
- Add client_ids optional fields to data sources decort_flipgroup_list and decort_cb_flipgroup_list in cloudapi/flipgroup and cloudbroker/flipgroup
|
|
||||||
|
|
||||||
#### kvmvm:
|
|
||||||
- Add cd_image_id computed field to data sources decort_kvmvm, decort_kvmvm_list, decort_cb_kvmvm, decort_cb_kvmvm_list and resourced decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add natable_vins_id, natable_vins_ip, natable_vins_name, natable_vins_network and natable_vins_network_name computed fields to data source decort_cb_kvmvm and to resource decort_cb_kvmvm in cloudbroker/kvmvm
|
|
||||||
- Change field local_port (in block port_forwarding) from required to optional in resources decort_kvmvm and decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add hp_backed, cpu_pin, numa_affinity and numa_node_id computed fields to data sources decort_kvmvm, decort_kvmvm_list, decort_cb_kvmvm, decort_cb_kvmvm_list in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add hp_backed, cpu_pin, numa_affinity optional fields and numa_node_id computed field to resources decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add validation of ram to be divisible by 128 to resources decort_kvmvm and decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add name optional field to data source decort_cb_kvmvm_pci_device_list in cloudbroker/kvmvm
|
|
||||||
- Add fields image_name and virtual_image_name in resource and data source decort_cb_kvmvm in cloudbroker/kvmvm
|
|
||||||
- Add fields enabled and node_id in resource and data sources decort_cb_kvmvm, decort_cb_kvmvm_list, decort_cb_kvmvm_list_deleted in cloudbroker/kvmvm. Add field node_id in resource and data sources decort_kvmvm, decort_kvmvm_list, decort_kvmvm_list_deleted in cloudapi/kvmvm
|
|
||||||
- Delete network and extra_disk fields in data source decort_cb_kvmvm in cloudbroker/kvmvm
|
|
||||||
- Add computed fields compute_id, description, guid, hwpath, device_id, name, rg_id, stack_id, status, system_name in data source decort_kvmvm_pci_device_list in cloudapi/kvmvm
|
|
||||||
- Add computed fields account_id, created_time, deleted_time, gid, guid, vgpu_id, last_claimed_by, last_update_time, mode, pci_slot, pgpuid, profile_id, ram, reference_id, rg_id, status, type, vm_id in data sources decort_kvmvm_vgpu_list and decort_cb_kvmvm_vgpu_list in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add field replication (disk_id, pool_id, role, self_volume_id, storage_id, volume_id) in data source decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add computed field reserved_node_cpus in data sources decort_kvmvm, decort_kvmvm_list, decort_kvmvm_list_deleted, decort_cb_kvmvm, decort_cb_kvmvm_list, decort_cb_kvmvm_list_deleted and in resources decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add "VFNIC" as allowed net_type value in network block for resources decort_kvmvm and decort_cb_kvmvm (created with "KVM_X86" driver) in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Set optional field image_id in resource decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add optional field without_boot_disk in resource decort_kvmvm, decort_cb_kvmvm in cloudapi/kvmvm and cloudbroker/kvmvm
|
|
||||||
- Add optional fields depresent, node_ids in resource decort_cb_kvmvm in cloudbroker/kvmvm
|
|
||||||
|
|
||||||
#### image:
|
|
||||||
- Add cd_presented_to computed field to data sources decort_image, decort_cb_image and to resources decort_image, decort_cb_image in cloudapi/image and cloudbroker/image
|
|
||||||
- Add account_id required field to resource decort_image in cloudapi/image
|
|
||||||
- Add accounts optional field to resource decort_cb_image in cloudbroker/image
|
|
||||||
- Add network_interface_naming computed field to data sources decort_image, decort_image_list, decort_cb_image, decort_cb_image_list and to resources decort_image, decort_cb_image in cloudapi/image and cloudbroker/image
|
|
||||||
- Delete gid required field from resource decort_image in cloudapi/image
|
|
||||||
- Delete meta and ckey computed fields from data sources and resource decort_cb_image and decort_cb_image_list in cloudbroker/image
|
|
||||||
- Add resource decort_image_from_blank_compute and decort_cb_image_from_blank_compute in cloudapi/compute and cloudbroker/compute
|
|
||||||
- Add resource decort_image_from_platoform_disk and decort_cb_image_from_platoform_disk in cloudapi/compute and cloudbroker/compute
|
|
||||||
- Add file_path optional field to resource decort_cb_image in cloudbroker/image
|
|
||||||
- Сhanged url field from required to optional in resource decort_cb_image in cloudbroker/image
|
|
||||||
|
|
||||||
#### k8s:
|
|
||||||
- Change lb_sysctl_params optional field from string to array in resources decort_k8s and decort_k8s_cp in cloudapi/k8s
|
|
||||||
- Add lb_sysctl_params optional field to resource decort_cb_k8s_cp in cloudbroker/k8s
|
|
||||||
- Add validation of ram to be divisible by 128 to resources decort_k8s, decort_k8s_cp, decort_k8s_wg, decort_cb_k8s_cp and decort_cb_k8s_wg in cloudapi/k8s and cloudbroker/k8s
|
|
||||||
- Change possible values num field (can be 5) in resources decort_k8s(cloudapi/k8s), decort_k8s_cp(cloudapi/k8s) and decort_cb_k8s_cp(cloudbroker/k8s)
|
|
||||||
|
|
||||||
#### lb:
|
|
||||||
- Add user_managed, manager_id, manager_type and part_k8s computed fields to data sources decort_lb, decort_lb_list, decort_cb_lb, decort_cb_lb_list and to resources decort_lb, decort_cb_lb in cloudapi/lb and cloudbroker/lb
|
|
||||||
- Add sysctl_params optional field to resources decort_lb and decort_cb_lb in cloudapi/lb and cloudbroker/lb
|
|
||||||
- Add safe optional field to resource decort_cb_lb in cloudbroker/lb
|
|
||||||
|
|
||||||
#### node:
|
|
||||||
- Add data sources decort_cb_node and decort_cb_node_list in cloudbroker/node
|
|
||||||
|
|
||||||
#### rg:
|
|
||||||
- Add compute_features computed fields to data sources decort_resgroup, decort_rg_list, decort_rg_list_deleted, decort_cb_rg, decort_cb_rg_list, decort_cb_rg_list_deleted and to resource decort_resgroup in clouapi/rg and cloudbroker/rg
|
|
||||||
- Add compute_features optional field to resource decort_cb_rg in cloudbroker/rg
|
|
||||||
- Add extnet_id, free_ips computed fields to data sources decort_rg_vins_list and decort_cb_rg_vins_list in cloudapi/rg and cloudbroker/rg
|
|
||||||
- Change resource quota handling logic in cloudapi to be like cloudbroker's. Added "cu_d" field into cloudapi resource quota schema. Deleted default values of "cpu", "ram", "disk", "ext_traffic", "ext_ips" and "gpu_units" fields in cloudapi resource schema
|
|
||||||
|
|
||||||
#### sep:
|
|
||||||
- Add pools optional field to resource decort_cb_sep in cloudbroker/sep
|
|
||||||
- Change config field from optional to required in resource decort_cb_sep in cloudbroker/sep
|
|
||||||
|
|
||||||
#### user:
|
|
||||||
- Add data sources decort_cb_user, decort_cb_user_list and decort_cb_user_get_audit in cloudbroker/user
|
|
||||||
- Add resource decort_cb_user in cloudbroker/user
|
|
||||||
|
|
||||||
#### vfpool:
|
|
||||||
- Add data sources decort_vfpool, decort_vfpool_list and decort_cb_vfpool, decort_cb_vfpool_list in cloudapi/vfpool and cloudbroker/vfpool
|
|
||||||
- Add resource decort_cb_vfpool in cloudbroker/vfpool
|
|
||||||
|
|
||||||
#### vins:
|
|
||||||
- Change field int_port (in block nat_rule) from required to optional in resource decort_cb_vins in cloudbroker/vins
|
|
||||||
- Add extnet_id, free_ips computed fields to data sources decort_vins_list, decort_cb_vins_list in cloudapi/vins and cloudbroker/vins
|
|
||||||
- Add dns optional field to resources decort_vins and decort_cb_vins in cloudapi/vins and cloudbroker/vins
|
|
||||||
- Add node_id computed field to resources and data sources decort_vins and decort_cb_vins in cloudapi/vins and cloudbroker/vins
|
|
||||||
- Add vnfdev_id optional field to data sources decort_cb_vins_list in cloudbroker/vins
|
|
||||||
- Add vnfdev_id optional field to data sources decort_vins_list_deleted in cloudapi/vins
|
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Fix boot_disk_size field to be saved correctly in state in order to stop unnecessary resource update attempts after `terraform apply` in resource decort_cb_kvmvm in cloudbroker/kvmvm
|
- Fixed panic
|
||||||
- Rename computed field name to k8s_name in order to fix state in data source decort_k8s_list_deleted in cloudapi/k8s
|
- Fixed field description in cloudapi/kvmvm/resource_compute
|
||||||
- Delete account_id field in data sources decort_rg_list_lb and decort_cb_rg_list_lb in cloudapi/rg and cloubroker/rg
|
- Fixed field owner in request create lb in cloudapi/cloudbroker
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
|||||||
BINARY=${NAME}
|
BINARY=${NAME}
|
||||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=4.6.0
|
VERSION=4.4.3
|
||||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||||
|
|
||||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||||
|
|||||||
58
README.md
58
README.md
@@ -6,8 +6,6 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
| Версия DECORT API | Версия провайдера Terraform |
|
| Версия DECORT API | Версия провайдера Terraform |
|
||||||
| ------ | ------ |
|
| ------ | ------ |
|
||||||
| 4.4.0 | 4.6.x |
|
|
||||||
| 3.8.9 | 4.5.x |
|
|
||||||
| 3.8.8 | 4.4.x |
|
| 3.8.8 | 4.4.x |
|
||||||
| 3.8.7 | 4.3.x |
|
| 3.8.7 | 4.3.x |
|
||||||
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
|
||||||
@@ -28,43 +26,23 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
|
|||||||
|
|
||||||
## Возможности провайдера
|
## Возможности провайдера
|
||||||
|
|
||||||
- Режим пользователя:
|
- Работа с Compute instances,
|
||||||
- Работа с accounts,
|
- Работа с disks,
|
||||||
- Работа с bservice,
|
- Работа с k8s,
|
||||||
- Работа с disks,
|
- Работа с image,
|
||||||
- Работа с extnets,
|
- Работа с flipgroups,
|
||||||
- Работа с flipgroups,
|
- Работа с stacks,
|
||||||
- Работа с image,
|
- Работа с reource groups,
|
||||||
- Работа с k8s,
|
- Работа с VINS,
|
||||||
- Работа с Compute instances,
|
- Работа с pfw,
|
||||||
- Работа с load balancer,
|
- Работа с accounts,
|
||||||
- Работа с locations,
|
- Работа с snapshots,
|
||||||
- Работа с pfw,
|
- Работа с bservice,
|
||||||
- Работа с resource groups,
|
- Работа с extnets,
|
||||||
- Работа с snapshots,
|
- Работа с locations,
|
||||||
- Работа с stacks,
|
- Работа с load balancer.
|
||||||
- Работа с VINS.
|
|
||||||
|
|
||||||
- Режим администратора:
|
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
- Работа с accounts,
|
|
||||||
- Работа с audits,
|
|
||||||
- Работа с disks,
|
|
||||||
- Работа с extnets,
|
|
||||||
- Работа с flipgroups,
|
|
||||||
- Работа с grids,
|
|
||||||
- Работа с images,
|
|
||||||
- Работа с k8ci,
|
|
||||||
- Работа с k8s,
|
|
||||||
- Работа с Compute instances,
|
|
||||||
- Работа с load balancer,
|
|
||||||
- Работа с pci device,
|
|
||||||
- Работа с resource groups,
|
|
||||||
- Работа с seps,
|
|
||||||
- Работа с user,
|
|
||||||
- Работа с stacks,
|
|
||||||
- Работа с VINS.
|
|
||||||
|
|
||||||
Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
|
|
||||||
## Установка
|
## Установка
|
||||||
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
|
||||||
@@ -111,7 +89,7 @@ terraform {
|
|||||||
9. Добавьте в файл блок с инициализацией провайдера.
|
9. Добавьте в файл блок с инициализацией провайдера.
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
controller_url = "https://mr4.digitalenergy.online"
|
controller_url = "https://mr4.digitalenergy.online"
|
||||||
oauth2_url = "https://sso.digitalenergy.online"
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
@@ -197,7 +175,7 @@ ${host_name}/${namespace}/${type}
|
|||||||
8. Добавьте в файл блок с инициализацией провайдера.
|
8. Добавьте в файл блок с инициализацией провайдера.
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
controller_url = "https://mr4.digitalenergy.online"
|
controller_url = "https://mr4.digitalenergy.online"
|
||||||
oauth2_url = "https://sso.digitalenergy.online"
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Two ways for starting:
|
|||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
provider "decort" {
|
provider "decort" {
|
||||||
authenticator = "decs3o"
|
authenticator = "oauth2"
|
||||||
#controller_url = <DECORT_CONTROLLER_URL>
|
#controller_url = <DECORT_CONTROLLER_URL>
|
||||||
controller_url = "https://ds1.digitalenergy.online"
|
controller_url = "https://ds1.digitalenergy.online"
|
||||||
#oauth2_url = <DECORT_SSO_URL>
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
|||||||
48
go.mod
48
go.mod
@@ -1,27 +1,27 @@
|
|||||||
module repository.basistech.ru/BASIS/terraform-provider-decort
|
module repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
go 1.20
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/google/uuid v1.4.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0
|
github.com/hashicorp/terraform-plugin-docs v0.13.0
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
golang.org/x/net v0.19.0
|
golang.org/x/net v0.17.0
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.10
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
github.com/Masterminds/semver/v3 v3.2.0 // indirect
|
github.com/Masterminds/semver/v3 v3.2.0 // indirect
|
||||||
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
||||||
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
|
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
|
||||||
github.com/agext/levenshtein v1.2.3 // indirect
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||||
github.com/armon/go-radix v1.0.0 // indirect
|
github.com/armon/go-radix v1.0.0 // indirect
|
||||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||||
github.com/cloudflare/circl v1.3.7 // indirect
|
github.com/cloudflare/circl v1.3.3 // indirect
|
||||||
github.com/fatih/color v1.16.0 // indirect
|
github.com/fatih/color v1.13.0 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
@@ -35,24 +35,24 @@ require (
|
|||||||
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
|
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
|
||||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
github.com/hashicorp/go-plugin v1.6.0 // indirect
|
github.com/hashicorp/go-plugin v1.5.1 // indirect
|
||||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||||
github.com/hashicorp/hc-install v0.6.3 // indirect
|
github.com/hashicorp/hc-install v0.6.1 // indirect
|
||||||
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
|
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
|
||||||
github.com/hashicorp/logutils v1.0.0 // indirect
|
github.com/hashicorp/logutils v1.0.0 // indirect
|
||||||
github.com/hashicorp/terraform-exec v0.20.0 // indirect
|
github.com/hashicorp/terraform-exec v0.19.0 // indirect
|
||||||
github.com/hashicorp/terraform-json v0.21.0 // indirect
|
github.com/hashicorp/terraform-json v0.17.1 // indirect
|
||||||
github.com/hashicorp/terraform-plugin-go v0.22.0 // indirect
|
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
|
||||||
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
|
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
|
||||||
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
|
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
|
||||||
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
|
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/huandu/xstrings v1.4.0 // indirect
|
github.com/huandu/xstrings v1.4.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.15 // indirect
|
github.com/imdario/mergo v0.3.15 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||||
github.com/mitchellh/cli v1.1.5 // indirect
|
github.com/mitchellh/cli v1.1.5 // indirect
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||||
@@ -65,16 +65,16 @@ require (
|
|||||||
github.com/shopspring/decimal v1.3.1 // indirect
|
github.com/shopspring/decimal v1.3.1 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
github.com/zclconf/go-cty v1.14.2 // indirect
|
github.com/zclconf/go-cty v1.14.1 // indirect
|
||||||
golang.org/x/crypto v0.19.0 // indirect
|
golang.org/x/crypto v0.15.0 // indirect
|
||||||
golang.org/x/mod v0.15.0 // indirect
|
golang.org/x/mod v0.13.0 // indirect
|
||||||
golang.org/x/sys v0.17.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
google.golang.org/appengine v1.6.8 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
|
||||||
google.golang.org/grpc v1.61.1 // indirect
|
google.golang.org/grpc v1.57.1 // indirect
|
||||||
google.golang.org/protobuf v1.32.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
113
go.sum
113
go.sum
@@ -8,8 +8,9 @@ github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFP
|
|||||||
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
|
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
|
||||||
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
||||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||||
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 h1:nHGfwXmFvJrSR9xu8qL7BkO4DqTHXE9N5vPhgY2I+j0=
|
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
|
||||||
github.com/ProtonMail/go-crypto v1.1.0-alpha.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
|
||||||
|
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
|
||||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||||
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
|
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
|
||||||
@@ -21,23 +22,23 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI
|
|||||||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
||||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||||
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
||||||
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||||
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
|
||||||
|
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
|
||||||
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
|
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
|
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
|
||||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
|
||||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||||
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
|
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
|
||||||
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
|
github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
@@ -48,8 +49,8 @@ github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QX
|
|||||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
@@ -61,8 +62,8 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
|
|||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
@@ -78,33 +79,33 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
|
|||||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||||
github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A=
|
github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k=
|
||||||
github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
|
github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
|
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
|
||||||
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
github.com/hashicorp/hc-install v0.6.3 h1:yE/r1yJvWbtrJ0STwScgEnCanb0U9v7zp0Gbkmcoxqs=
|
github.com/hashicorp/hc-install v0.6.1 h1:IGxShH7AVhPaSuSJpKtVi/EFORNjO+OYVJJrAtGG2mY=
|
||||||
github.com/hashicorp/hc-install v0.6.3/go.mod h1:KamGdbodYzlufbWh4r9NRo8y6GLHWZP2GBtdnms1Ln0=
|
github.com/hashicorp/hc-install v0.6.1/go.mod h1:0fW3jpg+wraYSnFDJ6Rlie3RvLf1bIqVIkzoon4KoVE=
|
||||||
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
|
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
|
||||||
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
|
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
|
||||||
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo=
|
github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM=
|
||||||
github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw=
|
github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg=
|
||||||
github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U=
|
github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA=
|
||||||
github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
|
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
|
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
|
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
|
||||||
github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc=
|
github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU=
|
||||||
github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE=
|
github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec=
|
||||||
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
|
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
|
||||||
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
|
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8=
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 h1:X7vB6vn5tON2b49ILa4W7mFAsndeqJ7bZFOGbVO+0Cc=
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0/go.mod h1:ydFcxbdj6klCqYEPkPvdvFKiNGKZLUs+896ODUXCyao=
|
||||||
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
|
github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno=
|
||||||
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
|
github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo=
|
||||||
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
|
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
|
||||||
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
|
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
|
||||||
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
@@ -136,9 +137,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
|||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
|
||||||
github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng=
|
github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng=
|
||||||
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
|
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
|
||||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
||||||
@@ -170,7 +170,7 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
|
|||||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
|
github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM=
|
||||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
||||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||||
@@ -190,34 +190,41 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
|||||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
|
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI=
|
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
|
||||||
github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
|
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||||
|
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
||||||
|
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||||
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -232,37 +239,43 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
|
||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
|
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
|
||||||
google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY=
|
google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg=
|
||||||
google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
|
google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -272,5 +285,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1 h1:wpxjnVO7hGaQVWbtFoYVbNoeFxk0QUnEfDsPuWjiNk0=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.10 h1:3DSdLI1exX+QFO9FKmpw5r7duOKI1rITqSBsTYFdSyw=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1/go.mod h1:OaUynHHuSjWMzpfyoL4au6oLcUogqUkPPBKA15pbHWo=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.10/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||||
|
|||||||
@@ -20,23 +20,20 @@ limitations under the License.
|
|||||||
|
|
||||||
package constants
|
package constants
|
||||||
|
|
||||||
// LIMIT_MAX_VINS_PER_RESGROUP set maximum number of VINs instances per Resource Group
|
// LimitMaxVinsPerResgroup set maximum number of VINs instances per Resource Group
|
||||||
const LIMIT_MAX_VINS_PER_RESGROUP = 4
|
const LimitMaxVinsPerResgroup = 4
|
||||||
|
|
||||||
// MAX_SSHKEYS_PER_COMPUTE sets maximum number of user:ssh_key pairs to authorize when creating new compute
|
// MaxSshKeysPerCompute sets maximum number of user:ssh_key pairs to authorize when creating new compute
|
||||||
const MAX_SSHKEYS_PER_COMPUTE = 12
|
const MaxSshKeysPerCompute = 12
|
||||||
|
|
||||||
// MAX_EXTRA_DISKS_PER_COMPUTE sets maximum number of extra disks that can be added when creating new compute
|
// MaxExtraDisksPerCompute sets maximum number of extra disks that can be added when creating new compute
|
||||||
const MAX_EXTRA_DISKS_PER_COMPUTE = 12
|
const MaxExtraDisksPerCompute = 12
|
||||||
|
|
||||||
// MAX_NETWORKS_PER_COMPUTE sets maximum number of vNICs per compute
|
// MaxNetworksPerCompute sets maximum number of vNICs per compute
|
||||||
const MAX_NETWORKS_PER_COMPUTE = 8
|
const MaxNetworksPerCompute = 8
|
||||||
|
|
||||||
// MAX_CPUS_PER_COMPUTE sets maximum number of vCPUs per compute
|
// MaxCpusPerCompute sets maximum number of vCPUs per compute
|
||||||
const MAX_CPUS_PER_COMPUTE = 128
|
const MaxCpusPerCompute = 128
|
||||||
|
|
||||||
// MIN_RAM_PER_COMPUTE sets minimum amount of RAM per compute in MB
|
// MinRamPerCompute sets minimum amount of RAM per compute in MB
|
||||||
const MIN_RAM_PER_COMPUTE = 128
|
const MinRamPerCompute = 128
|
||||||
|
|
||||||
// RAM_DIVISIBILITY sets divisibility of RAM value
|
|
||||||
const RAM_DIVISIBILITY = 128
|
|
||||||
|
|||||||
@@ -1,33 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package constants
|
package constants
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
// timeouts for API calls from CRUD functions of Terraform plugin
|
// timeouts for API calls from CRUD functions of Terraform plugin
|
||||||
var Timeout30s = time.Second * 30
|
var Timeout30s = time.Second * 30
|
||||||
var Timeout60s = time.Second * 60
|
var Timeout60s = time.Second * 60
|
||||||
var Timeout180s = time.Second * 180
|
var Timeout180s = time.Second * 180
|
||||||
var Timeout300s = time.Second * 300
|
var Timeout300s = time.Second * 300
|
||||||
var Timeout600s = time.Second * 600
|
var Timeout600s = time.Second * 600
|
||||||
var Timeout900s = time.Second * 900
|
var Timeout20m = time.Minute * 20
|
||||||
var Timeout20m = time.Minute * 20
|
var Timeout30m = time.Minute * 30
|
||||||
var Timeout30m = time.Minute * 30
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
@@ -23,13 +23,14 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io/ioutil"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
// "time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
@@ -42,32 +43,24 @@ import (
|
|||||||
|
|
||||||
// enumerated constants that define authentication modes
|
// enumerated constants that define authentication modes
|
||||||
const (
|
const (
|
||||||
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
MODE_UNDEF = iota // this is the invalid mode - it should never be seen
|
||||||
MODE_LEGACY
|
MODE_LEGACY = iota
|
||||||
MODE_DECS3O
|
MODE_OAUTH2 = iota
|
||||||
MODE_JWT
|
MODE_JWT = iota
|
||||||
MODE_BVS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControllerCfg struct {
|
type ControllerCfg struct {
|
||||||
controller_url string // always required
|
controller_url string // always required
|
||||||
auth_mode_code int // always required
|
auth_mode_code int // always required
|
||||||
auth_mode_txt string // always required, it is a text representation of auth mode
|
auth_mode_txt string // always required, it is a text representation of auth mode
|
||||||
bvs_user string // required for bvs mode
|
|
||||||
bvs_password string // required for bvs mode
|
|
||||||
domain string // required for bvs mode
|
|
||||||
token config.Token // obtained from BVS provider on successful login in bvs mode
|
|
||||||
path_cfg string // the path of the configuration file entry
|
|
||||||
path_token string // the path of the token file entry
|
|
||||||
time_to_refresh int64 // the number of minutes before the expiration of the token, a refresh will be made
|
|
||||||
legacy_user string // required for legacy mode
|
legacy_user string // required for legacy mode
|
||||||
legacy_password string // required for legacy mode
|
legacy_password string // required for legacy mode
|
||||||
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
legacy_sid string // obtained from DECORT controller on successful login in legacy mode
|
||||||
jwt string // obtained from Outh2 provider on successful login in decs3o mode, required in jwt mode
|
jwt string // obtained from Outh2 provider on successful login in oauth2 mode, required in jwt mode
|
||||||
app_id string // required for decs3o and bvs mode
|
app_id string // required for oauth2 mode
|
||||||
app_secret string // required for decs3o and bvs mode
|
app_secret string // required for oauth2 mode
|
||||||
oauth2_url string // required for decs3o and bvs mode
|
oauth2_url string // always required
|
||||||
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (decs3o mode) upon successful verification
|
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (oauth2 mode) upon successful verification
|
||||||
cc_client *http.Client // assigned when all initial checks successfully passed
|
cc_client *http.Client // assigned when all initial checks successfully passed
|
||||||
caller interfaces.Caller
|
caller interfaces.Caller
|
||||||
}
|
}
|
||||||
@@ -90,24 +83,17 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
legacy_user: d.Get("user").(string),
|
legacy_user: d.Get("user").(string),
|
||||||
legacy_password: d.Get("password").(string),
|
legacy_password: d.Get("password").(string),
|
||||||
legacy_sid: "",
|
legacy_sid: "",
|
||||||
bvs_user: d.Get("bvs_user").(string),
|
|
||||||
bvs_password: d.Get("bvs_password").(string),
|
|
||||||
domain: d.Get("domain").(string),
|
|
||||||
jwt: d.Get("jwt").(string),
|
jwt: d.Get("jwt").(string),
|
||||||
app_id: d.Get("app_id").(string),
|
app_id: d.Get("app_id").(string),
|
||||||
app_secret: d.Get("app_secret").(string),
|
app_secret: d.Get("app_secret").(string),
|
||||||
oauth2_url: d.Get("oauth2_url").(string),
|
oauth2_url: d.Get("oauth2_url").(string),
|
||||||
decort_username: "",
|
decort_username: "",
|
||||||
token: config.Token{},
|
|
||||||
path_cfg: d.Get("path_cfg").(string),
|
|
||||||
path_token: d.Get("path_token").(string),
|
|
||||||
time_to_refresh: int64(d.Get("time_to_refresh").(int)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
|
||||||
|
|
||||||
if ret_config.controller_url == "" {
|
if ret_config.controller_url == "" {
|
||||||
return nil, fmt.Errorf("empty DECORT cloud controller URL provided")
|
return nil, fmt.Errorf("Empty DECORT cloud controller URL provided.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
// this should have already been done by StateFunc defined in Schema, but we want to be sure
|
||||||
@@ -116,53 +102,33 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
switch ret_config.auth_mode_txt {
|
switch ret_config.auth_mode_txt {
|
||||||
case "jwt":
|
case "jwt":
|
||||||
if ret_config.jwt == "" {
|
if ret_config.jwt == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'jwt' specified but no JWT provided")
|
return nil, fmt.Errorf("Authenticator mode 'jwt' specified but no JWT provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_JWT
|
ret_config.auth_mode_code = MODE_JWT
|
||||||
case "decs3o":
|
case "oauth2":
|
||||||
if ret_config.oauth2_url == "" {
|
if ret_config.oauth2_url == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no OAuth2 URL provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no OAuth2 URL provided.")
|
||||||
}
|
}
|
||||||
if ret_config.app_id == "" {
|
if ret_config.app_id == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Application ID provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Application ID provided.")
|
||||||
}
|
}
|
||||||
if ret_config.app_secret == "" {
|
if ret_config.app_secret == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Secret ID provided")
|
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Secret ID provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_DECS3O
|
ret_config.auth_mode_code = MODE_OAUTH2
|
||||||
case "legacy":
|
case "legacy":
|
||||||
//
|
//
|
||||||
ret_config.legacy_user = d.Get("user").(string)
|
ret_config.legacy_user = d.Get("user").(string)
|
||||||
if ret_config.legacy_user == "" {
|
if ret_config.legacy_user == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no user provided")
|
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no user provided.")
|
||||||
}
|
}
|
||||||
ret_config.legacy_password = d.Get("password").(string)
|
ret_config.legacy_password = d.Get("password").(string)
|
||||||
if ret_config.legacy_password == "" {
|
if ret_config.legacy_password == "" {
|
||||||
return nil, fmt.Errorf("authenticator mode 'legacy' specified but no password provided")
|
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no password provided.")
|
||||||
}
|
}
|
||||||
ret_config.auth_mode_code = MODE_LEGACY
|
ret_config.auth_mode_code = MODE_LEGACY
|
||||||
case "bvs":
|
|
||||||
if ret_config.bvs_user == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no user provided")
|
|
||||||
}
|
|
||||||
if ret_config.bvs_password == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no password provided")
|
|
||||||
}
|
|
||||||
if ret_config.oauth2_url == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no bvs URL provided")
|
|
||||||
}
|
|
||||||
if ret_config.app_id == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Application ID provided")
|
|
||||||
}
|
|
||||||
if ret_config.app_secret == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Secret ID provided")
|
|
||||||
}
|
|
||||||
if ret_config.domain == "" {
|
|
||||||
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Domain provided")
|
|
||||||
}
|
|
||||||
ret_config.auth_mode_code = MODE_BVS
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown authenticator mode %q provided", ret_config.auth_mode_txt)
|
return nil, fmt.Errorf("Unknown authenticator mode %q provided.", ret_config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if allow_unverified_ssl {
|
if allow_unverified_ssl {
|
||||||
@@ -198,16 +164,16 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case MODE_DECS3O:
|
case MODE_OAUTH2:
|
||||||
// on success getDECS3OJWT will set config.jwt to the obtained JWT, so there is no
|
// on success getOAuth2JWT will set config.jwt to the obtained JWT, so there is no
|
||||||
// need to set it once again here
|
// need to set it once again here
|
||||||
// _, err := ret_config.getDECS3OJWT()
|
// _, err := ret_config.getOAuth2JWT()
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// we are not verifying the JWT when parsing because actual verification is done on the
|
// // we are not verifying the JWT when parsing because actual verification is done on the
|
||||||
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
// // OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
|
||||||
// and JWT issuer name (claim "iss")
|
// // and JWT issuer name (claim "iss")
|
||||||
// parser := jwt.Parser{}
|
// parser := jwt.Parser{}
|
||||||
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@@ -220,7 +186,7 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// tbuf.WriteString(claims["iss"].(string))
|
// tbuf.WriteString(claims["iss"].(string))
|
||||||
// ret_config.decort_username = tbuf.String()
|
// ret_config.decort_username = tbuf.String()
|
||||||
// } else {
|
// } else {
|
||||||
// return nil, fmt.Errorf("failed to extract user and iss fields from JWT token in oauth2 mode")
|
// return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
sdkConf := config.Config{
|
sdkConf := config.Config{
|
||||||
@@ -232,27 +198,10 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_config.caller = decort.New(sdkConf)
|
ret_config.caller = decort.New(sdkConf)
|
||||||
case MODE_BVS:
|
|
||||||
|
|
||||||
sdkConf := config.BVSConfig{
|
|
||||||
AppID: ret_config.app_id,
|
|
||||||
AppSecret: ret_config.app_secret,
|
|
||||||
SSOURL: ret_config.oauth2_url,
|
|
||||||
DecortURL: ret_config.controller_url,
|
|
||||||
SSLSkipVerify: allow_unverified_ssl,
|
|
||||||
Username: ret_config.bvs_user,
|
|
||||||
Password: ret_config.bvs_password,
|
|
||||||
Domain: ret_config.domain,
|
|
||||||
Token: ret_config.token,
|
|
||||||
PathCfg: ret_config.path_cfg,
|
|
||||||
PathToken: ret_config.path_token,
|
|
||||||
TimeToRefresh: ret_config.time_to_refresh,
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_config.caller = decort.NewBVS(sdkConf)
|
|
||||||
default:
|
default:
|
||||||
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
// FYI, this should never happen due to all above checks, but we want to be fool proof
|
||||||
return nil, fmt.Errorf("unknown authenticator mode code %d provided", ret_config.auth_mode_code)
|
return nil, fmt.Errorf("Unknown authenticator mode code %d provided.", ret_config.auth_mode_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
// All checks passed successfully, credentials corresponding to the selected authenticator mode
|
||||||
@@ -264,13 +213,13 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// return config.decort_username
|
// return config.decort_username
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func (config *ControllerCfg) getDECS3OJWT() (string, error) {
|
// func (config *ControllerCfg) getOAuth2JWT() (string, error) {
|
||||||
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
|
||||||
// if config.auth_mode_code == MODE_UNDEF {
|
// if config.auth_mode_code == MODE_UNDEF {
|
||||||
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode")
|
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.")
|
||||||
// }
|
// }
|
||||||
// if config.auth_mode_code != MODE_DECS3O {
|
// if config.auth_mode_code != MODE_OAUTH2 {
|
||||||
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q", config.auth_mode_txt)
|
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// params := url.Values{}
|
// params := url.Values{}
|
||||||
@@ -301,7 +250,7 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
// }
|
// }
|
||||||
// defer resp.Body.Close()
|
// defer resp.Body.Close()
|
||||||
|
|
||||||
// responseData, err := io.ReadAll(resp.Body)
|
// responseData, err := ioutil.ReadAll(resp.Body)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return "", err
|
// return "", err
|
||||||
// }
|
// }
|
||||||
@@ -321,13 +270,13 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
*/
|
*/
|
||||||
if jwt == "" {
|
if jwt == "" {
|
||||||
if config.jwt == "" {
|
if config.jwt == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided")
|
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided.")
|
||||||
}
|
}
|
||||||
jwt = config.jwt
|
jwt = config.jwt
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.oauth2_url == "" {
|
if config.oauth2_url == "" {
|
||||||
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided")
|
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided.")
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
|
||||||
@@ -344,7 +293,7 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q",
|
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q.",
|
||||||
resp.StatusCode, req.URL)
|
resp.StatusCode, req.URL)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@@ -360,10 +309,10 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
reason, the method will return false and error.
|
reason, the method will return false and error.
|
||||||
*/
|
*/
|
||||||
if config.auth_mode_code == MODE_UNDEF {
|
if config.auth_mode_code == MODE_UNDEF {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode")
|
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode.")
|
||||||
}
|
}
|
||||||
if config.auth_mode_code != MODE_LEGACY {
|
if config.auth_mode_code != MODE_LEGACY {
|
||||||
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q", config.auth_mode_txt)
|
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q.", config.auth_mode_txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
@@ -384,12 +333,12 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q",
|
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q.",
|
||||||
resp.StatusCode, config.legacy_user, config.controller_url)
|
resp.StatusCode, config.legacy_user, config.controller_url)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
responseData, err := io.ReadAll(req.Body)
|
responseData, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -401,32 +350,21 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
|
||||||
switch config.auth_mode_code {
|
if config.auth_mode_code == MODE_LEGACY {
|
||||||
case MODE_LEGACY:
|
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudAPI()
|
return client.CloudAPI()
|
||||||
case MODE_DECS3O:
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudAPI()
|
|
||||||
case MODE_BVS:
|
|
||||||
client, _ := config.caller.(*decort.BVSDecortClient)
|
|
||||||
return client.CloudAPI()
|
|
||||||
default:
|
|
||||||
return &cloudapi.CloudAPI{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudAPI()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
|
||||||
switch config.auth_mode_code {
|
if config.auth_mode_code == MODE_LEGACY {
|
||||||
case MODE_LEGACY:
|
|
||||||
client, _ := config.caller.(*decort.LegacyDecortClient)
|
client, _ := config.caller.(*decort.LegacyDecortClient)
|
||||||
return client.CloudBroker()
|
return client.CloudBroker()
|
||||||
case MODE_DECS3O:
|
|
||||||
client, _ := config.caller.(*decort.DecortClient)
|
|
||||||
return client.CloudBroker()
|
|
||||||
case MODE_BVS:
|
|
||||||
client, _ := config.caller.(*decort.BVSDecortClient)
|
|
||||||
return client.CloudBroker()
|
|
||||||
default:
|
|
||||||
return &cloudbroker.CloudBroker{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client, _ := config.caller.(*decort.DecortClient)
|
||||||
|
return client.CloudBroker()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package location
|
package location
|
||||||
|
|
||||||
const LOCATIONS_LIST_API = "/restmachine/cloudapi/locations/list" // Returns list of GridRecord on success
|
const LocationsListAPI = "/restmachine/cloudapi/locations/list" // Returns list of GridRecord on success
|
||||||
|
|||||||
@@ -1,269 +1,172 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vfpool"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
|
||||||
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
)
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
|
||||||
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
func newDataSourcesMap() map[string]*schema.Resource {
|
||||||
cb_node "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/node"
|
return map[string]*schema.Resource{
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
"decort_account": account.DataSourceAccount(),
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||||
cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
|
"decort_resgroup": rg.DataSourceResgroup(),
|
||||||
cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user"
|
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||||
cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool"
|
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||||
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||||
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||||
)
|
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||||
|
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
func newDataSourcesMap() map[string]*schema.Resource {
|
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||||
return map[string]*schema.Resource{
|
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||||
"decort_account": account.DataSourceAccount(),
|
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||||
"decort_resgroup": rg.DataSourceResgroup(),
|
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
"decort_k8s": k8s.DataSourceK8s(),
|
||||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||||
"decort_k8s": k8s.DataSourceK8s(),
|
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
"decort_disk": disks.DataSourceDisk(),
|
||||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
"decort_disk_list": disks.DataSourceDiskList(),
|
||||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
"decort_rg_list": rg.DataSourceRgList(),
|
||||||
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||||
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||||
"decort_disk": disks.DataSourceDisk(),
|
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||||
"decort_disk_list": disks.DataSourceDiskList(),
|
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||||
"decort_rg_list": rg.DataSourceRgList(),
|
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
"decort_account_list": account.DataSourceAccountList(),
|
||||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||||
"decort_disk_replication": disks.DataSourceDiskReplication(),
|
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||||
"decort_account_list": account.DataSourceAccountList(),
|
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
"decort_bservice": bservice.DataSourceBasicService(),
|
||||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||||
"decort_bservice": bservice.DataSourceBasicService(),
|
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
"decort_extnet": extnet.DataSourceExtnet(),
|
||||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
"decort_image_list": image.DataSourceImageList(),
|
||||||
"decort_extnet": extnet.DataSourceExtnet(),
|
"decort_image": image.DataSourceImage(),
|
||||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
"decort_lb": lb.DataSourceLB(),
|
||||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
"decort_lb_list": lb.DataSourceLBList(),
|
||||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||||
"decort_image_list": image.DataSourceImageList(),
|
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||||
"decort_image": image.DataSourceImage(),
|
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||||
"decort_lb": lb.DataSourceLB(),
|
"decort_stack": stack.DataSourceStack(),
|
||||||
"decort_lb_list": lb.DataSourceLBList(),
|
"decort_stack_list": stack.DataSourceStackList(),
|
||||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
|
||||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||||
"decort_stack": stack.DataSourceStack(),
|
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
||||||
"decort_stack_list": stack.DataSourceStackList(),
|
"decort_cb_account_deleted_list": cb_account.DataSourceAccountDeletedList(),
|
||||||
"decort_vfpool": vfpool.DataSourceVFPool(),
|
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
||||||
"decort_vfpool_list": vfpool.DataSourceVFPoolList(),
|
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||||
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
||||||
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
||||||
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
||||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
||||||
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
||||||
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||||
|
"decort_cb_image": cb_image.DataSourceImage(),
|
||||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
||||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
||||||
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
||||||
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
|
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
||||||
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
||||||
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
||||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
||||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
"decort_cb_sep": cb_sep.DataSourceSep(),
|
||||||
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
|
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
||||||
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
|
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
||||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
||||||
"decort_cb_account_available_templates_list": cb_account.DataSourceAccountAvailableTemplatesList(),
|
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
||||||
"decort_cb_audit": cb_audit.DataSourceAudit(),
|
"decort_cb_vgpu": cb_vgpu.DataSourceVGPU(),
|
||||||
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
|
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
||||||
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
|
}
|
||||||
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
|
||||||
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
}
|
||||||
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
|
||||||
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
|
|
||||||
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
|
|
||||||
"decort_cb_image": cb_image.DataSourceImage(),
|
|
||||||
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
|
||||||
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
|
|
||||||
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
|
|
||||||
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
|
|
||||||
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
|
|
||||||
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
|
||||||
"decort_cb_grid_list_emails": cb_grid.DataSourceGridListEmails(),
|
|
||||||
"decort_cb_grid_list_consumption": cb_grid.DataSourceGridListConsumption(),
|
|
||||||
"decort_cb_grid_get_consumption": cb_grid.DataSourceGridGetConsumption(),
|
|
||||||
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
|
||||||
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
|
||||||
"decort_cb_kvmvm": cb_kvmvm.DataSourceCompute(),
|
|
||||||
"decort_cb_kvmvm_affinity_relations": cb_kvmvm.DataSourceComputeAffinityRelations(),
|
|
||||||
"decort_cb_kvmvm_audits": cb_kvmvm.DataSourceComputeAudits(),
|
|
||||||
"decort_cb_kvmvm_boot_order_get": cb_kvmvm.DataSourceComputeBootOrderGet(),
|
|
||||||
"decort_cb_kvmvm_get_audits": cb_kvmvm.DataSourceComputeGetAudits(),
|
|
||||||
"decort_cb_kvmvm_get_console_url": cb_kvmvm.DataSourceComputeGetConsoleUrl(),
|
|
||||||
"decort_cb_kvmvm_get_log": cb_kvmvm.DataSourceComputeGetLog(),
|
|
||||||
"decort_cb_kvmvm_list": cb_kvmvm.DataSourceComputeList(),
|
|
||||||
"decort_cb_kvmvm_list_deleted": cb_kvmvm.DataSourceComputeListDeleted(),
|
|
||||||
"decort_cb_kvmvm_migrate_storage_info": cb_kvmvm.DataSourceComputeMigrateStorageInfo(),
|
|
||||||
"decort_cb_kvmvm_pci_device_list": cb_kvmvm.DataSourceComputePCIDeviceList(),
|
|
||||||
"decort_cb_kvmvm_pfw_list": cb_kvmvm.DataSourceComputePfwList(),
|
|
||||||
"decort_cb_kvmvm_snapshot_list": cb_kvmvm.DataSourceComputeSnapshotList(),
|
|
||||||
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
|
|
||||||
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
|
|
||||||
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
|
|
||||||
"decort_cb_node": cb_node.DataSourceNode(),
|
|
||||||
"decort_cb_node_list": cb_node.DataSourceNodeList(),
|
|
||||||
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
|
||||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
|
||||||
"decort_cb_disk_list_deleted": cb_disks.DataSourceDiskListDeleted(),
|
|
||||||
"decort_cb_disk_list_types": cb_disks.DataSourceDiskListTypes(),
|
|
||||||
"decort_cb_disk_list_types_detailed": cb_disks.DataSourceDiskListTypesDetailed(),
|
|
||||||
"decort_cb_disk_list_unattached": cb_disks.DataSourceDiskListUnattached(),
|
|
||||||
"decort_cb_disk_snapshot": cb_disks.DataSourceDiskSnapshot(),
|
|
||||||
"decort_cb_disk_snapshot_list": cb_disks.DataSourceDiskSnapshotList(),
|
|
||||||
"decort_cb_disk_replication": cb_disks.DataSourceDiskReplication(),
|
|
||||||
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
|
||||||
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
|
||||||
"decort_cb_rg": cb_rg.DataSourceResgroup(),
|
|
||||||
"decort_cb_rg_affinity_group_computes": cb_rg.DataSourceRgAffinityGroupComputes(),
|
|
||||||
"decort_cb_rg_affinity_groups_get": cb_rg.DataSourceRgAffinityGroupsGet(),
|
|
||||||
"decort_cb_rg_affinity_groups_list": cb_rg.DataSourceRgAffinityGroupsList(),
|
|
||||||
"decort_cb_rg_resource_consumption_get": cb_rg.DataSourceRGResourceConsumptionGet(),
|
|
||||||
"decort_cb_rg_resource_consumption_list": cb_rg.DataSourceRGResourceConsumptionList(),
|
|
||||||
"decort_cb_rg_audits": cb_rg.DataSourceRgAudits(),
|
|
||||||
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
|
||||||
"decort_cb_rg_list_deleted": cb_rg.DataSourceRgListDeleted(),
|
|
||||||
"decort_cb_rg_list_computes": cb_rg.DataSourceRgListComputes(),
|
|
||||||
"decort_cb_rg_list_lb": cb_rg.DataSourceRgListLb(),
|
|
||||||
"decort_cb_rg_list_pfw": cb_rg.DataSourceRgListPfw(),
|
|
||||||
"decort_cb_rg_list_vins": cb_rg.DataSourceRgListVins(),
|
|
||||||
"decort_cb_rg_usage": cb_rg.DataSourceRgUsage(),
|
|
||||||
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
|
||||||
"decort_cb_sep": cb_sep.DataSourceSep(),
|
|
||||||
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
|
||||||
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
|
||||||
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
|
||||||
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
|
||||||
"decort_cb_lb": cb_lb.DataSourceLB(),
|
|
||||||
"decort_cb_lb_list": cb_lb.DataSourceLBList(),
|
|
||||||
"decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(),
|
|
||||||
"decort_cb_flipgroup_list": cb_flipgroup.DataSourceFlipgroupList(),
|
|
||||||
"decort_cb_flipgroup": cb_flipgroup.DataSourceFlipgroup(),
|
|
||||||
"decort_cb_stack_list": cb_stack.DataSourceStacksList(),
|
|
||||||
"decort_cb_stack": cb_stack.DataSourceStack(),
|
|
||||||
"decort_cb_user": cb_user.DataSourceUser(),
|
|
||||||
"decort_cb_user_get_audit": cb_user.DataSourceUserGetAudit(),
|
|
||||||
"decort_cb_user_list": cb_user.DataSourceUserList(),
|
|
||||||
"decort_cb_vfpool": cb_vfpool.DataSourceVFPool(),
|
|
||||||
"decort_cb_vfpool_list": cb_vfpool.DataSourceVFPoolList(),
|
|
||||||
"decort_cb_vins": cb_vins.DataSourceVins(),
|
|
||||||
"decort_cb_vins_list": cb_vins.DataSourceVinsList(),
|
|
||||||
"decort_cb_vins_audits": cb_vins.DataSourceVinsAudits(),
|
|
||||||
"decort_cb_vins_ip_list": cb_vins.DataSourceVinsIpList(),
|
|
||||||
"decort_cb_vins_list_deleted": cb_vins.DataSourceVinsListDeleted(),
|
|
||||||
"decort_cb_vins_ext_net_list": cb_vins.DataSourceVinsExtNetList(),
|
|
||||||
"decort_cb_vins_nat_rule_list": cb_vins.DataSourceVinsNatRuleList(),
|
|
||||||
"decort_cb_vins_static_route": cb_vins.DataSourceStaticRoute(),
|
|
||||||
"decort_cb_vins_static_route_list": cb_vins.DataSourceStaticRouteList(),
|
|
||||||
"decort_cb_k8ci": cb_k8ci.DataSourceK8CI(),
|
|
||||||
"decort_cb_k8ci_list": cb_k8ci.DataSourceK8CIList(),
|
|
||||||
"decort_cb_k8ci_list_deleted": cb_k8ci.DataSourceK8CIListDeleted(),
|
|
||||||
"decort_cb_k8s": cb_k8s.DataSourceK8s(),
|
|
||||||
"decort_cb_k8s_list": cb_k8s.DataSourceK8sList(),
|
|
||||||
"decort_cb_k8s_list_deleted": cb_k8s.DataSourceK8sListDeleted(),
|
|
||||||
"decort_cb_k8s_wg": cb_k8s.DataSourceK8sWg(),
|
|
||||||
"decort_cb_k8s_wg_cloud_init": cb_k8s.DataSourceK8sWgCloudInit(),
|
|
||||||
"decort_cb_k8s_wg_list": cb_k8s.DataSourceK8sWgList(),
|
|
||||||
"decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func Provider() *schema.Provider {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating
|
||||||
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"oauth2_url": {
|
"oauth2_url": {
|
||||||
@@ -49,7 +49,7 @@ func Provider() *schema.Provider {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
||||||
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"controller_url": {
|
"controller_url": {
|
||||||
@@ -74,39 +74,18 @@ func Provider() *schema.Provider {
|
|||||||
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_user": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
|
||||||
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"bvs_password": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"domain": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"app_id": {
|
"app_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
||||||
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_secret": {
|
"app_secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
||||||
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"jwt": {
|
"jwt": {
|
||||||
@@ -122,25 +101,6 @@ func Provider() *schema.Provider {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
||||||
},
|
},
|
||||||
|
|
||||||
"path_cfg": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The path of the configuration file entry",
|
|
||||||
},
|
|
||||||
|
|
||||||
"path_token": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The path of the token file entry",
|
|
||||||
},
|
|
||||||
|
|
||||||
"time_to_refresh": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: newResourcesMap(),
|
ResourcesMap: newResourcesMap(),
|
||||||
|
|||||||
@@ -1,113 +1,95 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
cb_pfw "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pfw"
|
||||||
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_snapshot "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/snapshot"
|
||||||
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user"
|
)
|
||||||
cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool"
|
|
||||||
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
func newResourcesMap() map[string]*schema.Resource {
|
||||||
)
|
return map[string]*schema.Resource{
|
||||||
|
"decort_resgroup": rg.ResourceResgroup(),
|
||||||
func newResourcesMap() map[string]*schema.Resource {
|
"decort_kvmvm": kvmvm.ResourceCompute(),
|
||||||
return map[string]*schema.Resource{
|
"decort_disk": disks.ResourceDisk(),
|
||||||
"decort_resgroup": rg.ResourceResgroup(),
|
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
|
||||||
"decort_kvmvm": kvmvm.ResourceCompute(),
|
"decort_vins": vins.ResourceVins(),
|
||||||
"decort_disk": disks.ResourceDisk(),
|
"decort_pfw": pfw.ResourcePfw(),
|
||||||
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
|
"decort_k8s": k8s.ResourceK8s(),
|
||||||
"decort_disk_replication": disks.ResourceDiskReplication(),
|
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||||
"decort_vins": vins.ResourceVins(),
|
"decort_k8s_cp": k8s.ResourceK8sCP(),
|
||||||
"decort_pfw": pfw.ResourcePfw(),
|
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||||
"decort_k8s": k8s.ResourceK8s(),
|
"decort_account": account.ResourceAccount(),
|
||||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
"decort_bservice": bservice.ResourceBasicService(),
|
||||||
"decort_k8s_cp": k8s.ResourceK8sCP(),
|
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
||||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
"decort_image": image.ResourceImage(),
|
||||||
"decort_account": account.ResourceAccount(),
|
"decort_image_virtual": image.ResourceImageVirtual(),
|
||||||
"decort_bservice": bservice.ResourceBasicService(),
|
"decort_lb": lb.ResourceLB(),
|
||||||
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
"decort_lb_backend": lb.ResourceLBBackend(),
|
||||||
"decort_image": image.ResourceImage(),
|
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
||||||
"decort_image_from_blank_compute": image.ResourceImageFromBlankCompute(),
|
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||||
"decort_image_from_platform_disk": image.ResourceImageFromPlatformDisk(),
|
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||||
"decort_image_virtual": image.ResourceImageVirtual(),
|
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||||
"decort_lb": lb.ResourceLB(),
|
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
||||||
"decort_lb_backend": lb.ResourceLBBackend(),
|
|
||||||
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
"decort_cb_account": cb_account.ResourceAccount(),
|
||||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
||||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||||
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
"decort_cb_image": cb_image.ResourceImage(),
|
||||||
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||||
|
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||||
"decort_cb_account": cb_account.ResourceAccount(),
|
"decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
||||||
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||||
"decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
|
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||||
"decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
|
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
||||||
"decort_cb_disk_replication": cb_disks.ResourceDiskReplication(),
|
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||||
"decort_cb_image": cb_image.ResourceImage(),
|
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||||
"decort_cb_image_from_blank_compute": cb_image.ResourceImageFromBlankCompute(),
|
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
||||||
"decort_cb_image_from_platform_disk": cb_image.ResourceImageFromPlatformDisk(),
|
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
||||||
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
||||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
}
|
||||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
}
|
||||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
|
||||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
|
||||||
"decort_cb_vins": cb_vins.ResourceVins(),
|
|
||||||
"decort_cb_k8ci": cb_k8ci.ResourceK8CI(),
|
|
||||||
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
|
|
||||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
|
||||||
"decort_cb_vins_static_route": cb_vins.ResourceStaticRoute(),
|
|
||||||
"decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
|
|
||||||
"decort_cb_lb": cb_lb.ResourceLB(),
|
|
||||||
"decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
|
|
||||||
"decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
|
|
||||||
"decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
|
|
||||||
"decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
|
|
||||||
"decort_cb_rg": cb_rg.ResourceResgroup(),
|
|
||||||
"decort_cb_user": cb_user.ResourceUser(),
|
|
||||||
"decort_cb_vfpool": cb_vfpool.ResourceVFPool(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +99,6 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
"cu_i": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -307,13 +302,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"compute_features": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"created_by": {
|
"created_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -1,128 +1,127 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountAuditsList(aal account.ListAudits) []map[string]interface{} {
|
func flattenAccountAuditsList(aal account.ListAudits) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, aa := range aal {
|
for _, aa := range aal {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"call": aa.Call,
|
"call": aa.Call,
|
||||||
"responsetime": aa.ResponseTime,
|
"responsetime": aa.ResponseTime,
|
||||||
"statuscode": aa.StatusCode,
|
"statuscode": aa.StatusCode,
|
||||||
"timestamp": aa.Timestamp,
|
"timestamp": aa.Timestamp,
|
||||||
"user": aa.User,
|
"user": aa.User,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
||||||
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"items": {
|
||||||
"items": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Description: "Search Result",
|
||||||
Description: "Search Result",
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"call": {
|
||||||
"call": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"responsetime": {
|
||||||
"responsetime": {
|
Type: schema.TypeFloat,
|
||||||
Type: schema.TypeFloat,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"statuscode": {
|
||||||
"statuscode": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"timestamp": {
|
||||||
"timestamp": {
|
Type: schema.TypeFloat,
|
||||||
Type: schema.TypeFloat,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"user": {
|
||||||
"user": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceAccountAuditsList() *schema.Resource {
|
||||||
func DataSourceAccountAuditsList() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceAccountAuditsListRead,
|
||||||
ReadContext: dataSourceAccountAuditsListRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceAccountAuditsListSchemaMake(),
|
||||||
Schema: dataSourceAccountAuditsListSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,263 +1,257 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountComputesList(acl *account.ListComputes) []map[string]interface{} {
|
func flattenAccountComputesList(acl *account.ListComputes) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, acc := range acl.Data {
|
for _, acc := range acl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": acc.AccountID,
|
"account_id": acc.AccountID,
|
||||||
"account_name": acc.AccountName,
|
"account_name": acc.AccountName,
|
||||||
"cpus": acc.CPUs,
|
"cpus": acc.CPUs,
|
||||||
"created_by": acc.CreatedBy,
|
"created_by": acc.CreatedBy,
|
||||||
"created_time": acc.CreatedTime,
|
"created_time": acc.CreatedTime,
|
||||||
"deleted_by": acc.DeletedBy,
|
"deleted_by": acc.DeletedBy,
|
||||||
"deleted_time": acc.DeletedTime,
|
"deleted_time": acc.DeletedTime,
|
||||||
"compute_id": acc.ComputeID,
|
"compute_id": acc.ComputeID,
|
||||||
"compute_name": acc.ComputeName,
|
"compute_name": acc.ComputeName,
|
||||||
"ram": acc.RAM,
|
"ram": acc.RAM,
|
||||||
"registered": acc.Registered,
|
"registered": acc.Registered,
|
||||||
"rg_id": acc.RGID,
|
"rg_id": acc.RGID,
|
||||||
"rg_name": acc.RGName,
|
"rg_name": acc.RGName,
|
||||||
"status": acc.Status,
|
"status": acc.Status,
|
||||||
"tech_status": acc.TechStatus,
|
"tech_status": acc.TechStatus,
|
||||||
"total_disks_size": acc.TotalDisksSize,
|
"total_disks_size": acc.TotalDisksSize,
|
||||||
"updated_by": acc.UpdatedBy,
|
"updated_by": acc.UpdatedBy,
|
||||||
"updated_time": acc.UpdatedTime,
|
"updated_time": acc.UpdatedTime,
|
||||||
"user_managed": acc.UserManaged,
|
"user_managed": acc.UserManaged,
|
||||||
"vins_connected": acc.VINSConnected,
|
"vins_connected": acc.VINSConnected,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountComputesList(accountComputesList))
|
||||||
d.Set("items", flattenAccountComputesList(accountComputesList))
|
d.Set("entry_count", accountComputesList.EntryCount)
|
||||||
d.Set("entry_count", accountComputesList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"compute_id": {
|
||||||
"compute_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by compute ID",
|
||||||
Description: "Filter by compute ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by compute name",
|
||||||
Description: "Filter by compute name",
|
},
|
||||||
},
|
"rg_name": {
|
||||||
"rg_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by RG name",
|
||||||
Description: "Filter by RG name",
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by RG ID",
|
||||||
Description: "Filter by RG ID",
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by tech. status",
|
||||||
Description: "Filter by tech. status",
|
},
|
||||||
},
|
"ip_address": {
|
||||||
"ip_address": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by IP address",
|
||||||
Description: "Filter by IP address",
|
},
|
||||||
},
|
"extnet_name": {
|
||||||
"extnet_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by extnet name",
|
||||||
Description: "Filter by extnet name",
|
},
|
||||||
},
|
"extnet_id": {
|
||||||
"extnet_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by extnet ID",
|
||||||
Description: "Filter by extnet ID",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Description: "Search Result",
|
||||||
Description: "Page size",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"items": {
|
"account_id": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Search Result",
|
},
|
||||||
Elem: &schema.Resource{
|
"account_name": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"cpus": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"account_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"created_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"cpus": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"created_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"created_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"deleted_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"deleted_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"compute_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"compute_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"compute_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ram": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"compute_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"registered": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"ram": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"registered": {
|
Computed: true,
|
||||||
Type: schema.TypeBool,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"tech_status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"total_disks_size": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"tech_status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"total_disks_size": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"updated_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"user_managed": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"updated_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"vins_connected": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"user_managed": {
|
Computed: true,
|
||||||
Type: schema.TypeBool,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"vins_connected": {
|
},
|
||||||
Type: schema.TypeInt,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceAccountComputesList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountComputesListRead,
|
||||||
|
|
||||||
func DataSourceAccountComputesList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountComputesListRead,
|
|
||||||
|
Schema: dataSourceAccountComputesListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountComputesListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,116 +1,110 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("cu_c", accountConsumedUnits.CUC)
|
||||||
d.Set("cu_c", accountConsumedUnits.CUC)
|
d.Set("cu_d", accountConsumedUnits.CUD)
|
||||||
d.Set("cu_d", accountConsumedUnits.CUD)
|
d.Set("cu_i", accountConsumedUnits.CUI)
|
||||||
d.Set("cu_dm", accountConsumedUnits.CUDM)
|
d.Set("cu_m", accountConsumedUnits.CUM)
|
||||||
d.Set("cu_i", accountConsumedUnits.CUI)
|
d.Set("cu_np", accountConsumedUnits.CUNP)
|
||||||
d.Set("cu_m", accountConsumedUnits.CUM)
|
d.Set("gpu_units", accountConsumedUnits.GPUUnits)
|
||||||
d.Set("cu_np", accountConsumedUnits.CUNP)
|
|
||||||
d.Set("gpu_units", accountConsumedUnits.GPUUnits)
|
return nil
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
|
"account_id": {
|
||||||
res := map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"account_id": {
|
Required: true,
|
||||||
Type: schema.TypeInt,
|
Description: "ID of the account",
|
||||||
Required: true,
|
},
|
||||||
Description: "ID of the account",
|
"cu_c": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_c": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_d": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_d": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_i": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_dm": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_m": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_i": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_np": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_m": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"gpu_units": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_np": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
}
|
||||||
},
|
return res
|
||||||
"gpu_units": {
|
}
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
func DataSourceAccountConsumedUnits() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountConsumedUnitsRead,
|
||||||
|
|
||||||
func DataSourceAccountConsumedUnits() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountConsumedUnitsRead,
|
|
||||||
|
Schema: dataSourceAccountConsumedUnitsSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountConsumedUnitsSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,91 +1,90 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("cu_result", result)
|
||||||
d.Set("cu_result", result)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"cu_type": {
|
||||||
"cu_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Required: true,
|
||||||
Required: true,
|
Description: "cloud unit resource type",
|
||||||
Description: "cloud unit resource type",
|
},
|
||||||
},
|
"cu_result": {
|
||||||
"cu_result": {
|
Type: schema.TypeFloat,
|
||||||
Type: schema.TypeFloat,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceAccountConsumedUnitsByType() *schema.Resource {
|
||||||
func DataSourceAccountConsumedUnitsByType() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
|
||||||
ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),
|
||||||
Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,78 +1,77 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountList(accountDeletedList))
|
||||||
d.Set("items", flattenAccountList(accountDeletedList))
|
d.Set("entry_count", accountDeletedList.EntryCount)
|
||||||
d.Set("entry_count", accountDeletedList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
|
temp := dataSourceAccountListSchemaMake()
|
||||||
temp := dataSourceAccountListSchemaMake()
|
delete(temp, "status")
|
||||||
delete(temp, "status")
|
return temp
|
||||||
return temp
|
}
|
||||||
}
|
|
||||||
|
func DataSourceAccountDeletedList() *schema.Resource {
|
||||||
func DataSourceAccountDeletedList() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceAccountDeletedListRead,
|
||||||
ReadContext: dataSourceAccountDeletedListRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceAccountDeletedListSchemaMake(),
|
||||||
Schema: dataSourceAccountDeletedListSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,177 +1,171 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountDisksList(adl *account.ListDisks) []map[string]interface{} {
|
func flattenAccountDisksList(adl *account.ListDisks) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, ad := range adl.Data {
|
for _, ad := range adl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"disk_id": ad.ID,
|
"disk_id": ad.ID,
|
||||||
"disk_name": ad.Name,
|
"disk_name": ad.Name,
|
||||||
"pool": ad.Pool,
|
"pool": ad.Pool,
|
||||||
"sep_id": ad.SEPID,
|
"sep_id": ad.SEPID,
|
||||||
"shareable": ad.Shareable,
|
"shareable": ad.Shareable,
|
||||||
"size_max": ad.SizeMax,
|
"size_max": ad.SizeMax,
|
||||||
"type": ad.Type,
|
"type": ad.Type,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountDisksList(accountDisksList))
|
||||||
d.Set("items", flattenAccountDisksList(accountDisksList))
|
d.Set("entry_count", accountDisksList.EntryCount)
|
||||||
d.Set("entry_count", accountDisksList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"disk_id": {
|
||||||
"disk_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by disk ID",
|
||||||
Description: "Filter by disk ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by disk name",
|
||||||
Description: "Filter by disk name",
|
},
|
||||||
},
|
"disk_max_size": {
|
||||||
"disk_max_size": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by disk max size",
|
||||||
Description: "Filter by disk max size",
|
},
|
||||||
},
|
"type": {
|
||||||
"type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by disk type",
|
||||||
Description: "Filter by disk type",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Description: "Search Result",
|
||||||
Description: "Page size",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"items": {
|
"disk_id": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Search Result",
|
},
|
||||||
Elem: &schema.Resource{
|
"disk_name": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"disk_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"pool": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"disk_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"sep_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"pool": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"shareable": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"sep_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"size_max": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"shareable": {
|
Computed: true,
|
||||||
Type: schema.TypeBool,
|
},
|
||||||
Computed: true,
|
"type": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"size_max": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"type": {
|
},
|
||||||
Type: schema.TypeString,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceAccountDisksList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountDisksListRead,
|
||||||
|
|
||||||
func DataSourceAccountDisksList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountDisksListRead,
|
|
||||||
|
Schema: dataSourceAccountDisksListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountDisksListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,253 +1,252 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountFlipGroupsList(afgl *account.ListFLIPGroups) []map[string]interface{} {
|
func flattenAccountFlipGroupsList(afgl *account.ListFLIPGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, afg := range afgl.Data {
|
for _, afg := range afgl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": afg.AccountID,
|
"account_id": afg.AccountID,
|
||||||
"client_type": afg.ClientType,
|
"client_type": afg.ClientType,
|
||||||
"conn_type": afg.ConnType,
|
"conn_type": afg.ConnType,
|
||||||
"created_by": afg.CreatedBy,
|
"created_by": afg.CreatedBy,
|
||||||
"created_time": afg.CreatedTime,
|
"created_time": afg.CreatedTime,
|
||||||
"default_gw": afg.DefaultGW,
|
"default_gw": afg.DefaultGW,
|
||||||
"deleted_by": afg.DeletedBy,
|
"deleted_by": afg.DeletedBy,
|
||||||
"deleted_time": afg.DeletedTime,
|
"deleted_time": afg.DeletedTime,
|
||||||
"desc": afg.Description,
|
"desc": afg.Description,
|
||||||
"gid": afg.GID,
|
"gid": afg.GID,
|
||||||
"guid": afg.GUID,
|
"guid": afg.GUID,
|
||||||
"fg_id": afg.ID,
|
"fg_id": afg.ID,
|
||||||
"ip": afg.IP,
|
"ip": afg.IP,
|
||||||
"milestones": afg.Milestones,
|
"milestones": afg.Milestones,
|
||||||
"fg_name": afg.Name,
|
"fg_name": afg.Name,
|
||||||
"net_id": afg.NetID,
|
"net_id": afg.NetID,
|
||||||
"net_type": afg.NetType,
|
"net_type": afg.NetType,
|
||||||
"netmask": afg.NetMask,
|
"netmask": afg.NetMask,
|
||||||
"status": afg.Status,
|
"status": afg.Status,
|
||||||
"updated_by": afg.UpdatedBy,
|
"updated_by": afg.UpdatedBy,
|
||||||
"updated_time": afg.UpdatedTime,
|
"updated_time": afg.UpdatedTime,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
||||||
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
||||||
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by name",
|
||||||
Description: "Filter by name",
|
},
|
||||||
},
|
"vins_id": {
|
||||||
"vins_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by ViNS ID",
|
||||||
Description: "Filter by ViNS ID",
|
},
|
||||||
},
|
"vins_name": {
|
||||||
"vins_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by ViNS name",
|
||||||
Description: "Filter by ViNS name",
|
},
|
||||||
},
|
"extnet_id": {
|
||||||
"extnet_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by extnet ID",
|
||||||
Description: "Filter by extnet ID",
|
},
|
||||||
},
|
"by_ip": {
|
||||||
"by_ip": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by IP",
|
||||||
Description: "Filter by IP",
|
},
|
||||||
},
|
"flipgroup_id": {
|
||||||
"flipgroup_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by flipgroup ID",
|
||||||
Description: "Filter by flipgroup ID",
|
},
|
||||||
},
|
"page": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"size": {
|
||||||
"size": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page size",
|
},
|
||||||
},
|
"items": {
|
||||||
"items": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Description: "Search Result",
|
||||||
Description: "Search Result",
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"client_type": {
|
||||||
"client_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"conn_type": {
|
||||||
"conn_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_by": {
|
||||||
"created_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_time": {
|
||||||
"created_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"default_gw": {
|
||||||
"default_gw": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_by": {
|
||||||
"deleted_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
"deleted_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"desc": {
|
||||||
"desc": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"gid": {
|
||||||
"gid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"fg_id": {
|
||||||
"fg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ip": {
|
||||||
"ip": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"milestones": {
|
||||||
"milestones": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"fg_name": {
|
||||||
"fg_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"net_id": {
|
||||||
"net_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"net_type": {
|
||||||
"net_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"netmask": {
|
||||||
"netmask": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_by": {
|
||||||
"updated_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_time": {
|
||||||
"updated_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
"entry_count": {
|
||||||
"entry_count": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
||||||
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceAccountFlipGroupsListRead,
|
||||||
ReadContext: dataSourceAccountFlipGroupsListRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
||||||
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,223 +1,209 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
|
func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, acc := range al.Data {
|
for _, acc := range al.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"acl": flattenRgAcl(acc.ACL),
|
"acl": flattenRgAcl(acc.ACL),
|
||||||
"compute_features": acc.ComputeFeatures,
|
"created_time": acc.CreatedTime,
|
||||||
"created_time": acc.CreatedTime,
|
"deleted_time": acc.DeletedTime,
|
||||||
"deleted_time": acc.DeletedTime,
|
"account_id": acc.ID,
|
||||||
"account_id": acc.ID,
|
"account_name": acc.Name,
|
||||||
"account_name": acc.Name,
|
"status": acc.Status,
|
||||||
"status": acc.Status,
|
"updated_time": acc.UpdatedTime,
|
||||||
"updated_time": acc.UpdatedTime,
|
}
|
||||||
}
|
res = append(res, temp)
|
||||||
res = append(res, temp)
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
|
||||||
func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
|
res := make([]map[string]interface{}, 0)
|
||||||
res := make([]map[string]interface{}, 0)
|
for _, rgAcl := range rgAcls {
|
||||||
for _, rgAcl := range rgAcls {
|
temp := map[string]interface{}{
|
||||||
temp := map[string]interface{}{
|
"explicit": rgAcl.IsExplicit,
|
||||||
"explicit": rgAcl.IsExplicit,
|
"guid": rgAcl.GUID,
|
||||||
"guid": rgAcl.GUID,
|
"right": rgAcl.Rights,
|
||||||
"right": rgAcl.Rights,
|
"status": rgAcl.Status,
|
||||||
"status": rgAcl.Status,
|
"type": rgAcl.Type,
|
||||||
"type": rgAcl.Type,
|
"user_group_id": rgAcl.UgroupID,
|
||||||
"user_group_id": rgAcl.UgroupID,
|
}
|
||||||
}
|
res = append(res, temp)
|
||||||
res = append(res, temp)
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
||||||
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
if err != nil {
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
d.SetId("")
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
id := uuid.New()
|
d.Set("items", flattenAccountList(accountList))
|
||||||
d.SetId(id.String())
|
d.Set("entry_count", accountList.EntryCount)
|
||||||
d.Set("items", flattenAccountList(accountList))
|
|
||||||
d.Set("entry_count", accountList.EntryCount)
|
return nil
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
"by_id": {
|
||||||
res := map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"by_id": {
|
Optional: true,
|
||||||
Type: schema.TypeInt,
|
Description: "Filter by ID",
|
||||||
Optional: true,
|
},
|
||||||
Description: "Filter by ID",
|
"name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"name": {
|
Optional: true,
|
||||||
Type: schema.TypeString,
|
Description: "Filter by name",
|
||||||
Optional: true,
|
},
|
||||||
Description: "Filter by name",
|
"acl": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"acl": {
|
Optional: true,
|
||||||
Type: schema.TypeString,
|
Description: "Filter by ACL",
|
||||||
Optional: true,
|
},
|
||||||
Description: "Filter by ACL",
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Optional: true,
|
||||||
Type: schema.TypeString,
|
Description: "Filter by status",
|
||||||
Optional: true,
|
},
|
||||||
Description: "Filter by status",
|
"page": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"sort_by": {
|
Optional: true,
|
||||||
Type: schema.TypeString,
|
Description: "Page number",
|
||||||
Optional: true,
|
},
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
"size": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"page": {
|
Optional: true,
|
||||||
Type: schema.TypeInt,
|
Description: "Page size",
|
||||||
Optional: true,
|
},
|
||||||
Description: "Page number",
|
"items": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"size": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
Elem: &schema.Resource{
|
||||||
Optional: true,
|
Schema: map[string]*schema.Schema{
|
||||||
Description: "Page size",
|
"acl": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"items": {
|
Computed: true,
|
||||||
Type: schema.TypeList,
|
Elem: &schema.Resource{
|
||||||
Computed: true,
|
Schema: map[string]*schema.Schema{
|
||||||
Elem: &schema.Resource{
|
"explicit": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeBool,
|
||||||
"acl": {
|
Computed: true,
|
||||||
Type: schema.TypeList,
|
},
|
||||||
Computed: true,
|
"guid": {
|
||||||
Elem: &schema.Resource{
|
Type: schema.TypeString,
|
||||||
Schema: map[string]*schema.Schema{
|
Computed: true,
|
||||||
"explicit": {
|
},
|
||||||
Type: schema.TypeBool,
|
"right": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"guid": {
|
},
|
||||||
Type: schema.TypeString,
|
"status": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"right": {
|
},
|
||||||
Type: schema.TypeString,
|
"type": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"status": {
|
},
|
||||||
Type: schema.TypeString,
|
"user_group_id": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"type": {
|
},
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"user_group_id": {
|
"created_time": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"compute_features": {
|
},
|
||||||
Type: schema.TypeList,
|
"account_id": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
Elem: &schema.Schema{
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
},
|
"account_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"account_name": {
|
},
|
||||||
Type: schema.TypeString,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"status": {
|
},
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
return res
|
||||||
},
|
}
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
func DataSourceAccountList() *schema.Resource {
|
||||||
Computed: true,
|
return &schema.Resource{
|
||||||
},
|
SchemaVersion: 1,
|
||||||
},
|
|
||||||
},
|
ReadContext: dataSourceAccountListRead,
|
||||||
},
|
|
||||||
"entry_count": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Read: &constants.Timeout30s,
|
||||||
Computed: true,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
}
|
|
||||||
return res
|
Schema: dataSourceAccountListSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func DataSourceAccountList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,116 +1,110 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("cu_c", accountReservedUnits.CUC)
|
||||||
d.Set("cu_c", accountReservedUnits.CUC)
|
d.Set("cu_d", accountReservedUnits.CUD)
|
||||||
d.Set("cu_d", accountReservedUnits.CUD)
|
d.Set("cu_i", accountReservedUnits.CUI)
|
||||||
d.Set("cu_dm", accountReservedUnits.CUDM)
|
d.Set("cu_m", accountReservedUnits.CUM)
|
||||||
d.Set("cu_i", accountReservedUnits.CUI)
|
d.Set("cu_np", accountReservedUnits.CUNP)
|
||||||
d.Set("cu_m", accountReservedUnits.CUM)
|
d.Set("gpu_units", accountReservedUnits.GPUUnits)
|
||||||
d.Set("cu_np", accountReservedUnits.CUNP)
|
|
||||||
d.Set("gpu_units", accountReservedUnits.GPUUnits)
|
return nil
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
|
"account_id": {
|
||||||
res := map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"account_id": {
|
Required: true,
|
||||||
Type: schema.TypeInt,
|
Description: "ID of the account",
|
||||||
Required: true,
|
},
|
||||||
Description: "ID of the account",
|
"cu_c": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_c": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_d": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_d": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_i": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_dm": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_m": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_i": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"cu_np": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_m": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
"gpu_units": {
|
||||||
},
|
Type: schema.TypeFloat,
|
||||||
"cu_np": {
|
Computed: true,
|
||||||
Type: schema.TypeFloat,
|
},
|
||||||
Computed: true,
|
}
|
||||||
},
|
return res
|
||||||
"gpu_units": {
|
}
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
func DataSourceAccountReservedUnits() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountReservedUnitsRead,
|
||||||
|
|
||||||
func DataSourceAccountReservedUnits() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountReservedUnitsRead,
|
|
||||||
|
Schema: dataSourceAccountReservedUnitsSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountReservedUnitsSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,377 +1,371 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
|
func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, arg := range argl.Data {
|
for _, arg := range argl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"computes": flattenAccRGComputes(arg.Computes),
|
"computes": flattenAccRGComputes(arg.Computes),
|
||||||
"resources": flattenAccRGResources(arg.Resources),
|
"resources": flattenAccRGResources(arg.Resources),
|
||||||
"created_by": arg.CreatedBy,
|
"created_by": arg.CreatedBy,
|
||||||
"created_time": arg.CreatedTime,
|
"created_time": arg.CreatedTime,
|
||||||
"deleted_by": arg.DeletedBy,
|
"deleted_by": arg.DeletedBy,
|
||||||
"deleted_time": arg.DeletedTime,
|
"deleted_time": arg.DeletedTime,
|
||||||
"rg_id": arg.RGID,
|
"rg_id": arg.RGID,
|
||||||
"milestones": arg.Milestones,
|
"milestones": arg.Milestones,
|
||||||
"rg_name": arg.RGName,
|
"rg_name": arg.RGName,
|
||||||
"status": arg.Status,
|
"status": arg.Status,
|
||||||
"updated_by": arg.UpdatedBy,
|
"updated_by": arg.UpdatedBy,
|
||||||
"updated_time": arg.UpdatedTime,
|
"updated_time": arg.UpdatedTime,
|
||||||
"vinses": arg.VINSes,
|
"vinses": arg.VINSes,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenAccRGComputes(argc account.RGComputes) []map[string]interface{} {
|
func flattenAccRGComputes(argc account.RGComputes) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"started": argc.Started,
|
"started": argc.Started,
|
||||||
"stopped": argc.Stopped,
|
"stopped": argc.Stopped,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenAccResourceHack(r account.LimitsRG) []map[string]interface{} {
|
func flattenAccResourceHack(r account.LimitsRG) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"cpu": r.CPU,
|
"cpu": r.CPU,
|
||||||
"disksize": r.DiskSize,
|
"disksize": r.DiskSize,
|
||||||
"extips": r.ExtIPs,
|
"extips": r.ExtIPs,
|
||||||
"exttraffic": r.ExtTraffic,
|
"exttraffic": r.ExtTraffic,
|
||||||
"gpu": r.GPU,
|
"gpu": r.GPU,
|
||||||
"ram": r.RAM,
|
"ram": r.RAM,
|
||||||
//"seps": flattenAccountSeps(r.SEPs),
|
//"seps": flattenAccountSeps(r.SEPs),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenAccResourceRg(r account.Resource) []map[string]interface{} {
|
func flattenAccResourceRg(r account.Resource) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"cpu": r.CPU,
|
"cpu": r.CPU,
|
||||||
"disksize": r.DiskSize,
|
"disksize": r.DiskSize,
|
||||||
"extips": r.ExtIPs,
|
"extips": r.ExtIPs,
|
||||||
"exttraffic": r.ExtTraffic,
|
"exttraffic": r.ExtTraffic,
|
||||||
"gpu": r.GPU,
|
"gpu": r.GPU,
|
||||||
"ram": r.RAM,
|
"ram": r.RAM,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenAccRGResources(argr account.RGResources) []map[string]interface{} {
|
func flattenAccRGResources(argr account.RGResources) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"consumed": flattenAccResourceRg(argr.Consumed),
|
"consumed": flattenAccResourceRg(argr.Consumed),
|
||||||
"limits": flattenAccResourceHack(argr.Limits),
|
"limits": flattenAccResourceHack(argr.Limits),
|
||||||
"reserved": flattenAccResourceRg(argr.Reserved),
|
"reserved": flattenAccResourceRg(argr.Reserved),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountRGList(accountRGList))
|
||||||
d.Set("items", flattenAccountRGList(accountRGList))
|
d.Set("entry_count", accountRGList.EntryCount)
|
||||||
d.Set("entry_count", accountRGList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"size": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by RG ID",
|
||||||
Description: "Page size",
|
},
|
||||||
},
|
"vins_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by ViNS ID",
|
||||||
Description: "Filter by RG ID",
|
},
|
||||||
},
|
"vm_id": {
|
||||||
"vins_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by VM ID",
|
||||||
Description: "Filter by ViNS ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"vm_id": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by name",
|
||||||
Description: "Filter by VM ID",
|
},
|
||||||
},
|
"status": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by status",
|
||||||
Description: "Filter by name",
|
},
|
||||||
},
|
"items": {
|
||||||
"status": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Optional: true,
|
Description: "Search Result",
|
||||||
Description: "Filter by status",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"items": {
|
"computes": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Search Result",
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"started": {
|
||||||
"computes": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"stopped": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"started": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"stopped": {
|
},
|
||||||
Type: schema.TypeInt,
|
"resources": {
|
||||||
Computed: true,
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
},
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"consumed": {
|
||||||
"resources": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"cpu": {
|
||||||
"consumed": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"disksize": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"cpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"extips": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"disksize": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"exttraffic": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"extips": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"gpu": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"exttraffic": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ram": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"gpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"ram": {
|
},
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
"limits": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
},
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
"limits": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"disksize": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"cpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"extips": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"disksize": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"exttraffic": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"extips": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"gpu": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"exttraffic": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ram": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"gpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"ram": {
|
},
|
||||||
Type: schema.TypeInt,
|
"reserved": {
|
||||||
Computed: true,
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
},
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"cpu": {
|
||||||
"reserved": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"disksize": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"cpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"extips": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"disksize": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"exttraffic": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"extips": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"gpu": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"exttraffic": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ram": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"gpu": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"ram": {
|
},
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
"created_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
"created_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"deleted_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"deleted_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"milestones": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"rg_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"milestones": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"updated_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"vinses": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"updated_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"vinses": {
|
},
|
||||||
Type: schema.TypeInt,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceAccountRGList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountRGListRead,
|
||||||
|
|
||||||
func DataSourceAccountRGList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountRGListRead,
|
|
||||||
|
Schema: dataSourceAccountRGListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountRGListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,191 +1,185 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
|
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(atl.Data))
|
res := make([]map[string]interface{}, 0, len(atl.Data))
|
||||||
for _, at := range atl.Data {
|
for _, at := range atl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"unc_path": at.UNCPath,
|
"unc_path": at.UNCPath,
|
||||||
"account_id": at.AccountID,
|
"account_id": at.AccountID,
|
||||||
"desc": at.Description,
|
"desc": at.Description,
|
||||||
"template_id": at.ID,
|
"template_id": at.ID,
|
||||||
"template_name": at.Name,
|
"template_name": at.Name,
|
||||||
"public": at.Public,
|
"public": at.Public,
|
||||||
"size": at.Size,
|
"size": at.Size,
|
||||||
"status": at.Status,
|
"status": at.Status,
|
||||||
"type": at.Type,
|
"type": at.Type,
|
||||||
"username": at.Username,
|
"username": at.Username,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
||||||
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
d.Set("entry_count", accountTemplatesList.EntryCount)
|
||||||
d.Set("entry_count", accountTemplatesList.EntryCount)
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the account",
|
||||||
Description: "ID of the account",
|
},
|
||||||
},
|
"include_deleted": {
|
||||||
"include_deleted": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Optional: true,
|
||||||
Optional: true,
|
},
|
||||||
},
|
"image_id": {
|
||||||
"image_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by image id",
|
||||||
Description: "Find by image id",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by name",
|
||||||
Description: "Filter by name",
|
},
|
||||||
},
|
"type": {
|
||||||
"type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by type",
|
||||||
Description: "Filter by type",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Description: "Search Result",
|
||||||
Description: "Page size",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"items": {
|
"unc_path": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Search Result",
|
},
|
||||||
Elem: &schema.Resource{
|
"account_id": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeInt,
|
||||||
"unc_path": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"desc": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"template_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"desc": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"template_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"template_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"public": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"template_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"size": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"public": {
|
Computed: true,
|
||||||
Type: schema.TypeBool,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"size": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"type": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"username": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"type": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"username": {
|
},
|
||||||
Type: schema.TypeString,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceAccountTemplatessList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceAccountTemplatesListRead,
|
||||||
|
|
||||||
func DataSourceAccountTemplatessList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceAccountTemplatesListRead,
|
|
||||||
|
Schema: dataSourceAccountTemplatesListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountTemplatesListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,238 +1,222 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
|
func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, av := range avl.Data {
|
for _, av := range avl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": av.AccountID,
|
"account_id": av.AccountID,
|
||||||
"account_name": av.AccountName,
|
"account_name": av.AccountName,
|
||||||
"computes": av.Computes,
|
"computes": av.Computes,
|
||||||
"created_by": av.CreatedBy,
|
"created_by": av.CreatedBy,
|
||||||
"created_time": av.CreatedTime,
|
"created_time": av.CreatedTime,
|
||||||
"deleted_by": av.DeletedBy,
|
"deleted_by": av.DeletedBy,
|
||||||
"deleted_time": av.DeletedTime,
|
"deleted_time": av.DeletedTime,
|
||||||
"external_ip": av.ExternalIP,
|
"external_ip": av.ExternalIP,
|
||||||
"extnet_id": av.ExtnetId,
|
"vin_id": av.ID,
|
||||||
"free_ips": av.FreeIPs,
|
"vin_name": av.Name,
|
||||||
"vin_id": av.ID,
|
"network": av.Network,
|
||||||
"vin_name": av.Name,
|
"pri_vnf_dev_id": av.PriVNFDevID,
|
||||||
"network": av.Network,
|
"rg_id": av.RGID,
|
||||||
"pri_vnf_dev_id": av.PriVNFDevID,
|
"rg_name": av.RGName,
|
||||||
"rg_id": av.RGID,
|
"status": av.Status,
|
||||||
"rg_name": av.RGName,
|
"updated_by": av.UpdatedBy,
|
||||||
"status": av.Status,
|
"updated_time": av.UpdatedTime,
|
||||||
"updated_by": av.UpdatedBy,
|
}
|
||||||
"updated_time": av.UpdatedTime,
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
return res
|
||||||
}
|
|
||||||
return res
|
}
|
||||||
|
|
||||||
}
|
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
||||||
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
if err != nil {
|
||||||
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
return diag.FromErr(err)
|
||||||
if err != nil {
|
}
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
id := uuid.New()
|
||||||
}
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenAccountVinsList(accountVinsList))
|
||||||
id := uuid.New()
|
d.Set("entry_count", accountVinsList.EntryCount)
|
||||||
d.SetId(id.String())
|
|
||||||
d.Set("items", flattenAccountVinsList(accountVinsList))
|
return nil
|
||||||
d.Set("entry_count", accountVinsList.EntryCount)
|
}
|
||||||
|
|
||||||
return nil
|
func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
||||||
}
|
res := map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
Type: schema.TypeInt,
|
||||||
res := map[string]*schema.Schema{
|
Required: true,
|
||||||
"account_id": {
|
Description: "ID of the account",
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Required: true,
|
"vins_id": {
|
||||||
Description: "ID of the account",
|
Type: schema.TypeInt,
|
||||||
},
|
Optional: true,
|
||||||
"vins_id": {
|
Description: "Filter by ViNS ID",
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Optional: true,
|
"name": {
|
||||||
Description: "Filter by ViNS ID",
|
Type: schema.TypeString,
|
||||||
},
|
Optional: true,
|
||||||
"name": {
|
Description: "Filter by name",
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Optional: true,
|
"rg_id": {
|
||||||
Description: "Filter by name",
|
Type: schema.TypeInt,
|
||||||
},
|
Optional: true,
|
||||||
"rg_id": {
|
Description: "Filter by RG ID",
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Optional: true,
|
"ext_ip": {
|
||||||
Description: "Filter by RG ID",
|
Type: schema.TypeString,
|
||||||
},
|
Optional: true,
|
||||||
"ext_ip": {
|
Description: "Filter by external IP",
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Optional: true,
|
"page": {
|
||||||
Description: "Filter by external IP",
|
Type: schema.TypeInt,
|
||||||
},
|
Optional: true,
|
||||||
"sort_by": {
|
Description: "Page number",
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Optional: true,
|
"size": {
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
Type: schema.TypeInt,
|
||||||
},
|
Optional: true,
|
||||||
"page": {
|
Description: "Page size",
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Optional: true,
|
"items": {
|
||||||
Description: "Page number",
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
"size": {
|
Description: "Search Result",
|
||||||
Type: schema.TypeInt,
|
Elem: &schema.Resource{
|
||||||
Optional: true,
|
Schema: map[string]*schema.Schema{
|
||||||
Description: "Page size",
|
"account_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"items": {
|
Computed: true,
|
||||||
Type: schema.TypeList,
|
},
|
||||||
Computed: true,
|
"account_name": {
|
||||||
Description: "Search Result",
|
Type: schema.TypeString,
|
||||||
Elem: &schema.Resource{
|
Computed: true,
|
||||||
Schema: map[string]*schema.Schema{
|
},
|
||||||
"account_id": {
|
"computes": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
"created_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"computes": {
|
"created_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
"deleted_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_time": {
|
"deleted_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
"external_ip": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_time": {
|
"vin_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"external_ip": {
|
"vin_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"extnet_id": {
|
"network": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"free_ips": {
|
"pri_vnf_dev_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"vin_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"vin_name": {
|
"rg_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"pri_vnf_dev_id": {
|
"updated_by": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rg_id": {
|
"updated_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rg_name": {
|
},
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
"entry_count": {
|
||||||
"status": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
}
|
||||||
"updated_by": {
|
return res
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
|
||||||
},
|
func DataSourceAccountVinsList() *schema.Resource {
|
||||||
"updated_time": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Computed: true,
|
|
||||||
},
|
ReadContext: dataSourceAccountVinsListRead,
|
||||||
},
|
|
||||||
},
|
Timeouts: &schema.ResourceTimeout{
|
||||||
},
|
Read: &constants.Timeout30s,
|
||||||
"entry_count": {
|
Default: &constants.Timeout60s,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
|
||||||
},
|
Schema: dataSourceAccountVinsListSchemaMake(),
|
||||||
}
|
}
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceAccountVinsList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountVinsListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountVinsListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
|||||||
d.Set("acl", flattenAccAcl(acc.ACL))
|
d.Set("acl", flattenAccAcl(acc.ACL))
|
||||||
d.Set("company", acc.Company)
|
d.Set("company", acc.Company)
|
||||||
d.Set("companyurl", acc.CompanyURL)
|
d.Set("companyurl", acc.CompanyURL)
|
||||||
d.Set("compute_features", acc.ComputeFeatures)
|
|
||||||
d.Set("created_by", acc.CreatedBy)
|
d.Set("created_by", acc.CreatedBy)
|
||||||
d.Set("created_time", acc.CreatedTime)
|
d.Set("created_time", acc.CreatedTime)
|
||||||
d.Set("deactivation_time", acc.DeactivationTime)
|
d.Set("deactivation_time", acc.DeactivationTime)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,106 +1,102 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
|
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
id = uint64(d.Get("account_id").(int))
|
id = uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListComputesRequest{
|
req := account.ListComputesRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if compute_id, ok := d.GetOk("compute_id"); ok {
|
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||||
req.ComputeID = uint64(compute_id.(int))
|
req.ComputeID = uint64(compute_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_name, ok := d.GetOk("rg_name"); ok {
|
if rg_name, ok := d.GetOk("rg_name"); ok {
|
||||||
req.RGName = rg_name.(string)
|
req.RGName = rg_name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rg_id.(int))
|
req.RGID = uint64(rg_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||||
req.TechStatus = tech_status.(string)
|
req.TechStatus = tech_status.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ip_address, ok := d.GetOk("ip_address"); ok {
|
if ip_address, ok := d.GetOk("ip_address"); ok {
|
||||||
req.IPAddress = ip_address.(string)
|
req.IPAddress = ip_address.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if extnet_name, ok := d.GetOk("extnet_name"); ok {
|
if extnet_name, ok := d.GetOk("extnet_name"); ok {
|
||||||
req.ExtNetName = extnet_name.(string)
|
req.ExtNetName = extnet_name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if extnet_id, ok := d.GetOk("extnet_id"); ok {
|
if extnet_id, ok := d.GetOk("extnet_id"); ok {
|
||||||
req.ExtNetID = uint64(extnet_id.(int))
|
req.ExtNetID = uint64(extnet_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
|
||||||
req.Size = uint64(size.(int))
|
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
|
}
|
||||||
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
|
|
||||||
if err != nil {
|
return accountComputesList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return accountComputesList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,80 +1,76 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
req := account.ListDeletedRequest{}
|
req := account.ListDeletedRequest{}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(by_id.(int))
|
req.ByID = uint64(by_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl, ok := d.GetOk("acl"); ok {
|
if acl, ok := d.GetOk("acl"); ok {
|
||||||
req.ACL = acl.(string)
|
req.ACL = acl.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
log.Debugf("utilityAccountDeletedListCheckPresence: load")
|
||||||
req.SortBy = sortBy.(string)
|
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityAccountDeletedListCheckPresence: load")
|
}
|
||||||
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
|
return accountDeletedList, nil
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return accountDeletedList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,88 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
|
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
id = uint64(d.Get("account_id").(int))
|
id = uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListDisksRequest{
|
req := account.ListDisksRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if disk_id, ok := d.GetOk("disk_id"); ok {
|
if disk_id, ok := d.GetOk("disk_id"); ok {
|
||||||
req.DiskID = uint64(disk_id.(int))
|
req.DiskID = uint64(disk_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||||
req.DiskMaxSize = uint64(disk_max_size.(int))
|
req.DiskMaxSize = uint64(disk_max_size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if typeVal, ok := d.GetOk("type"); ok {
|
if typeVal, ok := d.GetOk("type"); ok {
|
||||||
req.Type = typeVal.(string)
|
req.Type = typeVal.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
|
||||||
req.Size = uint64(size.(int))
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
|
}
|
||||||
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
|
|
||||||
if err != nil {
|
return accountDisksList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return accountDisksList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,83 +1,79 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := account.ListRequest{}
|
req := account.ListRequest{}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(by_id.(int))
|
req.ByID = uint64(by_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if acl, ok := d.GetOk("acl"); ok {
|
if acl, ok := d.GetOk("acl"); ok {
|
||||||
req.ACL = acl.(string)
|
req.ACL = acl.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
log.Debugf("utilityAccountListCheckPresence: load account list")
|
||||||
req.SortBy = sortBy.(string)
|
accountList, err := c.CloudAPI().Account().List(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityAccountListCheckPresence: load account list")
|
}
|
||||||
accountList, err := c.CloudAPI().Account().List(ctx, req)
|
|
||||||
if err != nil {
|
return accountList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return accountList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,94 +1,90 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
|
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
id = uint64(d.Get("account_id").(int))
|
id = uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListRGRequest{
|
req := account.ListRGRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rg_id.(int))
|
req.RGID = uint64(rg_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if vins_id, ok := d.GetOk("vins_id"); ok {
|
if vins_id, ok := d.GetOk("vins_id"); ok {
|
||||||
req.VINSID = uint64(vins_id.(int))
|
req.VINSID = uint64(vins_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if vm_id, ok := d.GetOk("vm_id"); ok {
|
if vm_id, ok := d.GetOk("vm_id"); ok {
|
||||||
req.VMID = uint64(vm_id.(int))
|
req.VMID = uint64(vm_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
log.Debugf("utilityAccountRGListCheckPresence: load account list")
|
||||||
req.SortBy = sortBy.(string)
|
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityAccountRGListCheckPresence: load account list")
|
}
|
||||||
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
|
|
||||||
if err != nil {
|
return accountRGList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return accountRGList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,83 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
|
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
id := uint64(d.Get("account_id").(int))
|
id := uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListTemplatesRequest{
|
req := account.ListTemplatesRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
||||||
req.IncludeDeleted = include_deleted.(bool)
|
req.IncludeDeleted = include_deleted.(bool)
|
||||||
}
|
}
|
||||||
if imageId, ok := d.GetOk("image_id"); ok {
|
if imageId, ok := d.GetOk("image_id"); ok {
|
||||||
req.ImageID = uint64(imageId.(int))
|
req.ImageID = uint64(imageId.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if typeTemplates, ok := d.GetOk("type"); ok {
|
if typeTemplates, ok := d.GetOk("type"); ok {
|
||||||
req.Type = typeTemplates.(string)
|
req.Type = typeTemplates.(string)
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
|
||||||
req.Size = uint64(size.(int))
|
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
||||||
}
|
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
||||||
|
if err != nil {
|
||||||
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
return nil, err
|
||||||
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return accountTemplatesList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountTemplatesList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,90 +1,86 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
|
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
id = uint64(d.Get("account_id").(int))
|
id = uint64(d.Get("account_id").(int))
|
||||||
|
|
||||||
req := account.ListVINSRequest{
|
req := account.ListVINSRequest{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if vins_id, ok := d.GetOk("vins_id"); ok {
|
if vins_id, ok := d.GetOk("vins_id"); ok {
|
||||||
req.VINSID = uint64(vins_id.(int))
|
req.VINSID = uint64(vins_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rg_id.(int))
|
req.RGID = uint64(rg_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if ext_ip, ok := d.GetOk("ext_ip"); ok {
|
||||||
req.Name = name.(string)
|
req.ExtIP = ext_ip.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ext_ip, ok := d.GetOk("ext_ip"); ok {
|
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
|
||||||
req.ExtIP = ext_ip.(string)
|
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
|
}
|
||||||
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
|
|
||||||
if err != nil {
|
return accountVinsList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return accountVinsList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,298 +1,297 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
d.SetId(strconv.FormatUint(bs.ID, 10))
|
||||||
d.SetId(strconv.FormatUint(bs.ID, 10))
|
|
||||||
|
flattenService(d, bs)
|
||||||
flattenService(d, bs)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"service_id": {
|
||||||
"service_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
},
|
||||||
},
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"account_name": {
|
||||||
"account_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"base_domain": {
|
||||||
"base_domain": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"computes": {
|
||||||
"computes": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"architecture": {
|
||||||
"architecture": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"compgroup_id": {
|
||||||
"compgroup_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"compgroup_name": {
|
||||||
"compgroup_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"compgroup_role": {
|
||||||
"compgroup_role": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"id": {
|
||||||
"id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"stack_id": {
|
||||||
"stack_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
"cpu_total": {
|
||||||
"cpu_total": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_by": {
|
||||||
"created_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_time": {
|
||||||
"created_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_by": {
|
||||||
"deleted_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
"deleted_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"disk_total": {
|
||||||
"disk_total": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"gid": {
|
||||||
"gid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"groups": {
|
||||||
"groups": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"computes": {
|
||||||
"computes": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"consistency": {
|
||||||
"consistency": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"id": {
|
||||||
"id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
// "groups_name": {
|
||||||
// "groups_name": {
|
// Type: schema.TypeList,
|
||||||
// Type: schema.TypeList,
|
// Computed: true,
|
||||||
// Computed: true,
|
// Elem: &schema.Schema{
|
||||||
// Elem: &schema.Schema{
|
// Type: schema.TypeString,
|
||||||
// Type: schema.TypeString,
|
// },
|
||||||
// },
|
// },
|
||||||
// },
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"milestones": {
|
||||||
"milestones": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"service_name": {
|
||||||
"service_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"parent_srv_id": {
|
||||||
"parent_srv_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"parent_srv_type": {
|
||||||
"parent_srv_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ram_total": {
|
||||||
"ram_total": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"rg_name": {
|
||||||
"rg_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"snapshots": {
|
||||||
"snapshots": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"label": {
|
||||||
"label": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"timestamp": {
|
||||||
"timestamp": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"valid": {
|
||||||
"valid": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
"ssh_key": {
|
||||||
"ssh_key": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ssh_user": {
|
||||||
"ssh_user": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_by": {
|
||||||
"updated_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_time": {
|
||||||
"updated_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"user_managed": {
|
||||||
"user_managed": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceBasicService() *schema.Resource {
|
||||||
func DataSourceBasicService() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceBasicServiceRead,
|
||||||
ReadContext: dataSourceBasicServiceRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceBasicServiceSchemaMake(),
|
||||||
Schema: dataSourceBasicServiceSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,85 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
|
||||||
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
|
d.Set("entry_count", basicServiceDeletedList.EntryCount)
|
||||||
d.Set("entry_count", basicServiceDeletedList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceBasicServiceDeletedListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceBasicServiceDeletedListSchemaMake() map[string]*schema.Schema {
|
temp := dataSourceBasicServiceListSchemaMake()
|
||||||
temp := dataSourceBasicServiceListSchemaMake()
|
|
||||||
|
delete(temp, "by_id")
|
||||||
delete(temp, "by_id")
|
delete(temp, "name")
|
||||||
delete(temp, "name")
|
delete(temp, "rg_name")
|
||||||
delete(temp, "rg_name")
|
delete(temp, "status")
|
||||||
delete(temp, "status")
|
delete(temp, "tech_status")
|
||||||
delete(temp, "tech_status")
|
delete(temp, "account_name")
|
||||||
delete(temp, "account_name")
|
|
||||||
|
return temp
|
||||||
return temp
|
}
|
||||||
}
|
|
||||||
|
func DataSourceBasicServiceDeletedList() *schema.Resource {
|
||||||
func DataSourceBasicServiceDeletedList() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceBasicServiceDeletedListRead,
|
||||||
ReadContext: dataSourceBasicServiceDeletedListRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
|
||||||
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,305 +1,304 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
bsg, err := utilityBasicServiceGroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("account_id", bsg.AccountID)
|
||||||
d.Set("account_id", bsg.AccountID)
|
d.Set("account_name", bsg.AccountName)
|
||||||
d.Set("account_name", bsg.AccountName)
|
d.Set("computes", flattenBSGroupComputes(bsg.Computes))
|
||||||
d.Set("computes", flattenBSGroupComputes(bsg.Computes))
|
d.Set("consistency", bsg.Consistency)
|
||||||
d.Set("consistency", bsg.Consistency)
|
d.Set("cpu", bsg.CPU)
|
||||||
d.Set("cpu", bsg.CPU)
|
d.Set("created_by", bsg.CreatedBy)
|
||||||
d.Set("created_by", bsg.CreatedBy)
|
d.Set("created_time", bsg.CreatedTime)
|
||||||
d.Set("created_time", bsg.CreatedTime)
|
d.Set("deleted_by", bsg.DeletedBy)
|
||||||
d.Set("deleted_by", bsg.DeletedBy)
|
d.Set("deleted_time", bsg.DeletedTime)
|
||||||
d.Set("deleted_time", bsg.DeletedTime)
|
d.Set("disk", bsg.Disk)
|
||||||
d.Set("disk", bsg.Disk)
|
d.Set("driver", bsg.Driver)
|
||||||
d.Set("driver", bsg.Driver)
|
d.Set("extnets", bsg.ExtNets)
|
||||||
d.Set("extnets", bsg.ExtNets)
|
d.Set("gid", bsg.GID)
|
||||||
d.Set("gid", bsg.GID)
|
d.Set("guid", bsg.GUID)
|
||||||
d.Set("guid", bsg.GUID)
|
d.Set("image_id", bsg.ImageID)
|
||||||
d.Set("image_id", bsg.ImageID)
|
d.Set("milestones", bsg.Milestones)
|
||||||
d.Set("milestones", bsg.Milestones)
|
d.Set("compgroup_name", bsg.Name)
|
||||||
d.Set("compgroup_name", bsg.Name)
|
d.Set("parents", bsg.Parents)
|
||||||
d.Set("parents", bsg.Parents)
|
d.Set("ram", bsg.RAM)
|
||||||
d.Set("ram", bsg.RAM)
|
d.Set("rg_id", bsg.RGID)
|
||||||
d.Set("rg_id", bsg.RGID)
|
d.Set("rg_name", bsg.RGName)
|
||||||
d.Set("rg_name", bsg.RGName)
|
d.Set("role", bsg.Role)
|
||||||
d.Set("role", bsg.Role)
|
d.Set("sep_id", bsg.SEPID)
|
||||||
d.Set("sep_id", bsg.SEPID)
|
d.Set("seq_no", bsg.SeqNo)
|
||||||
d.Set("seq_no", bsg.SeqNo)
|
d.Set("status", bsg.Status)
|
||||||
d.Set("status", bsg.Status)
|
d.Set("tech_status", bsg.TechStatus)
|
||||||
d.Set("tech_status", bsg.TechStatus)
|
d.Set("timeout_start", bsg.TimeoutStart)
|
||||||
d.Set("timeout_start", bsg.TimeoutStart)
|
d.Set("updated_by", bsg.UpdatedBy)
|
||||||
d.Set("updated_by", bsg.UpdatedBy)
|
d.Set("updated_time", bsg.UpdatedTime)
|
||||||
d.Set("updated_time", bsg.UpdatedTime)
|
d.Set("vinses", bsg.VINSes)
|
||||||
d.Set("vinses", bsg.VINSes)
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func flattenBSGroupOSUsers(bsgosus bservice.ListOSUsers) []map[string]interface{} {
|
||||||
func flattenBSGroupOSUsers(bsgosus bservice.ListOSUsers) []map[string]interface{} {
|
res := make([]map[string]interface{}, 0)
|
||||||
res := make([]map[string]interface{}, 0)
|
for _, bsgosu := range bsgosus {
|
||||||
for _, bsgosu := range bsgosus {
|
temp := map[string]interface{}{
|
||||||
temp := map[string]interface{}{
|
"login": bsgosu.Login,
|
||||||
"login": bsgosu.Login,
|
"password": bsgosu.Password,
|
||||||
"password": bsgosu.Password,
|
}
|
||||||
}
|
res = append(res, temp)
|
||||||
res = append(res, temp)
|
}
|
||||||
}
|
|
||||||
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]interface{} {
|
||||||
func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]interface{} {
|
res := make([]map[string]interface{}, 0)
|
||||||
res := make([]map[string]interface{}, 0)
|
for _, bsgc := range bsgcs {
|
||||||
for _, bsgc := range bsgcs {
|
temp := map[string]interface{}{
|
||||||
temp := map[string]interface{}{
|
"id": bsgc.ID,
|
||||||
"id": bsgc.ID,
|
"ip_addresses": bsgc.IPAddresses,
|
||||||
"ip_addresses": bsgc.IPAddresses,
|
"name": bsgc.Name,
|
||||||
"name": bsgc.Name,
|
"os_users": flattenBSGroupOSUsers(bsgc.OSUsers),
|
||||||
"os_users": flattenBSGroupOSUsers(bsgc.OSUsers),
|
}
|
||||||
}
|
res = append(res, temp)
|
||||||
res = append(res, temp)
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"service_id": {
|
||||||
"service_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
},
|
||||||
},
|
"compgroup_id": {
|
||||||
"compgroup_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
},
|
||||||
},
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"account_name": {
|
||||||
"account_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"computes": {
|
||||||
"computes": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"id": {
|
||||||
"id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ip_addresses": {
|
||||||
"ip_addresses": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
},
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"os_users": {
|
||||||
"os_users": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"login": {
|
||||||
"login": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"password": {
|
||||||
"password": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
"consistency": {
|
||||||
"consistency": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"cpu": {
|
||||||
"cpu": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_by": {
|
||||||
"created_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"created_time": {
|
||||||
"created_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_by": {
|
||||||
"deleted_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
"deleted_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"disk": {
|
||||||
"disk": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"driver": {
|
||||||
"driver": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"extnets": {
|
||||||
"extnets": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
},
|
||||||
},
|
"gid": {
|
||||||
"gid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"image_id": {
|
||||||
"image_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"milestones": {
|
||||||
"milestones": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"compgroup_name": {
|
||||||
"compgroup_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"parents": {
|
||||||
"parents": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
},
|
||||||
},
|
"ram": {
|
||||||
"ram": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"rg_name": {
|
||||||
"rg_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"role": {
|
||||||
"role": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"sep_id": {
|
||||||
"sep_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"seq_no": {
|
||||||
"seq_no": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"timeout_start": {
|
||||||
"timeout_start": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_by": {
|
||||||
"updated_by": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"updated_time": {
|
||||||
"updated_time": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"vinses": {
|
||||||
"vinses": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceBasicServiceGroup() *schema.Resource {
|
||||||
func DataSourceBasicServiceGroup() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceBasicServiceGroupRead,
|
||||||
ReadContext: dataSourceBasicServiceGroupRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceBasicServiceGroupSchemaMake(),
|
||||||
Schema: dataSourceBasicServiceGroupSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,269 +1,263 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenBasicServiceList(bsl *bservice.ListBasicServices) []map[string]interface{} {
|
func flattenBasicServiceList(bsl *bservice.ListBasicServices) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, bs := range bsl.Data {
|
for _, bs := range bsl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": bs.AccountID,
|
"account_id": bs.AccountID,
|
||||||
"account_name": bs.AccountName,
|
"account_name": bs.AccountName,
|
||||||
"base_domain": bs.BaseDomain,
|
"base_domain": bs.BaseDomain,
|
||||||
"created_by": bs.CreatedBy,
|
"created_by": bs.CreatedBy,
|
||||||
"created_time": bs.CreatedTime,
|
"created_time": bs.CreatedTime,
|
||||||
"deleted_by": bs.DeletedBy,
|
"deleted_by": bs.DeletedBy,
|
||||||
"deleted_time": bs.DeletedTime,
|
"deleted_time": bs.DeletedTime,
|
||||||
"gid": bs.GID,
|
"gid": bs.GID,
|
||||||
"groups": bs.Groups,
|
"groups": bs.Groups,
|
||||||
"guid": bs.GUID,
|
"guid": bs.GUID,
|
||||||
"service_id": bs.ID,
|
"service_id": bs.ID,
|
||||||
"service_name": bs.Name,
|
"service_name": bs.Name,
|
||||||
"parent_srv_id": bs.ParentSrvID,
|
"parent_srv_id": bs.ParentSrvID,
|
||||||
"parent_srv_type": bs.ParentSrvType,
|
"parent_srv_type": bs.ParentSrvType,
|
||||||
"rg_id": bs.RGID,
|
"rg_id": bs.RGID,
|
||||||
"rg_name": bs.RGName,
|
"rg_name": bs.RGName,
|
||||||
"ssh_user": bs.SSHUser,
|
"ssh_user": bs.SSHUser,
|
||||||
"status": bs.Status,
|
"status": bs.Status,
|
||||||
"tech_status": bs.TechStatus,
|
"tech_status": bs.TechStatus,
|
||||||
"updated_by": bs.UpdatedBy,
|
"updated_by": bs.UpdatedBy,
|
||||||
"updated_time": bs.UpdatedTime,
|
"updated_time": bs.UpdatedTime,
|
||||||
"user_managed": bs.UserManaged,
|
"user_managed": bs.UserManaged,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
basicServiceList, err := utilityBasicServiceListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenBasicServiceList(basicServiceList))
|
||||||
d.Set("items", flattenBasicServiceList(basicServiceList))
|
d.Set("entry_count", basicServiceList.EntryCount)
|
||||||
d.Set("entry_count", basicServiceList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"by_id": {
|
||||||
"by_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by ID",
|
||||||
Description: "Filter by ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by bservice name",
|
||||||
Description: "Filter by bservice name",
|
},
|
||||||
},
|
"rg_name": {
|
||||||
"rg_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by resource group name",
|
||||||
Description: "Filter by resource group name",
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by status",
|
||||||
Description: "Filter by status",
|
},
|
||||||
},
|
"tech_status": {
|
||||||
"tech_status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by tech status",
|
||||||
Description: "Filter by tech status",
|
},
|
||||||
},
|
"account_name": {
|
||||||
"account_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by account name",
|
||||||
Description: "Filter by account name",
|
},
|
||||||
},
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "ID of the account to query for BasicService instances",
|
||||||
Description: "ID of the account to query for BasicService instances",
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "ID of the resource group to query for BasicService instances",
|
||||||
Description: "ID of the resource group to query for BasicService instances",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Elem: &schema.Resource{
|
||||||
Description: "Page size",
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"account_id": {
|
||||||
"items": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"account_name": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"base_domain": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"account_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"created_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"base_domain": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"created_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"created_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"deleted_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"deleted_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"gid": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"groups": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"gid": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
Elem: &schema.Schema{
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
"groups": {
|
},
|
||||||
Type: schema.TypeList,
|
"guid": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
Elem: &schema.Schema{
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
"service_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"guid": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"service_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"service_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"parent_srv_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"service_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"parent_srv_type": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"parent_srv_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"parent_srv_type": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ssh_user": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"ssh_user": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"tech_status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"tech_status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"updated_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"user_managed": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"updated_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"user_managed": {
|
},
|
||||||
Type: schema.TypeBool,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceBasicServiceList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceBasicServiceListRead,
|
||||||
|
|
||||||
func DataSourceBasicServiceList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceBasicServiceListRead,
|
|
||||||
|
Schema: dataSourceBasicServiceListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceBasicServiceListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,110 +1,105 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList))
|
||||||
d.Set("items", flattenBasicServiceSnapshotsList(basicServiceSnapshotList))
|
|
||||||
d.Set("entry_count", basicServiceSnapshotList.EntryCount)
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"service_id": {
|
||||||
"service_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "ID of the BasicService instance",
|
||||||
Description: "ID of the BasicService instance",
|
},
|
||||||
},
|
"items": {
|
||||||
"items": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"label": {
|
||||||
"label": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"timestamp": {
|
||||||
"timestamp": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"valid": {
|
||||||
"valid": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
"entry_count": {
|
return res
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
|
||||||
},
|
func DataSourceBasicServiceSnapshotList() *schema.Resource {
|
||||||
}
|
return &schema.Resource{
|
||||||
return res
|
SchemaVersion: 1,
|
||||||
}
|
|
||||||
|
ReadContext: dataSourceBasicServiceSnapshotListRead,
|
||||||
func DataSourceBasicServiceSnapshotList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
SchemaVersion: 1,
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
ReadContext: dataSourceBasicServiceSnapshotListRead,
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
}
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func flattenBasicServiceComputes(bscs bservice.ListComputes) []map[string]interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(bsrvss))
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, bsrvs := range bsrvss {
|
for _, bsrvs := range bsrvss {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"guid": bsrvs.GUID,
|
"guid": bsrvs.GUID,
|
||||||
@@ -123,17 +123,3 @@ func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]in
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenBasicServiceSnapshotsList(bsrvss *bservice.ListInfoSnapshots) []map[string]interface{} {
|
|
||||||
res := make([]map[string]interface{}, 0, len(bsrvss.Data))
|
|
||||||
for _, bsrvs := range bsrvss.Data {
|
|
||||||
temp := map[string]interface{}{
|
|
||||||
"guid": bsrvs.GUID,
|
|
||||||
"label": bsrvs.Label,
|
|
||||||
"timestamp": bsrvs.Timestamp,
|
|
||||||
"valid": bsrvs.Valid,
|
|
||||||
}
|
|
||||||
res = append(res, temp)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,73 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityBasicServiceDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
func utilityBasicServiceDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := bservice.ListDeletedRequest{}
|
req := bservice.ListDeletedRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rgId.(int))
|
req.RGID = uint64(rgId.(int))
|
||||||
}
|
}
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
req.Page = uint64(page.(int))
|
||||||
req.SortBy = sortBy.(string)
|
}
|
||||||
}
|
if size, ok := d.GetOk("size"); ok {
|
||||||
if page, ok := d.GetOk("page"); ok {
|
req.Size = uint64(size.(int))
|
||||||
req.Page = uint64(page.(int))
|
}
|
||||||
}
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
log.Debugf("utilityBasicServiceDeletedListCheckPresence")
|
||||||
req.Size = uint64(size.(int))
|
basicServiceDeletedList, err := c.CloudAPI().BService().ListDeleted(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityBasicServiceDeletedListCheckPresence")
|
}
|
||||||
basicServiceDeletedList, err := c.CloudAPI().BService().ListDeleted(ctx, req)
|
|
||||||
if err != nil {
|
return basicServiceDeletedList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return basicServiceDeletedList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,96 +1,93 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package bservice
|
package bservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListBasicServices, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := bservice.ListRequest{}
|
req := bservice.ListRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rgId.(int))
|
req.RGID = uint64(rgId.(int))
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
|
||||||
req.Size = uint64(size.(int))
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
}
|
req.ByID = uint64(by_id.(int))
|
||||||
|
}
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
|
||||||
req.ByID = uint64(by_id.(int))
|
if name, ok := d.GetOk("name"); ok {
|
||||||
}
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
|
||||||
req.Name = name.(string)
|
if rg_name, ok := d.GetOk("rg_name"); ok {
|
||||||
}
|
req.RGName = rg_name.(string)
|
||||||
|
}
|
||||||
if rg_name, ok := d.GetOk("rg_name"); ok {
|
|
||||||
req.RGName = rg_name.(string)
|
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||||
}
|
req.TechStatus = tech_status.(string)
|
||||||
|
}
|
||||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
|
||||||
req.TechStatus = tech_status.(string)
|
if status, ok := d.GetOk("status"); ok {
|
||||||
}
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
if status, ok := d.GetOk("status"); ok {
|
|
||||||
req.Status = status.(string)
|
if acc_name, ok := d.GetOk("account_name"); ok {
|
||||||
}
|
req.AccountName = acc_name.(string)
|
||||||
|
}
|
||||||
if acc_name, ok := d.GetOk("account_name"); ok {
|
|
||||||
req.AccountName = acc_name.(string)
|
log.Debugf("utilityBasicServiceListCheckPresence")
|
||||||
}
|
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
|
||||||
|
if err != nil {
|
||||||
log.Debugf("utilityBasicServiceListCheckPresence")
|
return nil, err
|
||||||
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return basicServiceList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return basicServiceList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListInfoSnapshots, error) {
|
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListSnapshots, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var id uint64
|
var id uint64
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import (
|
|||||||
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,39 +293,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Time of the last deletion attempt",
|
Description: "Time of the last deletion attempt",
|
||||||
},
|
},
|
||||||
"replication": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"self_volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"storage_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "Replication status",
|
|
||||||
},
|
|
||||||
// "reality_device_number": {
|
// "reality_device_number": {
|
||||||
// Type: schema.TypeInt,
|
// Type: schema.TypeInt,
|
||||||
// Computed: true,
|
// Computed: true,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,11 +56,6 @@ func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{}
|
|||||||
for _, typeListDetailed := range tld.Data {
|
for _, typeListDetailed := range tld.Data {
|
||||||
toMap := typeListDetailed.(map[string]interface{})
|
toMap := typeListDetailed.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
||||||
"sep_id": toMap["sepId"].(float64),
|
"sep_id": toMap["sepId"].(float64),
|
||||||
"sep_name": toMap["sepName"].(string),
|
"sep_name": toMap["sepName"].(string),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
@@ -61,9 +61,9 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
for _, pool := range pools {
|
for _, pool := range pools {
|
||||||
toMap := pool.(map[string]interface{})
|
toMap := pool.(map[string]interface{})
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"name": toMap["name"].(string),
|
"name": toMap["name"].(string),
|
||||||
"system": toMap["system"].(string),
|
"system": toMap["system"].(string),
|
||||||
"types": toMap["types"].([]interface{}),
|
"types": toMap["types"].([]interface{}),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,6 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
|||||||
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,11 +86,6 @@ func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -118,8 +112,8 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Pool name",
|
Description: "Pool name",
|
||||||
},
|
},
|
||||||
"system": {
|
"system": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"types": {
|
"types": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
@@ -138,8 +132,8 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
"sep_name": {
|
"sep_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +112,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "type of the disks",
|
Description: "type of the disks",
|
||||||
},
|
},
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -381,11 +375,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Storage endpoint provider ID to create disk",
|
Description: "Storage endpoint provider ID to create disk",
|
||||||
},
|
},
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
Description: "shareable",
|
|
||||||
},
|
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -1,480 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019-2024 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://repository.basistech.ru/BASIS/terraform-provider-decort
|
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
*/
|
|
||||||
|
|
||||||
package disks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
func dataSourceDiskReplicationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("dataSourceDiskReplicationRead: called for disk with ID: %s", d.Id())
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
req := disks.ReplicationStatusRequest{
|
|
||||||
DiskID: uint64(d.Get("disk_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
status, err := c.CloudAPI().Disks().ReplicationStatus(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
|
||||||
|
|
||||||
disk, err := utilityDiskReplicaCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
flattenDiskReplica(d, disk, status)
|
|
||||||
|
|
||||||
log.Debugf("dataSourceDiskReplicationRead: read complete for disk with ID: %s", d.Id())
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
|
|
||||||
rets := map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Id of primary disk",
|
|
||||||
},
|
|
||||||
"replica_disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Id of secondary disk",
|
|
||||||
},
|
|
||||||
"status_replication": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Status of replication",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The name of the subscriber '(account') to whom this disk belongs",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
// "boot_partition": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Number of disk partitions",
|
|
||||||
// },
|
|
||||||
"computes": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Created time",
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Deleted time",
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Description of disk",
|
|
||||||
},
|
|
||||||
"destruction_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Time of final deletion",
|
|
||||||
},
|
|
||||||
"devicename": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the device",
|
|
||||||
},
|
|
||||||
// "disk_path": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk path",
|
|
||||||
// },
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the grid (platform)",
|
|
||||||
},
|
|
||||||
// "guid": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk ID on the storage side",
|
|
||||||
// },
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Image ID",
|
|
||||||
},
|
|
||||||
"images": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
Description: "IDs of images using the disk",
|
|
||||||
},
|
|
||||||
"iotune": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"read_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of bytes to read per second",
|
|
||||||
},
|
|
||||||
"read_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of bytes to read",
|
|
||||||
},
|
|
||||||
"read_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of io read operations per second",
|
|
||||||
},
|
|
||||||
"read_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of io read operations",
|
|
||||||
},
|
|
||||||
"size_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Size of io operations",
|
|
||||||
},
|
|
||||||
"total_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Total size bytes per second",
|
|
||||||
},
|
|
||||||
"total_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum total size of bytes per second",
|
|
||||||
},
|
|
||||||
"total_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Total number of io operations per second",
|
|
||||||
},
|
|
||||||
"total_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum total number of io operations per second",
|
|
||||||
},
|
|
||||||
"write_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of bytes to write per second",
|
|
||||||
},
|
|
||||||
"write_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of bytes to write per second",
|
|
||||||
},
|
|
||||||
"write_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of write operations per second",
|
|
||||||
},
|
|
||||||
"write_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of write operations per second",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// "iqn": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk IQN",
|
|
||||||
// },
|
|
||||||
// "login": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Login to access the disk",
|
|
||||||
// },
|
|
||||||
// "milestones": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Milestones",
|
|
||||||
// },
|
|
||||||
"disk_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of disk",
|
|
||||||
},
|
|
||||||
"order": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk order",
|
|
||||||
},
|
|
||||||
"params": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk params",
|
|
||||||
},
|
|
||||||
"parent_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the parent disk",
|
|
||||||
},
|
|
||||||
// "passwd": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Password to access the disk",
|
|
||||||
// },
|
|
||||||
"pci_slot": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the pci slot to which the disk is connected",
|
|
||||||
},
|
|
||||||
"pool": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Pool for disk location",
|
|
||||||
},
|
|
||||||
"present_to": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// "purge_attempts": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Number of deletion attempts",
|
|
||||||
// },
|
|
||||||
"purge_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Time of the last deletion attempt",
|
|
||||||
},
|
|
||||||
"replication": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"self_volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"storage_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "Replication status",
|
|
||||||
},
|
|
||||||
// "reality_device_number": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Reality device number",
|
|
||||||
// },
|
|
||||||
// "reference_id": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "ID of the reference to the disk",
|
|
||||||
// },
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Resource ID",
|
|
||||||
},
|
|
||||||
"res_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the resource",
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk role",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Storage endpoint provider ID to create disk",
|
|
||||||
},
|
|
||||||
"sep_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
|
||||||
},
|
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Size in GB",
|
|
||||||
},
|
|
||||||
"size_used": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of used space, in GB",
|
|
||||||
},
|
|
||||||
"snapshots": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the snapshot",
|
|
||||||
},
|
|
||||||
"label": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the snapshot",
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Reference to the snapshot",
|
|
||||||
},
|
|
||||||
"snap_set_guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The set snapshot ID",
|
|
||||||
},
|
|
||||||
"snap_set_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The set time of the snapshot",
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Snapshot time",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk status",
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Technical status of the disk",
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
|
||||||
},
|
|
||||||
"vmid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Virtual Machine ID (Deprecated)",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceDiskReplication() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceDiskReplicationRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceDiskReplicationSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import (
|
|||||||
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
|
diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,11 +93,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "type of the disks",
|
Description: "type of the disks",
|
||||||
},
|
},
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -357,39 +351,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Time of the last deletion attempt",
|
Description: "Time of the last deletion attempt",
|
||||||
},
|
},
|
||||||
"replication": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"self_volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"storage_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "Replication status",
|
|
||||||
},
|
|
||||||
// "reality_device_number": {
|
// "reality_device_number": {
|
||||||
// Type: schema.TypeInt,
|
// Type: schema.TypeInt,
|
||||||
// Computed: true,
|
// Computed: true,
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
|
|||||||
"res_name": unattachedDisk.ResName,
|
"res_name": unattachedDisk.ResName,
|
||||||
"role": unattachedDisk.Role,
|
"role": unattachedDisk.Role,
|
||||||
"sep_id": unattachedDisk.SEPID,
|
"sep_id": unattachedDisk.SEPID,
|
||||||
"shareable": unattachedDisk.Shareable,
|
|
||||||
"size_max": unattachedDisk.SizeMax,
|
"size_max": unattachedDisk.SizeMax,
|
||||||
"size_used": unattachedDisk.SizeUsed,
|
"size_used": unattachedDisk.SizeUsed,
|
||||||
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
||||||
@@ -72,6 +71,7 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
|
|||||||
|
|
||||||
func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||||
diskAcl, _ := json.Marshal(disk.ACL)
|
diskAcl, _ := json.Marshal(disk.ACL)
|
||||||
|
|
||||||
d.Set("account_id", disk.AccountID)
|
d.Set("account_id", disk.AccountID)
|
||||||
d.Set("account_name", disk.AccountName)
|
d.Set("account_name", disk.AccountName)
|
||||||
d.Set("acl", string(diskAcl))
|
d.Set("acl", string(diskAcl))
|
||||||
@@ -102,7 +102,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
|||||||
d.Set("present_to", disk.PresentTo)
|
d.Set("present_to", disk.PresentTo)
|
||||||
// d.Set("purge_attempts", disk.PurgeAttempts)
|
// d.Set("purge_attempts", disk.PurgeAttempts)
|
||||||
d.Set("purge_time", disk.PurgeTime)
|
d.Set("purge_time", disk.PurgeTime)
|
||||||
d.Set("replication", flattenDiskReplication(disk.Replication))
|
|
||||||
// d.Set("reality_device_number", disk.RealityDeviceNumber)
|
// d.Set("reality_device_number", disk.RealityDeviceNumber)
|
||||||
// d.Set("reference_id", disk.ReferenceID)
|
// d.Set("reference_id", disk.ReferenceID)
|
||||||
d.Set("res_id", disk.ResID)
|
d.Set("res_id", disk.ResID)
|
||||||
@@ -120,71 +119,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
|||||||
d.Set("vmid", disk.VMID)
|
d.Set("vmid", disk.VMID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenDiskReplication(rep disks.ItemReplication) []map[string]interface{} {
|
|
||||||
res := []map[string]interface{}{
|
|
||||||
{
|
|
||||||
"disk_id": rep.DiskID,
|
|
||||||
"pool_id": rep.PoolID,
|
|
||||||
"role": rep.Role,
|
|
||||||
"self_volume_id": rep.SelfVolumeID,
|
|
||||||
"storage_id": rep.StorageID,
|
|
||||||
"volume_id": rep.VolumeID,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusReplication string) {
|
|
||||||
diskAcl, _ := json.Marshal(disk.ACL)
|
|
||||||
d.Set("account_id", disk.AccountID)
|
|
||||||
d.Set("account_name", disk.AccountName)
|
|
||||||
d.Set("acl", string(diskAcl))
|
|
||||||
// d.Set("boot_partition", disk.BootPartition)
|
|
||||||
d.Set("computes", flattenDiskComputes(disk.Computes))
|
|
||||||
d.Set("created_time", disk.CreatedTime)
|
|
||||||
d.Set("deleted_time", disk.DeletedTime)
|
|
||||||
d.Set("desc", disk.Description)
|
|
||||||
d.Set("destruction_time", disk.DestructionTime)
|
|
||||||
d.Set("devicename", disk.DeviceName)
|
|
||||||
// d.Set("disk_path", disk.DiskPath)
|
|
||||||
d.Set("gid", disk.GID)
|
|
||||||
// d.Set("guid", disk.GUID)
|
|
||||||
d.Set("replica_disk_id", disk.ID)
|
|
||||||
d.Set("image_id", disk.ImageID)
|
|
||||||
d.Set("images", disk.Images)
|
|
||||||
d.Set("iotune", flattenIOTune(disk.IOTune))
|
|
||||||
// d.Set("iqn", disk.IQN)
|
|
||||||
// d.Set("login", disk.Login)
|
|
||||||
// d.Set("milestones", disk.Milestones)
|
|
||||||
d.Set("disk_name", disk.Name)
|
|
||||||
d.Set("order", disk.Order)
|
|
||||||
d.Set("params", disk.Params)
|
|
||||||
d.Set("parent_id", disk.ParentID)
|
|
||||||
// d.Set("passwd", disk.Passwd)
|
|
||||||
d.Set("pci_slot", disk.PCISlot)
|
|
||||||
d.Set("pool", disk.Pool)
|
|
||||||
d.Set("present_to", disk.PresentTo)
|
|
||||||
// d.Set("purge_attempts", disk.PurgeAttempts)
|
|
||||||
d.Set("purge_time", disk.PurgeTime)
|
|
||||||
d.Set("replication", flattenDiskReplication(disk.Replication))
|
|
||||||
// d.Set("reality_device_number", disk.RealityDeviceNumber)
|
|
||||||
// d.Set("reference_id", disk.ReferenceID)
|
|
||||||
d.Set("res_id", disk.ResID)
|
|
||||||
d.Set("res_name", disk.ResName)
|
|
||||||
d.Set("role", disk.Role)
|
|
||||||
d.Set("sep_id", disk.SepID)
|
|
||||||
d.Set("sep_type", disk.SepType)
|
|
||||||
d.Set("size_max", disk.SizeMax)
|
|
||||||
d.Set("size_used", disk.SizeUsed)
|
|
||||||
d.Set("shareable", disk.Shareable)
|
|
||||||
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
|
||||||
d.Set("status", disk.Status)
|
|
||||||
d.Set("status_replication", statusReplication)
|
|
||||||
d.Set("tech_status", disk.TechStatus)
|
|
||||||
d.Set("type", disk.Type)
|
|
||||||
d.Set("vmid", disk.VMID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||||
res := make([]interface{}, 0, len(sl))
|
res := make([]interface{}, 0, len(sl))
|
||||||
for _, snapshot := range sl {
|
for _, snapshot := range sl {
|
||||||
@@ -231,7 +165,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
|||||||
"pool": disk.Pool,
|
"pool": disk.Pool,
|
||||||
"present_to": disk.PresentTo,
|
"present_to": disk.PresentTo,
|
||||||
"purge_time": disk.PurgeTime,
|
"purge_time": disk.PurgeTime,
|
||||||
"replication": flattenDiskReplication(disk.Replication),
|
|
||||||
"res_id": disk.ResID,
|
"res_id": disk.ResID,
|
||||||
"res_name": disk.ResName,
|
"res_name": disk.ResName,
|
||||||
"role": disk.Role,
|
"role": disk.Role,
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package disks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
@@ -36,26 +34,3 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
|
|||||||
|
|
||||||
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func existDiskID(ctx context.Context, diskId uint64, m interface{}) error {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
req := disks.ListRequest{
|
|
||||||
ByID: diskId,
|
|
||||||
}
|
|
||||||
|
|
||||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(diskList.Data) == 0 {
|
|
||||||
return fmt.Errorf("resourceDiskReplication: can't create or update Disk replication because DiskID %d is not allowed or does not exist", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diskList.Data[0].SepType != "TATLIN" {
|
|
||||||
return fmt.Errorf("resourceDiskReplication: can't create or update Disk replication because DiskID %d is not TATLIN SEP Type", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
diskId, err := c.CloudAPI().Disks().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +219,6 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
|
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,9 +377,9 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"disk_name": {
|
"disk_name": {
|
||||||
@@ -395,9 +393,9 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "Size in GB",
|
Description: "Size in GB",
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the grid (platform)",
|
Description: "ID of the grid (platform)",
|
||||||
},
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
@@ -671,39 +669,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Time of the last deletion attempt",
|
Description: "Time of the last deletion attempt",
|
||||||
},
|
},
|
||||||
"replication": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"self_volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"storage_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "Replication status",
|
|
||||||
},
|
|
||||||
// "reality_device_number": {
|
// "reality_device_number": {
|
||||||
// Type: schema.TypeInt,
|
// Type: schema.TypeInt,
|
||||||
// Computed: true,
|
// Computed: true,
|
||||||
|
|||||||
@@ -1,642 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019-2024 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://repository.basistech.ru/BASIS/terraform-provider-decort
|
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
*/
|
|
||||||
|
|
||||||
package disks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceDiskReplicationCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationCreate: called for disk with ID: %d", diskId)
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
err := existDiskID(ctx, diskId, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
reqCreate := disks.ReplicateRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
Name: d.Get("disk_name").(string),
|
|
||||||
SepID: uint64(d.Get("sep_id").(int)),
|
|
||||||
PoolName: d.Get("pool_name").(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
diskReplicaId, err := c.CloudAPI().Disks().Replicate(ctx, reqCreate)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(diskReplicaId, 10))
|
|
||||||
d.Set("replica_disk_id", diskReplicaId)
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationCreate: create replica complete for disk with ID: %d", diskId)
|
|
||||||
|
|
||||||
warnings := dc.Warnings{}
|
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok && !start.(bool) {
|
|
||||||
log.Debugf("resourceDiskReplicationCreate: replication between disk with ID: %d and replica with ID: %d, try to stop", diskId, diskReplicaId)
|
|
||||||
reqStop := disks.ReplicationStopRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
}
|
|
||||||
_, err = c.CloudAPI().Disks().ReplicationStop(ctx, reqStop)
|
|
||||||
if err != nil {
|
|
||||||
warnings.Add(err)
|
|
||||||
}
|
|
||||||
log.Debugf("resourceDiskReplicationCreate: replication between disk with ID: %d and replica with ID: %d, stoped", diskId, diskReplicaId)
|
|
||||||
}
|
|
||||||
return append(resourceDiskReplicationRead(ctx, d, m), warnings.Get()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceDiskReplicationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceDiskReplicationRead: called for disk with ID: %s", d.Id())
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
req := disks.ReplicationStatusRequest{
|
|
||||||
DiskID: uint64(d.Get("disk_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
status, err := c.CloudAPI().Disks().ReplicationStatus(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diskReplica, err := utilityDiskReplicaCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
flattenDiskReplica(d, diskReplica, status)
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationRead: read complete for disk with ID: %s", d.Id())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceDiskReplicationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
log.Debugf("resourceDiskReplicationUpdate: called for disk with ID: %d", diskId)
|
|
||||||
|
|
||||||
err := existDiskID(ctx, diskId, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("start") {
|
|
||||||
if err := utilityDiskReplicationUpdateStartStop(ctx, d, m); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("pause") {
|
|
||||||
if err := utilityDiskReplicationUpdatePause(ctx, d, m); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("reverse") {
|
|
||||||
if err := utilityDiskReplicationUpdateReverse(ctx, d, m); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationUpdate: read complete for disk with ID: %d", diskId)
|
|
||||||
return resourceDiskReplicationRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceDiskReplicationDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
log.Debugf("resourceDiskReplicationDelete: called for disk with ID: %d", diskId)
|
|
||||||
|
|
||||||
disk, err := utilityDiskReplicaCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
if d.Get("start").(bool) {
|
|
||||||
reqStop := disks.ReplicationStopRequest{
|
|
||||||
DiskID: uint64(d.Get("disk_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationDelete: stop replication for disk with ID: %d", diskId)
|
|
||||||
_, err = c.CloudAPI().Disks().ReplicationStop(ctx, reqStop)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
log.Debugf("resourceDiskReplicationDelete: stop replication for disk with ID: %d, complete", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
reqDelete := disks.DeleteRequest{
|
|
||||||
DiskID: disk.ID,
|
|
||||||
Detach: d.Get("detach").(bool),
|
|
||||||
Permanently: d.Get("permanently").(bool),
|
|
||||||
Reason: d.Get("reason").(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceDiskReplicationDelete: delete disk replica for disk with ID: %d", diskId)
|
|
||||||
_, err = c.CloudAPI().Disks().Delete(ctx, reqDelete)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
log.Debugf("resourceDiskReplicationDelete: delete disk replica for disk with ID: %d, complete", diskId)
|
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
|
|
||||||
rets := map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Id of primary disk",
|
|
||||||
},
|
|
||||||
"disk_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of disk replica",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Storage endpoint provider ID to create disk replica",
|
|
||||||
},
|
|
||||||
"pool_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Pool for disk location",
|
|
||||||
},
|
|
||||||
"pause": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Resume replication",
|
|
||||||
},
|
|
||||||
"reverse": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Reverse replication",
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "Start/Stop replication",
|
|
||||||
},
|
|
||||||
"detach": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Detach disk from machine first",
|
|
||||||
},
|
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Delete disk permanently",
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Reason for disk deletion",
|
|
||||||
},
|
|
||||||
"replica_disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Id of replica disk",
|
|
||||||
},
|
|
||||||
"status_replication": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Status of replication",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The name of the subscriber '(account') to whom this disk belongs",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
// "boot_partition": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Number of disk partitions",
|
|
||||||
// },
|
|
||||||
"computes": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Created time",
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Deleted time",
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Description of disk",
|
|
||||||
},
|
|
||||||
"destruction_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Time of final deletion",
|
|
||||||
},
|
|
||||||
"devicename": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the device",
|
|
||||||
},
|
|
||||||
// "disk_path": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk path",
|
|
||||||
// },
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the grid (platform)",
|
|
||||||
},
|
|
||||||
// "guid": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk ID on the storage side",
|
|
||||||
// },
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Image ID",
|
|
||||||
},
|
|
||||||
"images": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
Description: "IDs of images using the disk",
|
|
||||||
},
|
|
||||||
"iotune": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"read_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of bytes to read per second",
|
|
||||||
},
|
|
||||||
"read_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of bytes to read",
|
|
||||||
},
|
|
||||||
"read_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of io read operations per second",
|
|
||||||
},
|
|
||||||
"read_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of io read operations",
|
|
||||||
},
|
|
||||||
"size_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Size of io operations",
|
|
||||||
},
|
|
||||||
"total_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Total size bytes per second",
|
|
||||||
},
|
|
||||||
"total_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum total size of bytes per second",
|
|
||||||
},
|
|
||||||
"total_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Total number of io operations per second",
|
|
||||||
},
|
|
||||||
"total_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum total number of io operations per second",
|
|
||||||
},
|
|
||||||
"write_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of bytes to write per second",
|
|
||||||
},
|
|
||||||
"write_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of bytes to write per second",
|
|
||||||
},
|
|
||||||
"write_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of write operations per second",
|
|
||||||
},
|
|
||||||
"write_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Maximum number of write operations per second",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// "iqn": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Disk IQN",
|
|
||||||
// },
|
|
||||||
// "login": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Login to access the disk",
|
|
||||||
// },
|
|
||||||
// "milestones": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Milestones",
|
|
||||||
// },
|
|
||||||
"order": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk order",
|
|
||||||
},
|
|
||||||
"params": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk params",
|
|
||||||
},
|
|
||||||
"parent_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the parent disk",
|
|
||||||
},
|
|
||||||
// "passwd": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Password to access the disk",
|
|
||||||
// },
|
|
||||||
"pci_slot": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the pci slot to which the disk is connected",
|
|
||||||
},
|
|
||||||
"present_to": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// "purge_attempts": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Number of deletion attempts",
|
|
||||||
// },
|
|
||||||
"purge_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Time of the last deletion attempt",
|
|
||||||
},
|
|
||||||
"replication": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"self_volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"storage_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"volume_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Description: "Replication status",
|
|
||||||
},
|
|
||||||
// "reality_device_number": {
|
|
||||||
// Type: schema.TypeInt,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "Reality device number",
|
|
||||||
// },
|
|
||||||
// "reference_id": {
|
|
||||||
// Type: schema.TypeString,
|
|
||||||
// Computed: true,
|
|
||||||
// Description: "ID of the reference to the disk",
|
|
||||||
// },
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Resource ID",
|
|
||||||
},
|
|
||||||
"res_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the resource",
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk role",
|
|
||||||
},
|
|
||||||
"sep_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
|
||||||
},
|
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Size in GB",
|
|
||||||
},
|
|
||||||
"size_used": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Number of used space, in GB",
|
|
||||||
},
|
|
||||||
"snapshots": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the snapshot",
|
|
||||||
},
|
|
||||||
"label": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the snapshot",
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Reference to the snapshot",
|
|
||||||
},
|
|
||||||
"snap_set_guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The set snapshot ID",
|
|
||||||
},
|
|
||||||
"snap_set_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The set time of the snapshot",
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Snapshot time",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Disk status",
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Technical status of the disk",
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
|
||||||
},
|
|
||||||
"vmid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Virtual Machine ID (Deprecated)",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceDiskReplication() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceDiskReplicationCreate,
|
|
||||||
ReadContext: resourceDiskReplicationRead,
|
|
||||||
UpdateContext: resourceDiskReplicationUpdate,
|
|
||||||
DeleteContext: resourceDiskReplicationDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout600s,
|
|
||||||
Read: &constants.Timeout300s,
|
|
||||||
Update: &constants.Timeout300s,
|
|
||||||
Delete: &constants.Timeout300s,
|
|
||||||
Default: &constants.Timeout300s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceDiskReplicationSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -83,7 +83,6 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,15 +169,15 @@ func resourceDiskSnapshotDelete(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "The unique ID of the subscriber-owner of the disk",
|
Description: "The unique ID of the subscriber-owner of the disk",
|
||||||
},
|
},
|
||||||
"label": {
|
"label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Name of the snapshot",
|
Description: "Name of the snapshot",
|
||||||
},
|
},
|
||||||
"rollback": {
|
"rollback": {
|
||||||
|
|||||||
@@ -1,97 +1,94 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package disks
|
package disks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
|
func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := disks.ListRequest{}
|
req := disks.ListRequest{}
|
||||||
|
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(by_id.(int))
|
req.ByID = uint64(by_id.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if account_name, ok := d.GetOk("account_name"); ok {
|
if account_name, ok := d.GetOk("account_name"); ok {
|
||||||
req.AccountName = account_name.(string)
|
req.AccountName = account_name.(string)
|
||||||
}
|
}
|
||||||
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
|
||||||
req.DiskMaxSize = int64(disk_max_size.(int))
|
req.DiskMaxSize = int64(disk_max_size.(int))
|
||||||
}
|
}
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
if shared, ok := d.GetOk("shared"); ok {
|
if shared, ok := d.GetOk("shared"); ok {
|
||||||
req.Shared = shared.(bool)
|
req.Shared = shared.(bool)
|
||||||
}
|
}
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if diskType, ok := d.GetOk("type"); ok {
|
if diskType, ok := d.GetOk("type"); ok {
|
||||||
req.Type = strings.ToUpper(diskType.(string))
|
req.Type = strings.ToUpper(diskType.(string))
|
||||||
}
|
}
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
req.AccountID = uint64(sepId.(int))
|
req.AccountID = uint64(sepId.(int))
|
||||||
}
|
}
|
||||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||||
req.Pool = pool_name.(string)
|
req.Pool = pool_name.(string)
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
|
||||||
req.Size = uint64(size.(int))
|
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
||||||
}
|
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
||||||
|
if err != nil {
|
||||||
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
return nil, err
|
||||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return diskList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return diskList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -54,10 +54,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource
|
|||||||
req.Type = typev.(string)
|
req.Type = typev.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
|
||||||
req.SortBy = sortBy.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
|
|||||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||||
req.Pool = pool_name.(string)
|
req.Pool = pool_name.(string)
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
|
||||||
req.SortBy = sortBy.(string)
|
|
||||||
}
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,174 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019-2024 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://repository.basistech.ru/BASIS/terraform-provider-decort
|
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
*/
|
|
||||||
|
|
||||||
package disks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
func utilityDiskReplicationUpdateStartStop(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
targetDiskId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: start update for disk replica with ID: %d", diskId)
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
start, ok := d.GetOk("start")
|
|
||||||
|
|
||||||
if ok && start.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: start disk replication from Disk with ID: %d to Disk with ID: %d", diskId, targetDiskId)
|
|
||||||
req := disks.ReplicationStartRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
TargetDiskID: targetDiskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationStart(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: start disk replication from Disk with ID: %d to Disk with ID: %d, complete", diskId, targetDiskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ok && !start.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: stop disk replication from Disk with ID: %d to Disk with ID: %d", targetDiskId, diskId)
|
|
||||||
req := disks.ReplicationStopRequest{
|
|
||||||
DiskID: targetDiskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationStop(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: stop disk replication from Disk with ID: %d to Disk with ID: %d, complete", targetDiskId, diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicationUpdateStartStop: complete update for disk replica with ID: %d", diskId)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func utilityDiskReplicationUpdatePause(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: start update for disk replica with ID: %d", diskId)
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
pause, ok := d.GetOk("pause")
|
|
||||||
|
|
||||||
if ok && pause.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: pause disk replication with ID: %d", diskId)
|
|
||||||
req := disks.ReplicationSuspendRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationSuspend(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: pause disk replication with ID: %d, complete", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ok && !pause.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: resume disk replication with ID: %d", diskId)
|
|
||||||
req := disks.ReplicationResumeRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationResume(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: resume disk replication with ID: %d, complete", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicationUpdatePause: complete update for disk replica with ID: %d", diskId)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func utilityDiskReplicationUpdateReverse(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
targetDiskId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: start update for disk replica with ID: %d", diskId)
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
reverse, ok := d.GetOk("reverse")
|
|
||||||
|
|
||||||
if ok && reverse.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: reverse disk replication from Disk with ID: %d to Disk with ID: %d", diskId, targetDiskId)
|
|
||||||
req := disks.ReplicationReverseRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationReverse(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: reverse disk replication from Disk with ID: %d to Disk with ID: %d, complete", diskId, targetDiskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ok && !reverse.(bool) {
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: reverse disk replication from Disk with ID: %d to Disk with ID: %d", targetDiskId, diskId)
|
|
||||||
req := disks.ReplicationReverseRequest{
|
|
||||||
DiskID: targetDiskId,
|
|
||||||
}
|
|
||||||
_, err := c.CloudAPI().Disks().ReplicationReverse(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: reverse disk replication from Disk with ID: %d to Disk with ID: %d, complete", targetDiskId, diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicaUpdateReverse: complete update for disk replica with ID: %d", diskId)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func utilityDiskReplicaCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.RecordDisk, error) {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
|
||||||
req := disks.GetRequest{}
|
|
||||||
|
|
||||||
if d.Id() != "" {
|
|
||||||
diskId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
req.DiskID = diskId
|
|
||||||
} else {
|
|
||||||
req.DiskID = uint64(d.Get("replica_disk_id").(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityDiskReplicaCheckPresence: load disk")
|
|
||||||
disk, err := c.CloudAPI().Disks().Get(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return disk, nil
|
|
||||||
}
|
|
||||||
@@ -46,10 +46,7 @@ func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.Re
|
|||||||
req := disks.ListTypesRequest{
|
req := disks.ListTypesRequest{
|
||||||
Detailed: true,
|
Detailed: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
|
||||||
req.SortBy = sortBy.(string)
|
|
||||||
}
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceDa
|
|||||||
Detailed: false,
|
Detailed: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
|
||||||
req.SortBy = sortBy.(string)
|
|
||||||
}
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,286 +1,285 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
Tim Tkachev, <tvtkachev@basistech.ru>
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
e, err := utilityExtnetCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
d.SetId(strconv.FormatUint(e.ID, 10))
|
||||||
d.SetId(strconv.FormatUint(e.ID, 10))
|
flattenExtnet(d, e)
|
||||||
flattenExtnet(d, e)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"net_id": {
|
||||||
"net_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
},
|
||||||
},
|
"ckey": {
|
||||||
"ckey": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"meta": {
|
||||||
"meta": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
},
|
Description: "meta",
|
||||||
Description: "meta",
|
},
|
||||||
},
|
"check_ips": {
|
||||||
"check_ips": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
},
|
},
|
||||||
},
|
"default": {
|
||||||
"default": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"default_qos": {
|
||||||
"default_qos": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"e_rate": {
|
||||||
"e_rate": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"e_burst": {
|
||||||
"e_burst": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"in_burst": {
|
||||||
"in_burst": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"in_rate": {
|
||||||
"in_rate": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
"desc": {
|
||||||
"desc": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"dns": {
|
||||||
"dns": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
},
|
},
|
||||||
},
|
"excluded": {
|
||||||
"excluded": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"client_type": {
|
||||||
"client_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"mac": {
|
||||||
"mac": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ip": {
|
||||||
"ip": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"type": {
|
||||||
"type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"vm_id": {
|
||||||
"vm_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
"free_ips": {
|
||||||
"free_ips": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"gateway": {
|
||||||
"gateway": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"gid": {
|
||||||
"gid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"guid": {
|
||||||
"guid": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ipcidr": {
|
||||||
"ipcidr": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"milestones": {
|
||||||
"milestones": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"net_name": {
|
||||||
"net_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"network": {
|
||||||
"network": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"network_id": {
|
||||||
"network_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"pre_reservations_num": {
|
||||||
"pre_reservations_num": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"prefix": {
|
||||||
"prefix": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"pri_vnf_dev_id": {
|
||||||
"pri_vnf_dev_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"reservations": {
|
||||||
"reservations": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"client_type": {
|
||||||
"client_type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"domainname": {
|
||||||
"domainname": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"hostname": {
|
||||||
"hostname": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"desc": {
|
||||||
"desc": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"ip": {
|
||||||
"ip": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"mac": {
|
||||||
"mac": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"type": {
|
||||||
"type": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"vm_id": {
|
||||||
"vm_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
"shared_with": {
|
||||||
"shared_with": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Schema{
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"vlan_id": {
|
||||||
"vlan_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
"vnfs": {
|
||||||
"vnfs": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: map[string]*schema.Schema{
|
"dhcp": {
|
||||||
"dhcp": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceExtnet() *schema.Resource {
|
||||||
func DataSourceExtnet() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceExtnetRead,
|
||||||
ReadContext: dataSourceExtnetRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceExtnetSchemaMake(),
|
||||||
Schema: dataSourceExtnetSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,167 +1,161 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
||||||
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
d.Set("entry_count", extnetComputesList.EntryCount)
|
||||||
d.Set("entry_count", extnetComputesList.EntryCount)
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Required: true,
|
||||||
Required: true,
|
Description: "filter by account ID",
|
||||||
Description: "filter by account ID",
|
},
|
||||||
},
|
"rg_id": {
|
||||||
"rg_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by RG ID",
|
||||||
Description: "Filter by RG ID",
|
},
|
||||||
},
|
"compute_id": {
|
||||||
"compute_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by compute ID",
|
||||||
Description: "Filter by compute ID",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Elem: &schema.Resource{
|
||||||
Description: "Page size",
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"account_id": {
|
||||||
"items": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"account_name": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"extnets": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"account_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
Elem: &schema.Resource{
|
||||||
Computed: true,
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"net_id": {
|
||||||
"extnets": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"ipaddr": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"net_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"ipcidr": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"ipaddr": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"ipcidr": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"name": {
|
},
|
||||||
Type: schema.TypeString,
|
"id": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
"name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"rg_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"rg_name": {
|
},
|
||||||
Type: schema.TypeString,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
},
|
return res
|
||||||
"entry_count": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
func DataSourceExtnetComputesList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
return res
|
|
||||||
}
|
ReadContext: dataSourceExtnetComputesListRead,
|
||||||
|
|
||||||
func DataSourceExtnetComputesList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceExtnetComputesListRead,
|
|
||||||
|
Schema: dataSourceExtnetComputesListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceExtnetComputesListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,86 +1,85 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
extnetId, err := utilityExtnetDefaultCheckPresence(ctx, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32)
|
||||||
extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32)
|
if err != nil {
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
d.Set("net_id", extnetIdInt)
|
||||||
d.Set("net_id", extnetIdInt)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"net_id": {
|
||||||
"net_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
},
|
}
|
||||||
}
|
return res
|
||||||
return res
|
}
|
||||||
}
|
|
||||||
|
func DataSourceExtnetDefault() *schema.Resource {
|
||||||
func DataSourceExtnetDefault() *schema.Resource {
|
return &schema.Resource{
|
||||||
return &schema.Resource{
|
SchemaVersion: 1,
|
||||||
SchemaVersion: 1,
|
|
||||||
|
ReadContext: dataSourceExtnetDefaultRead,
|
||||||
ReadContext: dataSourceExtnetDefaultRead,
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Read: &constants.Timeout30s,
|
||||||
Read: &constants.Timeout30s,
|
Default: &constants.Timeout60s,
|
||||||
Default: &constants.Timeout60s,
|
},
|
||||||
},
|
|
||||||
|
Schema: dataSourceExtnetDefaultSchemaMake(),
|
||||||
Schema: dataSourceExtnetDefaultSchemaMake(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,155 +1,145 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenExtnetList(extnetList))
|
||||||
d.Set("items", flattenExtnetList(extnetList))
|
d.Set("entry_count", extnetList.EntryCount)
|
||||||
d.Set("entry_count", extnetList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
res := map[string]*schema.Schema{
|
||||||
res := map[string]*schema.Schema{
|
"account_id": {
|
||||||
"account_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by account ID",
|
||||||
Description: "Find by account ID",
|
},
|
||||||
},
|
"by_id": {
|
||||||
"by_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by ID",
|
||||||
Description: "Find by ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by name",
|
||||||
Description: "Find by name",
|
},
|
||||||
},
|
"network": {
|
||||||
"network": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
},
|
||||||
},
|
"vlan_id": {
|
||||||
"vlan_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by VLAN ID",
|
||||||
Description: "Find by VLAN ID",
|
},
|
||||||
},
|
"vnfdev_id": {
|
||||||
"vnfdev_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by VnfDEV ID",
|
||||||
Description: "Find by VnfDEV ID",
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find by status",
|
||||||
Description: "Find by status",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Page size",
|
||||||
Description: "Page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Elem: &schema.Resource{
|
||||||
Description: "Page size",
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"net_id": {
|
||||||
"items": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"ipcidr": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"net_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"ipcidr": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"name": {
|
},
|
||||||
Type: schema.TypeString,
|
"entry_count": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"status": {
|
},
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
return res
|
||||||
},
|
}
|
||||||
},
|
|
||||||
},
|
func DataSourceExtnetList() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
"entry_count": {
|
SchemaVersion: 1,
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
ReadContext: dataSourceExtnetListRead,
|
||||||
},
|
|
||||||
}
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return res
|
Read: &constants.Timeout30s,
|
||||||
}
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
func DataSourceExtnetList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
Schema: dataSourceExtnetListSchemaMake(),
|
||||||
SchemaVersion: 1,
|
}
|
||||||
|
}
|
||||||
ReadContext: dataSourceExtnetListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceExtnetListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(ecs))
|
res := make([]map[string]interface{}, 0, len (ecs))
|
||||||
for _, ec := range ecs {
|
for _, ec := range ecs {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"net_id": ec.ID,
|
"net_id": ec.ID,
|
||||||
@@ -129,7 +129,6 @@ func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
|||||||
"net_id": e.ID,
|
"net_id": e.ID,
|
||||||
"ipcidr": e.IPCIDR,
|
"ipcidr": e.IPCIDR,
|
||||||
"name": e.Name,
|
"name": e.Name,
|
||||||
"status": e.Status,
|
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNetComputes, error) {
|
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNetComputes, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := extnet.ListComputesRequest{
|
req := extnet.ListComputesRequest{
|
||||||
AccountID: uint64(d.Get("account_id").(int)),
|
AccountID: uint64(d.Get("account_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rg_id.(int))
|
req.RGID = uint64(rg_id.(int))
|
||||||
}
|
}
|
||||||
if compute_id, ok := d.GetOk("compute_id"); ok {
|
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||||
req.ComputeID = uint64(compute_id.(int))
|
req.ComputeID = uint64(compute_id.(int))
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
|
||||||
req.Size = uint64(size.(int))
|
|
||||||
}
|
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||||
|
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
||||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
if err != nil {
|
||||||
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
}
|
return extnetComputesList, nil
|
||||||
|
}
|
||||||
return extnetComputesList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,87 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package extnet
|
package extnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNets, error) {
|
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.ListExtNets, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := extnet.ListRequest{}
|
req := extnet.ListRequest{}
|
||||||
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(by_id.(int))
|
req.ByID = uint64(by_id.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if network, ok := d.GetOk("network"); ok {
|
if network, ok := d.GetOk("network"); ok {
|
||||||
req.Network = network.(string)
|
req.Network = network.(string)
|
||||||
}
|
}
|
||||||
if vlan_id, ok := d.GetOk("vlan_id"); ok {
|
if vlan_id, ok := d.GetOk("vlan_id"); ok {
|
||||||
req.VLANID = uint64(vlan_id.(int))
|
req.VLANID = uint64(vlan_id.(int))
|
||||||
}
|
}
|
||||||
if vnfdev_id, ok := d.GetOk("vnfdev_id"); ok {
|
if vnfdev_id, ok := d.GetOk("vnfdev_id"); ok {
|
||||||
req.VNFDevID = uint64(vnfdev_id.(int))
|
req.VNFDevID = uint64(vnfdev_id.(int))
|
||||||
}
|
}
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
|
||||||
req.Size = uint64(size.(int))
|
log.Debugf("utilityExtnetListCheckPresence")
|
||||||
}
|
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
||||||
|
if err != nil {
|
||||||
log.Debugf("utilityExtnetListCheckPresence")
|
return nil, err
|
||||||
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return extnetList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return extnetList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -66,10 +66,6 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"client_ids": {
|
"client_ids": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -89,26 +85,10 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
"default_gw": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
"desc": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -141,28 +121,16 @@ func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
"net_mask": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_time": {
|
"ckey": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,11 +95,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Filter by RG ID",
|
Description: "Filter by RG ID",
|
||||||
},
|
},
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -110,29 +105,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page size",
|
Description: "Page size",
|
||||||
},
|
},
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Account id",
|
|
||||||
},
|
|
||||||
"conn_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Conn id",
|
|
||||||
},
|
|
||||||
"client_ids": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
Description: "client_ids",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Status",
|
|
||||||
},
|
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -213,13 +185,6 @@ func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,21 +36,15 @@ package flipgroup
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
||||||
d.Set("account_id", fg.AccountID)
|
d.Set("account_id", fg.AccountID)
|
||||||
d.Set("account_name", fg.AccountName)
|
|
||||||
d.Set("client_ids", fg.ClientIDs)
|
d.Set("client_ids", fg.ClientIDs)
|
||||||
d.Set("client_type", fg.ClientType)
|
d.Set("client_type", fg.ClientType)
|
||||||
d.Set("conn_id", fg.ConnID)
|
d.Set("conn_id", fg.ConnID)
|
||||||
d.Set("conn_type", fg.ConnType)
|
d.Set("conn_type", fg.ConnType)
|
||||||
d.Set("created_by", fg.CreatedBy)
|
|
||||||
d.Set("created_time", fg.CreatedTime)
|
|
||||||
d.Set("default_gw", fg.DefaultGW)
|
d.Set("default_gw", fg.DefaultGW)
|
||||||
d.Set("deleted_by", fg.DeletedBy)
|
|
||||||
d.Set("deleted_time", fg.DeletedTime)
|
|
||||||
d.Set("desc", fg.Description)
|
d.Set("desc", fg.Description)
|
||||||
d.Set("gid", fg.GID)
|
d.Set("gid", fg.GID)
|
||||||
d.Set("guid", fg.GUID)
|
d.Set("guid", fg.GUID)
|
||||||
@@ -60,20 +54,13 @@ func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.RecordFLIPGroup) {
|
|||||||
d.Set("name", fg.Name)
|
d.Set("name", fg.Name)
|
||||||
d.Set("net_id", fg.NetID)
|
d.Set("net_id", fg.NetID)
|
||||||
d.Set("net_type", fg.NetType)
|
d.Set("net_type", fg.NetType)
|
||||||
d.Set("network", fg.Network)
|
|
||||||
d.Set("rg_id", fg.RGID)
|
|
||||||
d.Set("rg_name", fg.RGName)
|
|
||||||
d.Set("status", fg.Status)
|
d.Set("status", fg.Status)
|
||||||
d.Set("updated_by", fg.UpdatedBy)
|
|
||||||
d.Set("updated_time", fg.UpdatedTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, fg := range fg_list.Data {
|
for _, fg := range fg_list.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ckey": fg.CKey,
|
|
||||||
"meta": flattens.FlattenMeta(fg.Meta),
|
|
||||||
"account_id": fg.AccountID,
|
"account_id": fg.AccountID,
|
||||||
"client_ids": fg.ClientIDs,
|
"client_ids": fg.ClientIDs,
|
||||||
"client_type": fg.ClientType,
|
"client_type": fg.ClientType,
|
||||||
@@ -89,7 +76,6 @@ func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interf
|
|||||||
"name": fg.Name,
|
"name": fg.Name,
|
||||||
"net_id": fg.NetID,
|
"net_id": fg.NetID,
|
||||||
"net_type": fg.NetType,
|
"net_type": fg.NetType,
|
||||||
"net_mask": fg.NetMask,
|
|
||||||
"status": fg.Status,
|
"status": fg.Status,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,6 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +148,6 @@ func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,10 +205,6 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"conn_id": {
|
"conn_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -221,26 +213,10 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
"default_gw": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -257,26 +233,14 @@ func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network": {
|
"net_mask": {
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rg_name": {
|
"ckey": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,48 +153,38 @@ func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceDa
|
|||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if vinsId, ok := d.GetOk("vins_id"); ok {
|
if vinsId, ok := d.GetOk("vins_id"); ok {
|
||||||
req.VINSID = uint64(vinsId.(int))
|
req.VINSID = uint64(vinsId.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if vinsName, ok := d.GetOk("vins_name"); ok {
|
if vinsName, ok := d.GetOk("vins_name"); ok {
|
||||||
req.VINSName = vinsName.(string)
|
req.VINSName = vinsName.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if extNetId, ok := d.GetOk("extnet_id"); ok {
|
if extNetId, ok := d.GetOk("extnet_id"); ok {
|
||||||
req.ExtNetID = uint64(extNetId.(int))
|
req.ExtNetID = uint64(extNetId.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if byIp, ok := d.GetOk("by_ip"); ok {
|
if byIp, ok := d.GetOk("by_ip"); ok {
|
||||||
req.ByIP = byIp.(string)
|
req.ByIP = byIp.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rgId.(int))
|
req.RGID = uint64(rgId.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if byId, ok := d.GetOk("by_id"); ok {
|
if byId, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(byId.(int))
|
req.ByID = uint64(byId.(int))
|
||||||
}
|
}
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
|
||||||
req.SortBy = sortBy.(string)
|
|
||||||
}
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
|
||||||
req.AccountId = uint64(accountId.(int))
|
|
||||||
}
|
|
||||||
if connId, ok := d.GetOk("conn_id"); ok {
|
|
||||||
req.ConnId = uint64(connId.(int))
|
|
||||||
}
|
|
||||||
if cliensId, ok := d.GetOk("client_ids"); ok {
|
|
||||||
cliensIds := cliensId.([]interface{})
|
|
||||||
for _, elem := range cliensIds {
|
|
||||||
req.ClientIDs = append(req.ClientIDs, uint64(elem.(int)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if status, ok := d.GetOk("status"); ok {
|
|
||||||
req.Status = status.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
fg_list, err := c.CloudAPI().FLIPGroup().List(ctx, req)
|
fg_list, err := c.CloudAPI().FLIPGroup().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ package image
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
@@ -44,11 +44,12 @@ import (
|
|||||||
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
image, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(int(image.ID)))
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
|
||||||
flattenImage(d, image)
|
flattenImage(d, image)
|
||||||
|
|
||||||
|
|||||||
@@ -1,165 +1,159 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
id := uuid.New()
|
||||||
id := uuid.New()
|
d.SetId(id.String())
|
||||||
d.SetId(id.String())
|
d.Set("items", flattenImageList(imageList))
|
||||||
d.Set("items", flattenImageList(imageList))
|
d.Set("entry_count", imageList.EntryCount)
|
||||||
d.Set("entry_count", imageList.EntryCount)
|
|
||||||
|
return nil
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||||
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
rets := map[string]*schema.Schema{
|
||||||
rets := map[string]*schema.Schema{
|
"sep_id": {
|
||||||
"sep_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by Storage Endpoint ID",
|
||||||
Description: "Filter by Storage Endpoint ID",
|
},
|
||||||
},
|
"by_id": {
|
||||||
"by_id": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by ID",
|
||||||
Description: "Filter by ID",
|
},
|
||||||
},
|
"name": {
|
||||||
"name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by name",
|
||||||
Description: "Filter by name",
|
},
|
||||||
},
|
"status": {
|
||||||
"status": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by status",
|
||||||
Description: "Filter by status",
|
},
|
||||||
},
|
"architecture": {
|
||||||
"architecture": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by architecture",
|
||||||
Description: "Filter by architecture",
|
},
|
||||||
},
|
"type_image": {
|
||||||
"type_image": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by image type",
|
||||||
Description: "Filter by image type",
|
},
|
||||||
},
|
"image_size": {
|
||||||
"image_size": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by image size",
|
||||||
Description: "Filter by image size",
|
},
|
||||||
},
|
"sep_name": {
|
||||||
"sep_name": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by SEP name",
|
||||||
Description: "Filter by SEP name",
|
},
|
||||||
},
|
"pool": {
|
||||||
"pool": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Filter by pool",
|
||||||
Description: "Filter by pool",
|
},
|
||||||
},
|
"public": {
|
||||||
"public": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find public/private images",
|
||||||
Description: "Find public/private images",
|
},
|
||||||
},
|
"hot_resize": {
|
||||||
"hot_resize": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find hot resizable images",
|
||||||
Description: "Find hot resizable images",
|
},
|
||||||
},
|
"bootable": {
|
||||||
"bootable": {
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeBool,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "Find bootable images",
|
||||||
Description: "Find bootable images",
|
},
|
||||||
},
|
"page": {
|
||||||
"sort_by": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "page number",
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
},
|
||||||
},
|
"size": {
|
||||||
"page": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Optional: true,
|
Description: "page size",
|
||||||
Description: "page number",
|
},
|
||||||
},
|
"items": {
|
||||||
"size": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
Optional: true,
|
Description: "image list",
|
||||||
Description: "page size",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: dataSourceImageSchemaMake(),
|
||||||
"items": {
|
},
|
||||||
Type: schema.TypeList,
|
},
|
||||||
Computed: true,
|
"entry_count": {
|
||||||
Description: "image list",
|
Type: schema.TypeInt,
|
||||||
Elem: &schema.Resource{
|
Computed: true,
|
||||||
Schema: dataSourceImageSchemaMake(),
|
},
|
||||||
},
|
}
|
||||||
},
|
|
||||||
"entry_count": {
|
return rets
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
|
||||||
},
|
func DataSourceImageList() *schema.Resource {
|
||||||
}
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
return rets
|
|
||||||
}
|
ReadContext: dataSourceImageListRead,
|
||||||
|
|
||||||
func DataSourceImageList() *schema.Resource {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return &schema.Resource{
|
Read: &constants.Timeout30s,
|
||||||
SchemaVersion: 1,
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
ReadContext: dataSourceImageListRead,
|
|
||||||
|
Schema: dataSourceImageListSchemaMake(),
|
||||||
Timeouts: &schema.ResourceTimeout{
|
}
|
||||||
Read: &constants.Timeout30s,
|
}
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceImageListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
)
|
)
|
||||||
@@ -23,17 +20,14 @@ func flattenHistory(history []image.History) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
||||||
cdPresentedTo, _ := json.Marshal(img.CdPresentedTo)
|
|
||||||
|
|
||||||
d.Set("unc_path", img.UNCPath)
|
d.Set("unc_path", img.UNCPath)
|
||||||
d.Set("ckey", img.CKey)
|
d.Set("ckey", img.CKey)
|
||||||
d.Set("account_id", img.AccountID)
|
d.Set("account_id", img.AccountID)
|
||||||
d.Set("acl", FlattenACL(img.ACL))
|
d.Set("acl", img.ACL)
|
||||||
d.Set("architecture", img.Architecture)
|
d.Set("architecture", img.Architecture)
|
||||||
d.Set("boot_type", img.BootType)
|
d.Set("boot_type", img.BootType)
|
||||||
d.Set("bootable", img.Bootable)
|
d.Set("bootable", img.Bootable)
|
||||||
d.Set("compute_ci_id", img.ComputeCIID)
|
d.Set("compute_ci_id", img.ComputeCIID)
|
||||||
d.Set("cd_presented_to", string(cdPresentedTo))
|
|
||||||
d.Set("deleted_time", img.DeletedTime)
|
d.Set("deleted_time", img.DeletedTime)
|
||||||
d.Set("desc", img.Description)
|
d.Set("desc", img.Description)
|
||||||
d.Set("drivers", img.Drivers)
|
d.Set("drivers", img.Drivers)
|
||||||
@@ -47,7 +41,6 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
|||||||
d.Set("link_to", img.LinkTo)
|
d.Set("link_to", img.LinkTo)
|
||||||
d.Set("milestones", img.Milestones)
|
d.Set("milestones", img.Milestones)
|
||||||
d.Set("image_name", img.Name)
|
d.Set("image_name", img.Name)
|
||||||
d.Set("network_interface_naming", img.NetworkInterfaceNaming)
|
|
||||||
d.Set("password", img.Password)
|
d.Set("password", img.Password)
|
||||||
d.Set("pool_name", img.Pool)
|
d.Set("pool_name", img.Pool)
|
||||||
d.Set("provider_name", img.ProviderName)
|
d.Set("provider_name", img.ProviderName)
|
||||||
@@ -69,42 +62,26 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
|
|||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, img := range il.Data {
|
for _, img := range il.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": img.AccountID,
|
"account_id": img.AccountID,
|
||||||
"architecture": img.Architecture,
|
"architecture": img.Architecture,
|
||||||
"boot_type": img.BootType,
|
"boot_type": img.BootType,
|
||||||
"bootable": img.Bootable,
|
"bootable": img.Bootable,
|
||||||
"cdrom": img.CDROM,
|
"cdrom": img.CDROM,
|
||||||
"desc": img.Description,
|
"desc": img.Description,
|
||||||
"drivers": img.Drivers,
|
"drivers": img.Drivers,
|
||||||
"hot_resize": img.HotResize,
|
"hot_resize": img.HotResize,
|
||||||
"image_id": img.ID,
|
"image_id": img.ID,
|
||||||
"link_to": img.LinkTo,
|
"link_to": img.LinkTo,
|
||||||
"image_name": img.Name,
|
"image_name": img.Name,
|
||||||
"network_interface_naming": img.NetworkInterfaceNaming,
|
"pool_name": img.Pool,
|
||||||
"pool_name": img.Pool,
|
"sep_id": img.SepID,
|
||||||
"sep_id": img.SepID,
|
"size": img.Size,
|
||||||
"size": img.Size,
|
"status": img.Status,
|
||||||
"status": img.Status,
|
"type": img.Type,
|
||||||
"type": img.Type,
|
"username": img.Username,
|
||||||
"username": img.Username,
|
"virtual": img.Virtual,
|
||||||
"virtual": img.Virtual,
|
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func FlattenACL(acl interface{}) string {
|
|
||||||
switch d := acl.(type) {
|
|
||||||
case string:
|
|
||||||
return d
|
|
||||||
case int:
|
|
||||||
return strconv.Itoa(d)
|
|
||||||
case int64:
|
|
||||||
return strconv.FormatInt(d, 10)
|
|
||||||
case float64:
|
|
||||||
return strconv.FormatInt(int64(d), 10)
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,222 +1,216 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
|
func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"image_id": {
|
"image_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"show_all": {
|
"show_all": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Default: false,
|
Default: false,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"unc_path": {
|
|
||||||
Type: schema.TypeString,
|
"unc_path": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"ckey": {
|
},
|
||||||
Type: schema.TypeString,
|
"ckey": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"account_id": {
|
},
|
||||||
Type: schema.TypeInt,
|
"account_id": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"acl": {
|
},
|
||||||
Type: schema.TypeString,
|
"acl": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"architecture": {
|
},
|
||||||
Type: schema.TypeString,
|
"architecture": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"boot_type": {
|
},
|
||||||
Type: schema.TypeString,
|
"boot_type": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"bootable": {
|
},
|
||||||
Type: schema.TypeBool,
|
"bootable": {
|
||||||
Computed: true,
|
Type: schema.TypeBool,
|
||||||
},
|
Computed: true,
|
||||||
"compute_ci_id": {
|
},
|
||||||
Type: schema.TypeInt,
|
"compute_ci_id": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"cd_presented_to": {
|
},
|
||||||
Type: schema.TypeString,
|
"deleted_time": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"deleted_time": {
|
},
|
||||||
Type: schema.TypeInt,
|
"desc": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"desc": {
|
},
|
||||||
Type: schema.TypeString,
|
"drivers": {
|
||||||
Computed: true,
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
"drivers": {
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Schema{
|
},
|
||||||
Type: schema.TypeString,
|
"enabled": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
},
|
Computed: true,
|
||||||
"enabled": {
|
},
|
||||||
Type: schema.TypeBool,
|
"gid": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"gid": {
|
},
|
||||||
Type: schema.TypeInt,
|
"guid": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"guid": {
|
},
|
||||||
Type: schema.TypeInt,
|
"history": {
|
||||||
Computed: true,
|
Type: schema.TypeList,
|
||||||
},
|
Computed: true,
|
||||||
"history": {
|
Elem: &schema.Resource{
|
||||||
Type: schema.TypeList,
|
Schema: map[string]*schema.Schema{
|
||||||
Computed: true,
|
"guid": {
|
||||||
Elem: &schema.Resource{
|
Type: schema.TypeString,
|
||||||
Schema: map[string]*schema.Schema{
|
Computed: true,
|
||||||
"guid": {
|
},
|
||||||
Type: schema.TypeString,
|
"id": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"id": {
|
},
|
||||||
Type: schema.TypeInt,
|
"timestamp": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
Computed: true,
|
||||||
"timestamp": {
|
},
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
"hot_resize": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
},
|
Computed: true,
|
||||||
"hot_resize": {
|
},
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
"last_modified": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"last_modified": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"link_to": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"link_to": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"milestones": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"milestones": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"image_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"image_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"password": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"network_interface_naming": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"pool_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"password": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"provider_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"pool_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"purge_attempts": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"provider_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"present_to": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"purge_attempts": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
Elem: &schema.Schema{
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
"present_to": {
|
},
|
||||||
Type: schema.TypeList,
|
"res_id": {
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
Elem: &schema.Schema{
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
"rescuecd": {
|
||||||
},
|
Type: schema.TypeBool,
|
||||||
"res_id": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"sep_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"rescuecd": {
|
Computed: true,
|
||||||
Type: schema.TypeBool,
|
},
|
||||||
Computed: true,
|
"shared_with": {
|
||||||
},
|
Type: schema.TypeList,
|
||||||
"sep_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
Elem: &schema.Schema{
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
"shared_with": {
|
},
|
||||||
Type: schema.TypeList,
|
"size": {
|
||||||
Computed: true,
|
Type: schema.TypeInt,
|
||||||
Elem: &schema.Schema{
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"size": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"tech_status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"type": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"tech_status": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"username": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"type": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"version": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"username": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
}
|
||||||
},
|
}
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -94,10 +94,6 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Image name",
|
Description: "Image name",
|
||||||
},
|
},
|
||||||
"network_interface_naming": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_name": {
|
"pool_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -1,160 +1,159 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema {
|
func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema {
|
||||||
delete(sch, "show_all")
|
delete(sch, "show_all")
|
||||||
sch["name"] = &schema.Schema{
|
sch["name"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Name of the rescue disk",
|
Description: "Name of the rescue disk",
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["url"] = &schema.Schema{
|
sch["url"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "URL where to download media from",
|
Description: "URL where to download media from",
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["image_id"] = &schema.Schema{
|
sch["gid"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Required: true,
|
||||||
Computed: true,
|
Description: "grid (platform) ID where this template should be create in",
|
||||||
Description: "image id",
|
}
|
||||||
}
|
|
||||||
|
sch["image_id"] = &schema.Schema{
|
||||||
sch["boot_type"] = &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Required: true,
|
Computed: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
|
Description: "image id",
|
||||||
Description: "Boot type of image bios or uefi",
|
}
|
||||||
}
|
|
||||||
|
sch["boot_type"] = &schema.Schema{
|
||||||
sch["type"] = &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Required: true,
|
||||||
Required: true,
|
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
|
||||||
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
|
Description: "Boot type of image bios or uefi",
|
||||||
Description: "Image type linux, windows or other",
|
}
|
||||||
}
|
|
||||||
|
sch["type"] = &schema.Schema{
|
||||||
sch["hot_resize"] = &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeBool,
|
Required: true,
|
||||||
Optional: true,
|
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
|
||||||
Computed: true,
|
Description: "Image type linux, windows or other",
|
||||||
Description: "Does this machine supports hot resize",
|
}
|
||||||
}
|
|
||||||
|
sch["hot_resize"] = &schema.Schema{
|
||||||
sch["username"] = &schema.Schema{
|
Type: schema.TypeBool,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Computed: true,
|
||||||
Computed: true,
|
Description: "Does this machine supports hot resize",
|
||||||
Description: "Optional username for the image",
|
}
|
||||||
}
|
|
||||||
|
sch["username"] = &schema.Schema{
|
||||||
sch["password"] = &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeString,
|
Optional: true,
|
||||||
Optional: true,
|
Computed: true,
|
||||||
Computed: true,
|
Description: "Optional username for the image",
|
||||||
Description: "Optional password for the image",
|
}
|
||||||
}
|
|
||||||
|
sch["password"] = &schema.Schema{
|
||||||
sch["account_id"] = &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeInt,
|
Optional: true,
|
||||||
Required: true,
|
Computed: true,
|
||||||
Description: "AccountId to make the image exclusive",
|
Description: "Optional password for the image",
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["username_dl"] = &schema.Schema{
|
sch["account_id"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "username for upload binary media",
|
Computed: true,
|
||||||
}
|
Description: "AccountId to make the image exclusive",
|
||||||
|
}
|
||||||
sch["password_dl"] = &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
sch["username_dl"] = &schema.Schema{
|
||||||
Optional: true,
|
Type: schema.TypeString,
|
||||||
Description: "password for upload binary media",
|
Optional: true,
|
||||||
}
|
Description: "username for upload binary media",
|
||||||
|
}
|
||||||
sch["pool_name"] = &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
sch["password_dl"] = &schema.Schema{
|
||||||
Optional: true,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Optional: true,
|
||||||
Description: "pool for image create",
|
Description: "password for upload binary media",
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["sep_id"] = &schema.Schema{
|
sch["pool_name"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "storage endpoint provider ID",
|
Description: "pool for image create",
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["architecture"] = &schema.Schema{
|
sch["sep_id"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"X86_64", "PPC64_LE"}, true),
|
Description: "storage endpoint provider ID",
|
||||||
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
}
|
||||||
}
|
|
||||||
|
sch["architecture"] = &schema.Schema{
|
||||||
sch["drivers"] = &schema.Schema{
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeList,
|
Optional: true,
|
||||||
Required: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
ValidateFunc: validation.StringInSlice([]string{"X86_64", "PPC64_LE"}, true),
|
||||||
Type: schema.TypeString,
|
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
sch["drivers"] = &schema.Schema{
|
||||||
sch["permanently"] = &schema.Schema{
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeBool,
|
Required: true,
|
||||||
Optional: true,
|
Elem: &schema.Schema{
|
||||||
Default: false,
|
Type: schema.TypeString,
|
||||||
Description: "whether to completely delete the image",
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sch["network_interface_naming"] = &schema.Schema{
|
sch["permanently"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Default: false,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true),
|
Description: "whether to completely delete the image",
|
||||||
Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming",
|
}
|
||||||
}
|
|
||||||
|
return sch
|
||||||
return sch
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package image
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
@@ -37,46 +34,3 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
|
|||||||
|
|
||||||
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func existComputeID(ctx context.Context, computeId uint64, m interface{}) error {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := compute.GetRequest{ComputeID: computeId}
|
|
||||||
|
|
||||||
// check for compute existence
|
|
||||||
computeRecord, err := c.CloudAPI().Compute().Get(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("ComputeID %d is not allowed or does not exist", computeId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if compute was created as blank
|
|
||||||
computeImageId := computeRecord.ImageID
|
|
||||||
bootImageId := -1
|
|
||||||
for _, d := range computeRecord.Disks {
|
|
||||||
if d.Type == "B" {
|
|
||||||
bootImageId = int(d.ImageID)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if computeImageId != 0 && bootImageId != 0 {
|
|
||||||
return fmt.Errorf("ComputeID %d is not allowed because it is not blank compute (either compute imageId or boot imageId are not zero)", computeId)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func existDiskID(ctx context.Context, diskId uint64, m interface{}) error {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := disks.ListRequest{ByID: diskId}
|
|
||||||
|
|
||||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(diskList.Data) != 1 {
|
|
||||||
return fmt.Errorf("diskId %d is not allowed or doesn't exist", diskId)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,263 +1,274 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
||||||
|
|
||||||
haveAccountID, err := existAccountID(ctx, d, m)
|
haveGID, err := existGID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveAccountID {
|
if !haveGID {
|
||||||
return diag.Errorf("resourceImageCreate: can't create Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
return diag.Errorf("resourceImageCreate: can't create Image because GID %d is not allowed or does not exist", d.Get("gid").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
if _, ok := d.GetOk("account_id"); ok {
|
||||||
req := image.CreateRequest{
|
haveAccountID, err := existAccountID(ctx, d, m)
|
||||||
AccountID: uint64(d.Get("account_id").(int)),
|
if err != nil {
|
||||||
Name: d.Get("name").(string),
|
return diag.FromErr(err)
|
||||||
URL: d.Get("url").(string),
|
}
|
||||||
BootType: d.Get("boot_type").(string),
|
|
||||||
ImageType: d.Get("type").(string),
|
if !haveAccountID {
|
||||||
}
|
return diag.Errorf("resourceImageCreate: can't create Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
||||||
|
}
|
||||||
drivers := []string{}
|
}
|
||||||
for _, driver := range d.Get("drivers").([]interface{}) {
|
|
||||||
drivers = append(drivers, driver.(string))
|
c := m.(*controller.ControllerCfg)
|
||||||
}
|
req := image.CreateRequest{}
|
||||||
|
|
||||||
req.Drivers = drivers
|
req.Name = d.Get("name").(string)
|
||||||
|
req.URL = d.Get("url").(string)
|
||||||
if hotresize, ok := d.GetOk("hot_resize"); ok {
|
req.GID = uint64(d.Get("gid").(int))
|
||||||
req.HotResize = hotresize.(bool)
|
req.BootType = d.Get("boot_type").(string)
|
||||||
}
|
req.ImageType = d.Get("type").(string)
|
||||||
if username, ok := d.GetOk("username"); ok {
|
|
||||||
req.Username = username.(string)
|
drivers := []string{}
|
||||||
}
|
for _, driver := range d.Get("drivers").([]interface{}) {
|
||||||
if password, ok := d.GetOk("password"); ok {
|
drivers = append(drivers, driver.(string))
|
||||||
req.Password = password.(string)
|
}
|
||||||
}
|
|
||||||
if usernameDL, ok := d.GetOk("username_dl"); ok {
|
req.Drivers = drivers
|
||||||
req.UsernameDL = usernameDL.(string)
|
|
||||||
}
|
if hotresize, ok := d.GetOk("hot_resize"); ok {
|
||||||
if passwordDL, ok := d.GetOk("password_dl"); ok {
|
req.HotResize = hotresize.(bool)
|
||||||
req.PasswordDL = passwordDL.(string)
|
}
|
||||||
}
|
if username, ok := d.GetOk("username"); ok {
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
req.Username = username.(string)
|
||||||
req.SEPID = uint64(sepId.(int))
|
}
|
||||||
}
|
if password, ok := d.GetOk("password"); ok {
|
||||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
req.Password = password.(string)
|
||||||
req.Pool = poolName.(string)
|
}
|
||||||
}
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
req.AccountID = uint64(accountId.(int))
|
||||||
req.Architecture = architecture.(string)
|
}
|
||||||
}
|
if usernameDL, ok := d.GetOk("username_dl"); ok {
|
||||||
if networkInterfaceNaming, ok := d.GetOk("network_interface_naming"); ok {
|
req.UsernameDL = usernameDL.(string)
|
||||||
req.NetworkInterfaceNaming = networkInterfaceNaming.(string)
|
}
|
||||||
}
|
if passwordDL, ok := d.GetOk("password_dl"); ok {
|
||||||
|
req.PasswordDL = passwordDL.(string)
|
||||||
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
}
|
||||||
if err != nil {
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
d.SetId("")
|
req.SEPID = uint64(sepId.(int))
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
if poolName, ok := d.GetOk("pool_name"); ok {
|
||||||
|
req.Pool = poolName.(string)
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
}
|
||||||
d.Set("image_id", imageId)
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
|
req.Architecture = architecture.(string)
|
||||||
_, err = utilityImageCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
imageId, err := c.CloudAPI().Image().Create(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
return resourceImageRead(ctx, d, m)
|
}
|
||||||
}
|
|
||||||
|
d.SetId(strconv.FormatUint(imageId, 10))
|
||||||
func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
d.Set("image_id", imageId)
|
||||||
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
_, err = utilityImageCheckPresence(ctx, d, m)
|
||||||
img, err := utilityImageCheckPresence(ctx, d, m)
|
if err != nil {
|
||||||
if img == nil {
|
return diag.FromErr(err)
|
||||||
d.SetId("")
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
return resourceImageRead(ctx, d, m)
|
||||||
|
}
|
||||||
switch img.Status {
|
|
||||||
case status.Modeled:
|
func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
||||||
case status.Creating:
|
|
||||||
case status.Created:
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
case status.Destroyed, status.Purged:
|
if img == nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
return diag.FromErr(err)
|
||||||
// return resourceImageCreate(ctx, d, m)
|
}
|
||||||
}
|
|
||||||
|
switch img.Status {
|
||||||
flattenImage(d, img)
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
return nil
|
case status.Creating:
|
||||||
}
|
case status.Created:
|
||||||
|
case status.Destroyed, status.Purged:
|
||||||
func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
d.SetId("")
|
||||||
log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
|
// return resourceImageCreate(ctx, d, m)
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
flattenImage(d, img)
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.DeleteRequest{
|
func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
}
|
|
||||||
|
_, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
if err != nil {
|
||||||
req.Permanently = permanently.(bool)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().Image().Delete(ctx, req)
|
c := m.(*controller.ControllerCfg)
|
||||||
if err != nil {
|
req := image.DeleteRequest{
|
||||||
return diag.FromErr(err)
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
|
req.Permanently = permanently.(bool)
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
_, err = c.CloudAPI().Image().Delete(ctx, req)
|
||||||
func resourceImageRename(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
if err != nil {
|
||||||
log.Debugf("resourceImageEditName: called for %s, id: %s", d.Get("name").(string), d.Id())
|
return diag.FromErr(err)
|
||||||
c := m.(*controller.ControllerCfg)
|
}
|
||||||
req := image.RenameRequest{
|
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
d.SetId("")
|
||||||
Name: d.Get("name").(string),
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
_, err := c.CloudAPI().Image().Rename(ctx, req)
|
|
||||||
if err != nil {
|
func resourceImageRename(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
return err
|
log.Debugf("resourceImageEditName: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
}
|
c := m.(*controller.ControllerCfg)
|
||||||
|
req := image.RenameRequest{
|
||||||
return nil
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
}
|
Name: d.Get("name").(string),
|
||||||
|
}
|
||||||
func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
|
_, err := c.CloudAPI().Image().Rename(ctx, req)
|
||||||
|
if err != nil {
|
||||||
haveGID, err := existGID(ctx, d, m)
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
if !haveGID {
|
|
||||||
return diag.Errorf("resourceImageUpdate: can't update Image because GID %d is not allowed or does not exist", d.Get("gid").(int))
|
func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
}
|
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
|
|
||||||
haveAccountID, err := existAccountID(ctx, d, m)
|
haveGID, err := existGID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveAccountID {
|
if !haveGID {
|
||||||
return diag.Errorf("resourceImageUpdate: can't update Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
return diag.Errorf("resourceImageUpdate: can't update Image because GID %d is not allowed or does not exist", d.Get("gid").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
if _, ok := d.GetOk("account_id"); ok {
|
||||||
if image == nil {
|
haveAccountID, err := existAccountID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
if !haveAccountID {
|
||||||
|
return diag.Errorf("resourceImageUpdate: can't update Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
||||||
switch image.Status {
|
}
|
||||||
case status.Modeled:
|
}
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status)
|
|
||||||
case status.Creating:
|
image, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
case status.Created:
|
if image == nil {
|
||||||
case status.Destroyed, status.Purged:
|
if err != nil {
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
}
|
||||||
// return resourceImageCreate(ctx, d, m)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("name") {
|
switch image.Status {
|
||||||
err := resourceImageRename(ctx, d, m)
|
case status.Modeled:
|
||||||
if err != nil {
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status)
|
||||||
return diag.FromErr(err)
|
case status.Creating:
|
||||||
}
|
case status.Created:
|
||||||
}
|
case status.Destroyed, status.Purged:
|
||||||
|
d.SetId("")
|
||||||
return resourceImageRead(ctx, d, m)
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
}
|
// return resourceImageCreate(ctx, d, m)
|
||||||
|
}
|
||||||
func ResourceImage() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
if d.HasChange("name") {
|
||||||
SchemaVersion: 1,
|
err := resourceImageRename(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
CreateContext: resourceImageCreate,
|
return diag.FromErr(err)
|
||||||
ReadContext: resourceImageRead,
|
}
|
||||||
UpdateContext: resourceImageUpdate,
|
}
|
||||||
DeleteContext: resourceImageDelete,
|
|
||||||
|
return resourceImageRead(ctx, d, m)
|
||||||
Importer: &schema.ResourceImporter{
|
}
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
func ResourceImage() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
SchemaVersion: 1,
|
||||||
Create: &constants.Timeout600s,
|
|
||||||
Read: &constants.Timeout300s,
|
CreateContext: resourceImageCreate,
|
||||||
Update: &constants.Timeout300s,
|
ReadContext: resourceImageRead,
|
||||||
Delete: &constants.Timeout300s,
|
UpdateContext: resourceImageUpdate,
|
||||||
Default: &constants.Timeout300s,
|
DeleteContext: resourceImageDelete,
|
||||||
},
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
}
|
},
|
||||||
}
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Create: &constants.Timeout600s,
|
||||||
|
Read: &constants.Timeout300s,
|
||||||
|
Update: &constants.Timeout300s,
|
||||||
|
Delete: &constants.Timeout300s,
|
||||||
|
Default: &constants.Timeout300s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,508 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|
||||||
Authors:
|
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
*/
|
|
||||||
|
|
||||||
package image
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
computeId := uint64(d.Get("compute_id").(int))
|
|
||||||
name := d.Get("name").(string)
|
|
||||||
|
|
||||||
log.Debugf("resourceImageFromBlankComputeCreate: called for image %s", name)
|
|
||||||
|
|
||||||
err := existComputeID(ctx, computeId, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.Errorf("resourceImageFromBlankComputeCreate: can't create Image: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := d.GetOk("account_id"); ok {
|
|
||||||
haveAccountID, err := existAccountID(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !haveAccountID {
|
|
||||||
return diag.Errorf("resourceImageFromBlankComputeCreate: can't create Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := compute.CreateTemplateFromBlankRequest{
|
|
||||||
ComputeID: computeId,
|
|
||||||
Name: name,
|
|
||||||
BootType: d.Get("boot_type").(string),
|
|
||||||
ImageType: d.Get("type").(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
if username, ok := d.GetOk("username"); ok {
|
|
||||||
req.Username = username.(string)
|
|
||||||
}
|
|
||||||
if password, ok := d.GetOk("password"); ok {
|
|
||||||
req.Password = password.(string)
|
|
||||||
}
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
|
||||||
req.AccountID = uint64(accountId.(int))
|
|
||||||
}
|
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
|
||||||
req.SepID = uint64(sepId.(int))
|
|
||||||
}
|
|
||||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
|
||||||
req.PoolName = poolName.(string)
|
|
||||||
}
|
|
||||||
if hotresize, ok := d.GetOk("hot_resize"); ok {
|
|
||||||
req.HotResize = hotresize.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
var imageId uint64
|
|
||||||
asyncMode := d.Get("async_mode").(bool)
|
|
||||||
if !asyncMode {
|
|
||||||
imageId, err = c.CloudAPI().Compute().CreateTemplateFromBlank(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
taskId, err := c.CloudAPI().Compute().CreateTemplateFromBlankAsync(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
taskReq := tasks.GetRequest{
|
|
||||||
AuditID: strings.Trim(taskId, `"`),
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
task, err := c.CloudAPI().Tasks().Get(ctx, taskReq)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceImageFromBlankComputeCreate: instance creating - %s", task.Stage)
|
|
||||||
|
|
||||||
if task.Completed {
|
|
||||||
if task.Error != "" {
|
|
||||||
return diag.FromErr(fmt.Errorf("cannot create image instance: %v", task.Error))
|
|
||||||
}
|
|
||||||
|
|
||||||
id, err := task.Result.ID()
|
|
||||||
imageId = uint64(id)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Second * 20)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
|
||||||
d.Set("image_id", imageId)
|
|
||||||
|
|
||||||
_, err = utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceImageFromBlankComputeRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromBlankComputeRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
img, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if img == nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch img.Status {
|
|
||||||
case status.Modeled:
|
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
|
||||||
case status.Creating:
|
|
||||||
case status.Created:
|
|
||||||
case status.Destroyed, status.Purged:
|
|
||||||
d.SetId("")
|
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
|
||||||
// return resourceImageCreate(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
flattenImage(d, img)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromBlankComputeDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.DeleteRequest{
|
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
|
||||||
req.Permanently = permanently.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = c.CloudAPI().Image().Delete(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeRename(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
|
||||||
log.Debugf("resourceImageFromBlankComputeRename: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.RenameRequest{
|
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
|
||||||
Name: d.Get("name").(string),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.CloudAPI().Image().Rename(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromBlankComputeUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
// we do not allow change of compute_id, but allow resource update after import
|
|
||||||
old, _ := d.GetChange("compute_id")
|
|
||||||
if old.(int) != 0 && d.HasChange("compute_id") {
|
|
||||||
return diag.Errorf("resourceImageFromBlankComputeUpdate: can't update Image because compute_id is not allowed to be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch image.Status {
|
|
||||||
case status.Modeled:
|
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status)
|
|
||||||
case status.Creating:
|
|
||||||
case status.Created:
|
|
||||||
case status.Destroyed, status.Purged:
|
|
||||||
d.SetId("")
|
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
|
||||||
// return resourceImageCreate(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("name") {
|
|
||||||
err := resourceImageFromBlankComputeRename(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceImageFromBlankComputeRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceImageFromBlankCompute() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceImageFromBlankComputeCreate,
|
|
||||||
ReadContext: resourceImageFromBlankComputeRead,
|
|
||||||
UpdateContext: resourceImageFromBlankComputeUpdate,
|
|
||||||
DeleteContext: resourceImageFromBlankComputeDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout30m,
|
|
||||||
Read: &constants.Timeout900s,
|
|
||||||
Update: &constants.Timeout900s,
|
|
||||||
Delete: &constants.Timeout900s,
|
|
||||||
Default: &constants.Timeout900s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceImageFromBlankComputeSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Compute Id",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the rescue disk",
|
|
||||||
},
|
|
||||||
"boot_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
|
|
||||||
Description: "Boot type of image BIOS or UEFI",
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
|
|
||||||
Description: "Image type linux, windows or other",
|
|
||||||
},
|
|
||||||
|
|
||||||
"username": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional username for the image",
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional password for the image",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "AccountId to make the image exclusive",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "storage endpoint provider ID",
|
|
||||||
},
|
|
||||||
"pool_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "pool for image create",
|
|
||||||
},
|
|
||||||
"hot_resize": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Does this machine supports hot resize",
|
|
||||||
},
|
|
||||||
"async_mode": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "create an image in async/sync mode",
|
|
||||||
},
|
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "whether to completely delete the image",
|
|
||||||
},
|
|
||||||
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"unc_path": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"architecture": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"bootable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_ci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cd_presented_to": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"drivers": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"history": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"last_modified": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"link_to": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"image_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"network_interface_naming": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"provider_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"present_to": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rescuecd": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shared_with": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,506 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|
||||||
Authors:
|
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
|
||||||
*/
|
|
||||||
|
|
||||||
package image
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
diskId := uint64(d.Get("disk_id").(int))
|
|
||||||
name := d.Get("name").(string)
|
|
||||||
|
|
||||||
log.Debugf("resourceImageFromPlatformDiskCreate: called for image %s", name)
|
|
||||||
|
|
||||||
err := existDiskID(ctx, diskId, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.Errorf("resourceImageFromPlatformDiskCreate: can't create Image: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := d.GetOk("account_id"); ok {
|
|
||||||
haveAccountID, err := existAccountID(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !haveAccountID {
|
|
||||||
return diag.Errorf("resourceImageFromPlatformDiskCreate: can't create Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := disks.FromPlatformDiskRequest{
|
|
||||||
DiskID: diskId,
|
|
||||||
Name: name,
|
|
||||||
BootType: d.Get("boot_type").(string),
|
|
||||||
ImageType: d.Get("type").(string),
|
|
||||||
Architecture: d.Get("architecture").(string),
|
|
||||||
Bootable: d.Get("bootable").(bool), // default value - true
|
|
||||||
}
|
|
||||||
|
|
||||||
if username, ok := d.GetOk("username"); ok {
|
|
||||||
req.Username = username.(string)
|
|
||||||
}
|
|
||||||
if password, ok := d.GetOk("password"); ok {
|
|
||||||
req.Password = password.(string)
|
|
||||||
}
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
|
||||||
req.AccountID = uint64(accountId.(int))
|
|
||||||
}
|
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
|
||||||
req.SepID = uint64(sepId.(int))
|
|
||||||
}
|
|
||||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
|
||||||
req.PoolName = poolName.(string)
|
|
||||||
}
|
|
||||||
if driversInterface, ok := d.GetOk("drivers"); ok {
|
|
||||||
for _, d := range driversInterface.([]interface{}) {
|
|
||||||
req.Drivers = append(req.Drivers, d.(string))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if hotresize, ok := d.GetOk("hot_resize"); ok {
|
|
||||||
req.HotResize = hotresize.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
var imageId uint64
|
|
||||||
asyncMode := d.Get("async_mode").(bool)
|
|
||||||
if !asyncMode {
|
|
||||||
imageId, err = c.CloudAPI().Disks().FromPlatformDisk(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
taskId, err := c.CloudAPI().Disks().FromPlatformDiskAsync(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
taskReq := tasks.GetRequest{
|
|
||||||
AuditID: strings.Trim(taskId, `"`),
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
task, err := c.CloudAPI().Tasks().Get(ctx, taskReq)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceImageFromPlatformDiskCreate: instance creating - %s", task.Stage)
|
|
||||||
|
|
||||||
if task.Completed {
|
|
||||||
if task.Error != "" {
|
|
||||||
return diag.FromErr(fmt.Errorf("cannot create image instance: %v", task.Error))
|
|
||||||
}
|
|
||||||
|
|
||||||
id, err := task.Result.ID()
|
|
||||||
imageId = uint64(id)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Second * 20)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
|
||||||
d.Set("image_id", imageId)
|
|
||||||
|
|
||||||
_, err = utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceImageFromPlatformDiskRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromPlatformDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromPlatformDiskRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
img, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if img == nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch img.Status {
|
|
||||||
case status.Modeled:
|
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
|
||||||
case status.Creating:
|
|
||||||
case status.Created:
|
|
||||||
case status.Destroyed, status.Purged:
|
|
||||||
d.SetId("")
|
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
|
||||||
}
|
|
||||||
|
|
||||||
flattenImage(d, img)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromPlatformDiskDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromPlatformDiskDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.DeleteRequest{
|
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
|
||||||
req.Permanently = permanently.(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = c.CloudAPI().Image().Delete(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId("")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageFromPlatformDiskUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
|
||||||
// we do not allow change of disk_id, but allow resource update after import
|
|
||||||
old, _ := d.GetChange("disk_id")
|
|
||||||
if old.(int) != 0 && d.HasChange("disk_id") {
|
|
||||||
return diag.Errorf("resourceImageFromPlatformDiskUpdate: can't update Image because disk_id is not allowed to be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch image.Status {
|
|
||||||
case status.Modeled:
|
|
||||||
return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status)
|
|
||||||
case status.Creating:
|
|
||||||
case status.Created:
|
|
||||||
case status.Destroyed, status.Purged:
|
|
||||||
d.SetId("")
|
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("name") {
|
|
||||||
err := resourceImageRename(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceImageFromPlatformDiskRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceImageFromPlatformDisk() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceImageFromPlatformDiskCreate,
|
|
||||||
ReadContext: resourceImageFromPlatformDiskRead,
|
|
||||||
UpdateContext: resourceImageFromPlatformDiskUpdate,
|
|
||||||
DeleteContext: resourceImageFromPlatformDiskDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout30m,
|
|
||||||
Read: &constants.Timeout900s,
|
|
||||||
Update: &constants.Timeout900s,
|
|
||||||
Delete: &constants.Timeout900s,
|
|
||||||
Default: &constants.Timeout900s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceImageFromPlatformDiskSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Disk Id",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the rescue disk",
|
|
||||||
},
|
|
||||||
"boot_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
|
|
||||||
Description: "Boot type of image BIOS or UEFI",
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
|
|
||||||
Description: "Image type linux, windows or other",
|
|
||||||
},
|
|
||||||
"architecture": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"X86_64", "PPC64_LE"}, true),
|
|
||||||
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
|
||||||
},
|
|
||||||
|
|
||||||
"username": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional username for the image",
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional password for the image",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "AccountId to make the image exclusive",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "storage endpoint provider ID",
|
|
||||||
},
|
|
||||||
"pool_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "pool for image create",
|
|
||||||
},
|
|
||||||
"drivers": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
StateFunc: statefuncs.StateFuncToUpper,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]",
|
|
||||||
},
|
|
||||||
"bootable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "bootable image",
|
|
||||||
},
|
|
||||||
"hot_resize": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Does this machine supports hot resize",
|
|
||||||
},
|
|
||||||
"async_mode": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "create an image in async/sync mode",
|
|
||||||
},
|
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "whether to completely delete the image",
|
|
||||||
},
|
|
||||||
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"unc_path": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_ci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cd_presented_to": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"history": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"last_modified": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"link_to": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"image_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"network_interface_naming": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"provider_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"present_to": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rescuecd": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shared_with": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +1,111 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListRequest{}
|
req := image.ListRequest{}
|
||||||
|
|
||||||
if sep_id, ok := d.GetOk("sep_id"); ok {
|
if sep_id, ok := d.GetOk("sep_id"); ok {
|
||||||
req.SEPID = uint64(sep_id.(int))
|
req.SEPID = uint64(sep_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if by_id, ok := d.GetOk("by_id"); ok {
|
if by_id, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(by_id.(int))
|
req.ByID = uint64(by_id.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
req.Architecture = architecture.(string)
|
req.Architecture = architecture.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if type_image, ok := d.GetOk("type_image"); ok {
|
if type_image, ok := d.GetOk("type_image"); ok {
|
||||||
req.TypeImage = type_image.(string)
|
req.TypeImage = type_image.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if image_size, ok := d.GetOk("image_size"); ok {
|
if image_size, ok := d.GetOk("image_size"); ok {
|
||||||
req.ImageSize = uint64(image_size.(int))
|
req.ImageSize = uint64(image_size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
if sep_name, ok := d.GetOk("sep_name"); ok {
|
if sep_name, ok := d.GetOk("sep_name"); ok {
|
||||||
req.SEPName = sep_name.(string)
|
req.SEPName = sep_name.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pool, ok := d.GetOk("pool"); ok {
|
if pool, ok := d.GetOk("pool"); ok {
|
||||||
req.Pool = pool.(string)
|
req.Pool = pool.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if public, ok := d.GetOk("public"); ok {
|
if public, ok := d.GetOk("public"); ok {
|
||||||
req.Public = public.(bool)
|
req.Public = public.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if hot_resize, ok := d.GetOk("hot_resize"); ok {
|
if hot_resize, ok := d.GetOk("hot_resize"); ok {
|
||||||
req.HotResize = hot_resize.(bool)
|
req.HotResize = hot_resize.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if bootable, ok := d.GetOk("bootable"); ok {
|
if bootable, ok := d.GetOk("bootable"); ok {
|
||||||
req.Bootable = bootable.(bool)
|
req.Bootable = bootable.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.SortBy = sortBy.(string)
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
if page, ok := d.GetOk("page"); ok {
|
req.Size = uint64(size.(int))
|
||||||
req.Page = uint64(page.(int))
|
}
|
||||||
}
|
|
||||||
if size, ok := d.GetOk("size"); ok {
|
log.Debugf("utilityImageListCheckPresence: load image list")
|
||||||
req.Size = uint64(size.(int))
|
imageList, err := c.CloudAPI().Image().List(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
log.Debugf("utilityImageListCheckPresence: load image list")
|
}
|
||||||
imageList, err := c.CloudAPI().Image().List(ctx, req)
|
|
||||||
if err != nil {
|
return imageList, nil
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return imageList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -94,11 +94,6 @@ func dataSourceK8CIListSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "Include deleted k8cis in result",
|
Description: "Include deleted k8cis in result",
|
||||||
},
|
},
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import (
|
|||||||
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
cluster, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
d.SetId(strconv.FormatUint(cluster.ID, 10))
|
||||||
@@ -400,10 +399,6 @@ func dataSourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -179,11 +179,6 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"sort_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "sort by one of supported fields, format +|-(field)",
|
|
||||||
},
|
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -276,10 +271,6 @@ func createK8sListSchema() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func dataSourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
wg, workersComputeList, err := utilityDataK8sWgCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m
|
|||||||
|
|
||||||
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import (
|
|||||||
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(aclList))
|
res := make([]map[string]interface{}, 0, len (aclList))
|
||||||
for _, acl := range aclList {
|
for _, acl := range aclList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"explicit": acl.Explicit,
|
"explicit": acl.Explicit,
|
||||||
@@ -134,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
res := make([]map[string]interface{}, 0, len (interfaces))
|
||||||
for _, interfaceCompute := range interfaces {
|
for _, interfaceCompute := range interfaces {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"def_gw": interfaceCompute.DefGW,
|
"def_gw": interfaceCompute.DefGW,
|
||||||
@@ -147,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(detailedInfoList))
|
res := make([]map[string]interface{}, 0, len (detailedInfoList))
|
||||||
if computes != nil {
|
if computes != nil {
|
||||||
for i, detailedInfo := range detailedInfoList {
|
for i, detailedInfo := range detailedInfoList {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -247,7 +247,6 @@ func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []com
|
|||||||
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
d.Set("workers", flattenK8sGroup(cluster.K8SGroups.Workers, workers))
|
||||||
d.Set("lb_id", cluster.LBID)
|
d.Set("lb_id", cluster.LBID)
|
||||||
d.Set("name", cluster.Name)
|
d.Set("name", cluster.Name)
|
||||||
d.Set("network_plugin", cluster.NetworkPlugin)
|
|
||||||
d.Set("rg_id", cluster.RGID)
|
d.Set("rg_id", cluster.RGID)
|
||||||
d.Set("rg_name", cluster.RGName)
|
d.Set("rg_name", cluster.RGName)
|
||||||
d.Set("status", cluster.Status)
|
d.Set("status", cluster.Status)
|
||||||
@@ -268,7 +267,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(workersGroups))
|
res := make([]map[string]interface{}, 0, len (workersGroups))
|
||||||
for _, worker := range workersGroups {
|
for _, worker := range workersGroups {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"annotations": worker.Annotations,
|
"annotations": worker.Annotations,
|
||||||
@@ -289,11 +288,11 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(k8sItems.Data))
|
res := make([]map[string]interface{}, 0, len (k8sItems.Data))
|
||||||
for _, item := range k8sItems.Data {
|
for _, item := range k8sItems.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"account_id": item.AccountID,
|
"account_id": item.AccountID,
|
||||||
"account_name": item.AccountName,
|
"account_name": item.Name,
|
||||||
"acl": item.ACL,
|
"acl": item.ACL,
|
||||||
"bservice_id": item.BServiceID,
|
"bservice_id": item.BServiceID,
|
||||||
"ci_id": item.CIID,
|
"ci_id": item.CIID,
|
||||||
@@ -309,7 +308,6 @@ func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
|||||||
"lb_id": item.LBID,
|
"lb_id": item.LBID,
|
||||||
"milestones": item.Milestones,
|
"milestones": item.Milestones,
|
||||||
"k8s_name": item.Name,
|
"k8s_name": item.Name,
|
||||||
"network_plugin": item.NetworkPlugin,
|
|
||||||
"rg_id": item.RGID,
|
"rg_id": item.RGID,
|
||||||
"rg_name": item.RGName,
|
"rg_name": item.RGName,
|
||||||
"service_account": flattenServiceAccount(item.ServiceAccount),
|
"service_account": flattenServiceAccount(item.ServiceAccount),
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ package k8s
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func nodeMasterDefault() K8sNodeRecord {
|
func nodeMasterDefault() K8sNodeRecord {
|
||||||
@@ -75,8 +73,8 @@ func mastersSchemaMake() map[string]*schema.Schema {
|
|||||||
masters["num"] = &schema.Schema{
|
masters["num"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ValidateFunc: validation.IntInSlice([]int{1, 3, 5}),
|
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
||||||
Description: "Number of nodes to create. Can be either 1, 3 or 5",
|
Description: "Number of nodes to create. Can be either 1 or 3",
|
||||||
}
|
}
|
||||||
masters["sep_id"] = &schema.Schema{
|
masters["sep_id"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -87,25 +85,21 @@ func mastersSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
masters["cpu"] = &schema.Schema{
|
masters["cpu"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Node CPU count.",
|
Description: "Node CPU count.",
|
||||||
}
|
}
|
||||||
masters["ram"] = &schema.Schema{
|
masters["ram"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
ValidateFunc: validation.All(
|
|
||||||
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
|
|
||||||
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
|
|
||||||
),
|
|
||||||
Description: "Node RAM in MB.",
|
Description: "Node RAM in MB.",
|
||||||
}
|
}
|
||||||
masters["disk"] = &schema.Schema{
|
masters["disk"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
//ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Node boot disk size in GB.",
|
Description: "Node boot disk size in GB.",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,11 +117,7 @@ func workersSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"ram": {
|
"ram": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
ValidateFunc: validation.All(
|
|
||||||
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
|
|
||||||
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
|
|
||||||
),
|
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"cpu": {
|
"cpu": {
|
||||||
|
|||||||
@@ -1,396 +0,0 @@
|
|||||||
package k8s
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceK8sCPSchemaV1() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the cluster.",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "Resource group ID that this instance belongs to.",
|
|
||||||
},
|
|
||||||
"k8sci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "ID of the k8s catalog item to base this instance on.",
|
|
||||||
},
|
|
||||||
"network_plugin": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Network plugin to be used",
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true),
|
|
||||||
},
|
|
||||||
"num": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
ValidateFunc: validation.IntInSlice([]int{1, 3}),
|
|
||||||
Description: "Number of VMs to create. Can be either 1 or 3",
|
|
||||||
},
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node CPU count.",
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node RAM in MB.",
|
|
||||||
},
|
|
||||||
"disk": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Node boot disk size in GB.",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Storage Endpoint ID",
|
|
||||||
},
|
|
||||||
"sep_pool": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Storage Endpoint Pool",
|
|
||||||
},
|
|
||||||
"with_lb": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "Create k8s with load balancer if true.",
|
|
||||||
},
|
|
||||||
"extnet_only": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Use only selected ExtNet for infrastructure connections",
|
|
||||||
},
|
|
||||||
// /4.4.0
|
|
||||||
"cloud_init": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
|
|
||||||
},
|
|
||||||
"join_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings for joining a node to a cluster. It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"kube_proxy_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster. It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"kubelet_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster. It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"cluster_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to define global settings and configurations for the entire cluster. It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"init_config": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "is used to define settings and actions that should be performed before any other component in the cluster starts. It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting.",
|
|
||||||
},
|
|
||||||
"additional_sans": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names",
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"ha_mode": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Use Highly Available schema for LB deploy",
|
|
||||||
},
|
|
||||||
"lb_sysctl_params": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
|
|
||||||
},
|
|
||||||
"oidc_cert": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "insert ssl certificate in x509 pem format",
|
|
||||||
},
|
|
||||||
////
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
//ForceNew: true,
|
|
||||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Text description of this instance.",
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: true,
|
|
||||||
Description: "Start k8s cluster.",
|
|
||||||
},
|
|
||||||
"detailed_info": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"interfaces": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"def_gw": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ip_address": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"natable_vins_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"natable_vins_network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"master_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Master group ID.",
|
|
||||||
},
|
|
||||||
"master_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Master group name.",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"k8s_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"rg_acl": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"explicit": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_group_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"bservice_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"k8s_ci_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"lb_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"k8s_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"lb_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "IP address of default load balancer.",
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"kubeconfig": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Kubeconfig for cluster access.",
|
|
||||||
},
|
|
||||||
"vins_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of default vins for this instace.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user