Compare commits

...

33 Commits
4.0.2 ... 4.6.0

Author SHA1 Message Date
6876b25f0e 4.6.0 2024-05-31 15:42:50 +03:00
db1760cb72 4.6.0 2024-05-31 14:05:21 +03:00
84b7a80e1b wiki 2024-04-09 10:56:12 +03:00
8857ed17be wiki 2024-04-09 09:23:33 +03:00
91ba361af9 4.5.3 2024-03-26 12:17:33 +03:00
f49d9f8860 4.5.2 2023-12-19 16:37:50 +03:00
20050bc169 4.5.1 2023-12-18 18:55:52 +03:00
e2ee45ee14 4.5.1 2023-12-18 18:36:55 +03:00
Nikita Sorokin
294680282e 4.5.0 2023-11-13 00:59:02 +03:00
Nikita Sorokin
2bc0fbae9a 4.5.0-alpha 2023-11-07 18:26:09 +03:00
Nikita Sorokin
2453a32d01 4.4.2 2023-10-18 08:30:37 +03:00
Nikita Sorokin
0602a4b693 4.4.1 2023-10-13 13:28:19 +03:00
Nikita Sorokin
28b60de115 4.4.0-static-route-updated 2023-10-09 13:15:11 +03:00
Nikita Sorokin
b705ce4aab 4.4.0 2023-09-28 19:41:26 +03:00
Nikita Sorokin
83ca627cea 4.4.0 2023-09-28 16:08:15 +03:00
Nikita Sorokin
739289fbb8 4.3.8 2023-09-27 16:17:35 +03:00
Nikita Sorokin
c89574c3e6 4.3.7 2023-09-22 12:49:22 +03:00
Nikita Sorokin
a1e61674c8 4.3.6 2023-09-04 11:15:01 +03:00
Nikita Sorokin
cb9ff26bb0 4.3.5 2023-08-29 16:26:37 +03:00
Nikita Sorokin
6932f9d305 4.3.5 2023-08-28 13:02:41 +03:00
Nikita Sorokin
712f8edf9e 4.3.4 2023-08-23 16:32:48 +03:00
Nikita Sorokin
805ffe1f29 4.3.3 2023-08-22 13:15:17 +03:00
Nikita Sorokin
bf8d3fb437 4.3.2 2023-08-17 18:18:23 +03:00
d7a7eb9cb3 4.3.1 README update 2023-08-16 16:00:00 +03:00
Nikita Sorokin
b60f32c570 v4.3.1 2023-08-10 20:22:43 +03:00
272e385318 4.3.0 2023-07-26 13:32:39 +03:00
f731cf246f 4.2.4 2023-07-07 11:54:41 +03:00
6365f63fc1 4.2.3 2023-06-29 16:02:38 +03:00
85ce76564f 4.2.2 2023-06-23 15:30:46 +03:00
928481d26f 4.2.1 2023-06-19 16:05:27 +03:00
0e64974821 4.2.0 2023-06-08 12:26:21 +03:00
371bb0d90f 4.1.1 2023-06-01 17:40:47 +03:00
caf7213bca 4.1.0 2023-05-26 17:12:03 +03:00
1649 changed files with 180502 additions and 28335 deletions

4
.gitignore vendored
View File

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

View File

@@ -1,10 +1,128 @@
## Version 4.0.2 ## Version 4.6.0
## Features ### Feature
- Added new data source decort_k8s_computes used to list all VMs in k8s cluster
- Added the ability to manipulate worker-groups inside resource decort_k8s
- Added new required field name to workers block
- Added new optional fields (labels, annotations, taints) to workers block
## Bug Fix #### general
- Fixed incorrect state reading in resource decort_k8s - 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
- 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
- Rename computed field name to k8s_name in order to fix state in data source decort_k8s_list_deleted in cloudapi/k8s
- Delete account_id field in data sources decort_rg_list_lb and decort_cb_rg_list_lb in cloudapi/rg and cloubroker/rg

View File

@@ -1,30 +1,29 @@
TEST?=$$(go list ./... | grep -v 'vendor') TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=digitalenergy.online HOSTNAME=basis
NAMESPACE=decort NAMESPACE=decort
NAME=terraform-provider-decort NAME=terraform-provider-decort
BINDIR = ./bin BINDIR = ./bin
ZIPDIR = ./zip ZIPDIR = ./zip
#BINARY=terraform-provider-${NAME} BINARY=${NAME}
BINARY=${NAME}.exe
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/ MAINPATH = ./cmd/decort/
VERSION=4.0.2 VERSION=4.6.0
#OS_ARCH=darwin_amd64 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
OS_ARCH=windows_amd64
#OS_ARCH=linux_amd64
FILES= ${BINARY}_${VERSION}_darwin_amd64\ FILES = ${BINARY}_${VERSION}_darwin_amd64\
${BINARY}_${VERSION}_darwin_arm64\
${BINARY}_${VERSION}_freebsd_386\ ${BINARY}_${VERSION}_freebsd_386\
${BINARY}_${VERSION}_freebsd_amd64\ ${BINARY}_${VERSION}_freebsd_amd64\
${BINARY}_${VERSION}_freebsd_arm\ ${BINARY}_${VERSION}_freebsd_arm\
${BINARY}_${VERSION}_linux_386\ ${BINARY}_${VERSION}_linux_386\
${BINARY}_${VERSION}_linux_amd64\ ${BINARY}_${VERSION}_linux_amd64\
${BINARY}_${VERSION}_linux_arm\ ${BINARY}_${VERSION}_linux_arm\
${BINARY}_${VERSION}_linux_arm64\
${BINARY}_${VERSION}_openbsd_386\ ${BINARY}_${VERSION}_openbsd_386\
${BINARY}_${VERSION}_openbsd_amd64\ ${BINARY}_${VERSION}_openbsd_amd64\
${BINARY}_${VERSION}_solaris_amd64\ ${BINARY}_${VERSION}_solaris_amd64\
${BINARY}_${VERSION}_windows_386 \ ${BINARY}_${VERSION}_windows_386.exe\
${BINARY}_${VERSION}_windows_amd64\ ${BINARY}_${VERSION}_windows_amd64.exe\
BINS = $(addprefix bin/, $(FILES)) BINS = $(addprefix bin/, $(FILES))
@@ -50,6 +49,7 @@ release: $(FILES)
$(FILES) : $(BINDIR) $(ZIPDIR) $(BINS) $(FILES) : $(BINDIR) $(ZIPDIR) $(BINS)
zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@ zip -r $(ZIPDIR)/$@.zip $(BINDIR)/$@
zip -rj $(ZIPDIR)/$@.zip scripts/install.bat scripts/install.sh
$(BINDIR): $(BINDIR):
mkdir $@ mkdir $@
@@ -59,25 +59,27 @@ $(ZIPDIR):
$(BINS): $(BINS):
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 $(MAINPATH) GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 $(MAINPATH)
GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64 $(MAINPATH)
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 $(MAINPATH) GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 $(MAINPATH)
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 $(MAINPATH) GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 $(MAINPATH)
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm $(MAINPATH) GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm $(MAINPATH)
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 $(MAINPATH) GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 $(MAINPATH)
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 $(MAINPATH) GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 $(MAINPATH)
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm $(MAINPATH) GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm $(MAINPATH)
GOOS=linux GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_linux_arm64 ${MAINPATH}
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 $(MAINPATH) GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 $(MAINPATH)
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(MAINPATH) GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 $(MAINPATH)
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 $(MAINPATH) GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 $(MAINPATH)
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 $(MAINPATH) GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386.exe $(MAINPATH)
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 $(MAINPATH) GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64.exe $(MAINPATH)
install: build install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
test: test:
go test -i $(TEST) || exit 1 go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
testacc: testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

228
README.md
View File

@@ -6,7 +6,11 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
| Версия DECORT API | Версия провайдера Terraform | | Версия DECORT API | Версия провайдера Terraform |
| ------ | ------ | | ------ | ------ |
| 3.8.6 | 4.x.x | | 4.4.0 | 4.6.x |
| 3.8.9 | 4.5.x |
| 3.8.8 | 4.4.x |
| 3.8.7 | 4.3.x |
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
| 3.8.5 | 3.4.x | | 3.8.5 | 3.4.x |
| 3.8.0 - 3.8.4 | 3.3.1 | | 3.8.0 - 3.8.4 | 3.3.1 |
| 3.7.x | rc-1.25 | | 3.7.x | rc-1.25 |
@@ -24,118 +28,163 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
## Возможности провайдера ## Возможности провайдера
- Работа с Compute instances, - Режим пользователя:
- Работа с disks, - Работа с accounts,
- Работа с k8s, - Работа с bservice,
- Работа с image, - Работа с disks,
- Работа с reource groups, - Работа с extnets,
- Работа с VINS, - Работа с flipgroups,
- Работа с pfw, - Работа с image,
- Работа с accounts, - Работа с k8s,
- Работа с snapshots, - Работа с Compute instances,
- Работа с pcidevice, - Работа с load balancer,
- Работа с sep, - Работа с locations,
- Работа с vgpu, - Работа с pfw,
- Работа с bservice, - Работа с resource groups,
- Работа с extnets, - Работа с snapshots,
- Работа с locations, - Работа с stacks,
- Работа с load balancer. - Работа с VINS.
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki - Режим администратора:
- Работа с accounts,
- Работа с audits,
- Работа с disks,
- Работа с extnets,
- Работа с flipgroups,
- Работа с grids,
- Работа с images,
- Работа с k8ci,
- Работа с k8s,
- Работа с Compute instances,
- Работа с load balancer,
- Работа с pci device,
- Работа с resource groups,
- Работа с seps,
- Работа с user,
- Работа с stacks,
- Работа с VINS.
## Начало Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
Старт возможен по двум путям: ## Установка
Начиная с версии провайдера `4.3.0` в релизном архиве находятся скрипты-инсталляторы.
1. Установка через собранные пакеты. Чтобы выполнить установку, необходимо:
2. Ручная установка. 1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
### Установка через собранные пакеты. 3. Скачать архив.
4. Распаковать архив.
1. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started 5. Выполнить скрипт установщика, `install.sh` или `install.bat` для Windows.<br/>
2. Создайте файл `main.tf` и добавьте в него следующий блок. *Для запуска `install.sh` не забудьте изменить права доступа к файлу*
```bash
chmod u+x install.sh
```
6. Дождаться сообщения об успешной установке. Установщик выведет актуальный блок конфигурации провайдера, скопируйте его
```bash
DECORT provider version 4.3.0 has been successfully installed
Copy this provider configuration to main.tf file:
terraform {
required_providers {
decort = {
version = "4.3.0"
source = "basis/decort/decort"
}
}
}
```
7. После этого, создайте файл `main.tf` в рабочей директории, которая может находится в любом удобном для пользователя месте.
В данном примере, рабочая директория с файлом main.tf находится по пути:
```bash
~/work/tfdir/main.tf
```
8. Вставьте в `main.tf` блок конфигурации провайдера, который был выведен на экран установщиком:
```terraform
terraform {
required_providers {
decort = {
version = "4.3.0"
source = "basis/decort/decort"
}
}
}
```
9. Добавьте в файл блок с инициализацией провайдера.
```terraform ```terraform
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "decs3o"
#controller_url = <DECORT_CONTROLLER_URL> controller_url = "https://mr4.digitalenergy.online"
controller_url = "https://ds1.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
``` ```
3. Выполните команду 10. В консоли выполните команду
```bash
```
terraform init terraform init
``` ```
Провайдер автоматически будет установлен на ваш компьютер из terraform registry. 11. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
### Ручная установка
1. Скачайте и установите Go по ссылке: https://go.dev/dl/
2. Скачайте и установите terraform по ссылке: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started
3. Склонируйте репозиторий с провайдером, выполнив команду:
```bash
git clone https://repository.basistech.ru/BASIS/terraform-provider-decort
```
4. Перейдите в скачанную папку с провайдером и выполните команду
```bash
go build -o terraform-provider-decort
```
Если вы знаете как устроен _makefile_, то можно изменить в файле `Makefile` параметры под вашу ОС и выполнить команду
```bash
make build
```
5. Полученный файл необходимо поместить:
Linux:
## Установка из релизов
Terraform провайдер DECORT имеет скомпилированные релизные версии, которые расположены по адресу: [Релизы](https://repository.basistech.ru/BASIS/terraform-provider-decort/releases).
Чтобы выполнить установку из релиза, необходимо:
1. Перейти по адресу: https://repository.basistech.ru/BASIS/terraform-provider-decort/releases
2. Выбрать необходимую версию провайдера подходящую под операционную систему.
3. Скачать архив.
4. Распаковать архив.
5. Полученный файл (в директории `bin/`) необходимо поместить:
Linux:
```bash ```bash
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target} ~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
``` ```
Windows: Windows:
```powershell ```powershell
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target} %APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
``` ```
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
Где: Где:
- host_name - имя хоста, держателя провайдера, например, basis
- host_name - имя хоста, держателя провайдера, например, digitalenergy.online - namespace - пространство имен хоста, например decort
- namespace - пространство имен хоста, например decort
- type - тип провайдера, может совпадать с пространством имен, например, decort - type - тип провайдера, может совпадать с пространством имен, например, decort
- version - версия провайдера, например 1.2 - version - версия провайдера, например 4.3.0
- target - версия ОС, например windows_amd64 - target - архитектура операционной системы, например windows_amd64
6. После этого, создайте файл `main.tf`. В примере ниже используется путь до провайдера на машине с ОС Linux:
7. Добавьте в него следующий блок
```bash
~/.terraform.d/plugins/basis/decort/decort/4.3.0/linux_amd64/tf-provider
^ ^ ^ ^ ^ ^
host_name | | | | | |
| | | | |
namespace | | | | |
| | | |
type | | | |
| | |
version | | |
| |
target | |
|
исполняемый файл |
```
6. После этого, создайте файл `main.tf` в рабочей директории, которая может находится в любом удобном для пользователя месте.
В данном примере, рабочая директория с файлом main.tf находится по пути:
```bash
~/work/tfdir/main.tf
```
7. Добавьте в `main.tf` следующий блок
```terraform ```terraform
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
version = "1.2" version = "4.3.0"
source = "digitalenergy.online/decort/decort" source = "basis/decort/decort"
} }
} }
} }
``` ```
В поле `version` указывается версия провайдера.
В поле `version` указывается версия провайдера. <br/>
Обязательный параметр **ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
Тип поля - строка
ВНИМАНИЕ: Версии в блоке и в репозитории, в который был помещен провайдер должны совпадать!
В поле `source` помещается путь до репозитория с версией вида: В поле `source` помещается путь до репозитория с версией вида:
@@ -143,17 +192,24 @@ terraform {
${host_name}/${namespace}/${type} ${host_name}/${namespace}/${type}
``` ```
ВНИМАНИЕ: все параметры должны совпадать с путем репозитория, в котором помещен провайдер. **ВНИМАНИЕ: Версии в блоке и в пути к исполняемому файлу провайдера должны совпадать!**
8. В консоле выполнить команду 8. Добавьте в файл блок с инициализацией провайдера.
```terraform
provider "decort" {
authenticator = "decs3o"
controller_url = "https://mr4.digitalenergy.online"
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
```
9. В консоли выполните команду
```bash ```bash
terraform init terraform init
``` ```
9. Если все прошло хорошо - ошибок не будет. 10. В случае успешной установки, Terraform инициализирует провайдер и будет готов к дальнейшей работе.
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
## Примеры работы ## Примеры работы
@@ -162,8 +218,4 @@ terraform init
- На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki - На вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
- В папке `samples` - В папке `samples`
Схемы к terraform'у доступны:
- В папке `docs`
Хорошей работы! Хорошей работы!

View File

@@ -58,7 +58,7 @@ Two ways for starting:
```terraform ```terraform
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "decs3o"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>

View File

@@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

71
go.mod
View File

@@ -1,56 +1,58 @@
module repository.basistech.ru/BASIS/terraform-provider-decort module repository.basistech.ru/BASIS/terraform-provider-decort
go 1.18 go 1.20
require ( require (
github.com/golang-jwt/jwt/v4 v4.4.3 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.24.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/sirupsen/logrus v1.9.0 github.com/sirupsen/logrus v1.9.0
golang.org/x/net v0.5.0 golang.org/x/net v0.19.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3 repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1
) )
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/agext/levenshtein v1.2.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.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/fatih/color v1.13.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect github.com/go-playground/validator/v10 v10.15.4 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
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.4.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.4.8 // indirect github.com/hashicorp/go-plugin v1.6.0 // 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.4.0 // indirect github.com/hashicorp/hc-install v0.6.3 // indirect
github.com/hashicorp/hcl/v2 v2.15.0 // 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.17.3 // indirect github.com/hashicorp/terraform-exec v0.20.0 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect github.com/hashicorp/terraform-json v0.21.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.14.2 // indirect github.com/hashicorp/terraform-plugin-go v0.22.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // 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.13 // indirect github.com/imdario/mergo v0.3.15 // indirect
github.com/leodido/go-urn v1.2.1 // indirect github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect github.com/mattn/go-isatty v0.0.20 // 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
@@ -63,15 +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/v4 v4.3.12 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect github.com/zclconf/go-cty v1.14.2 // indirect
golang.org/x/crypto v0.5.0 // indirect golang.org/x/crypto v0.19.0 // indirect
golang.org/x/sys v0.4.0 // indirect golang.org/x/mod v0.15.0 // indirect
golang.org/x/text v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect
google.golang.org/appengine v1.6.7 // indirect golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect google.golang.org/appengine v1.6.8 // indirect
google.golang.org/grpc v1.51.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/protobuf v1.28.1 // indirect google.golang.org/grpc v1.61.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

254
go.sum
View File

@@ -1,4 +1,4 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
@@ -7,124 +7,106 @@ github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr
github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/ProtonMail/go-crypto v1.1.0-alpha.0 h1:nHGfwXmFvJrSR9xu8qL7BkO4DqTHXE9N5vPhgY2I+j0=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/ProtonMail/go-crypto v1.1.0-alpha.0/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
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.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
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/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 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/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/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=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 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/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
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.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.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=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A=
github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
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.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
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.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= github.com/hashicorp/hc-install v0.6.3 h1:yE/r1yJvWbtrJ0STwScgEnCanb0U9v7zp0Gbkmcoxqs=
github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= github.com/hashicorp/hc-install v0.6.3/go.mod h1:KamGdbodYzlufbWh4r9NRo8y6GLHWZP2GBtdnms1Ln0=
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= 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.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo=
github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw=
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U=
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
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.14.2 h1:rhsVEOGCnY04msNymSvbUsXfRLKh9znXZmHlf5e8mhE= github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc=
github.com/hashicorp/terraform-plugin-go v0.14.2/go.mod h1:Q12UjumPNGiFsZffxOsA40Tlz1WVXt2Evh865Zj0+UA= github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE=
github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 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=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
@@ -133,28 +115,19 @@ github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -163,15 +136,14 @@ 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=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
@@ -181,102 +153,76 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
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.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
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/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=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
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-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/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=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -286,51 +232,45 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.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/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.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.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.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
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.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3 h1:jrBl90lRfp34bE3m30N3mYIDTSlaPySuo+pE7bK4eOI= repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1 h1:wpxjnVO7hGaQVWbtFoYVbNoeFxk0QUnEfDsPuWjiNk0=
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE= repository.basistech.ru/BASIS/decort-golang-sdk v1.8.1/go.mod h1:OaUynHHuSjWMzpfyoL4au6oLcUogqUkPPBKA15pbHWo=

View File

@@ -1,27 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package constants
//CloudApi - a part of url for cloudapi
const CloudApi = "/restmachine/cloudapi"
//CloudBroker - a part of url for cloudbroker
const CloudBroker = "/restmachine/cloudbroker"

View File

@@ -20,20 +20,23 @@ limitations under the License.
package constants package constants
// LimitMaxVinsPerResgroup set maximum number of VINs instances per Resource Group // LIMIT_MAX_VINS_PER_RESGROUP set maximum number of VINs instances per Resource Group
const LimitMaxVinsPerResgroup = 4 const LIMIT_MAX_VINS_PER_RESGROUP = 4
// MaxSshKeysPerCompute sets maximum number of user:ssh_key pairs to authorize when creating new compute // MAX_SSHKEYS_PER_COMPUTE sets maximum number of user:ssh_key pairs to authorize when creating new compute
const MaxSshKeysPerCompute = 12 const MAX_SSHKEYS_PER_COMPUTE = 12
// MaxExtraDisksPerCompute sets maximum number of extra disks that can be added when creating new compute // MAX_EXTRA_DISKS_PER_COMPUTE sets maximum number of extra disks that can be added when creating new compute
const MaxExtraDisksPerCompute = 12 const MAX_EXTRA_DISKS_PER_COMPUTE = 12
// MaxNetworksPerCompute sets maximum number of vNICs per compute // MAX_NETWORKS_PER_COMPUTE sets maximum number of vNICs per compute
const MaxNetworksPerCompute = 8 const MAX_NETWORKS_PER_COMPUTE = 8
// MaxCpusPerCompute sets maximum number of vCPUs per compute // MAX_CPUS_PER_COMPUTE sets maximum number of vCPUs per compute
const MaxCpusPerCompute = 128 const MAX_CPUS_PER_COMPUTE = 128
// MinRamPerCompute sets minimum amount of RAM per compute in MB // MIN_RAM_PER_COMPUTE sets minimum amount of RAM per compute in MB
const MinRamPerCompute = 128 const MIN_RAM_PER_COMPUTE = 128
// RAM_DIVISIBILITY sets divisibility of RAM value
const RAM_DIVISIBILITY = 128

View File

@@ -1,32 +1,33 @@
/* /*
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 Timeout20m = time.Minute * 20 var Timeout900s = time.Second * 900
var Timeout30m = time.Minute * 30 var Timeout20m = time.Minute * 20
var Timeout30m = time.Minute * 30

View File

@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -21,18 +21,14 @@ limitations under the License.
package controller package controller
import ( import (
"bytes"
"context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time"
// "time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
decort "repository.basistech.ru/BASIS/decort-golang-sdk" decort "repository.basistech.ru/BASIS/decort-golang-sdk"
@@ -41,31 +37,37 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
jwt "github.com/golang-jwt/jwt/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
// enumerated constants that define authentication modes // enumerated constants that define authentication modes
const ( const (
MODE_UNDEF = iota // this is the invalid mode - it should never be seen MODE_UNDEF = iota // this is the invalid mode - it should never be seen
MODE_LEGACY = iota MODE_LEGACY
MODE_OAUTH2 = iota MODE_DECS3O
MODE_JWT = iota MODE_JWT
MODE_BVS
) )
type ControllerCfg struct { type ControllerCfg struct {
controller_url string // always required controller_url string // always required
auth_mode_code int // always required auth_mode_code int // always required
auth_mode_txt string // always required, it is a text representation of auth mode auth_mode_txt string // always required, it is a text representation of auth mode
bvs_user string // required for bvs mode
bvs_password string // required for bvs mode
domain string // required for bvs mode
token config.Token // obtained from BVS provider on successful login in bvs mode
path_cfg string // the path of the configuration file entry
path_token string // the path of the token file entry
time_to_refresh int64 // the number of minutes before the expiration of the token, a refresh will be made
legacy_user string // required for legacy mode legacy_user string // required for legacy mode
legacy_password string // required for legacy mode legacy_password string // required for legacy mode
legacy_sid string // obtained from DECORT controller on successful login in legacy mode legacy_sid string // obtained from DECORT controller on successful login in legacy mode
jwt string // obtained from Outh2 provider on successful login in oauth2 mode, required in jwt mode jwt string // obtained from Outh2 provider on successful login in decs3o mode, required in jwt mode
app_id string // required for oauth2 mode app_id string // required for decs3o and bvs mode
app_secret string // required for oauth2 mode app_secret string // required for decs3o and bvs mode
oauth2_url string // always required oauth2_url string // required for decs3o and bvs mode
decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (oauth2 mode) upon successful verification decort_username string // assigned to either legacy_user (legacy mode) or Oauth2 user (decs3o mode) upon successful verification
cc_client *http.Client // assigned when all initial checks successfully passed cc_client *http.Client // assigned when all initial checks successfully passed
caller interfaces.Caller caller interfaces.Caller
} }
@@ -88,17 +90,24 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
legacy_user: d.Get("user").(string), legacy_user: d.Get("user").(string),
legacy_password: d.Get("password").(string), legacy_password: d.Get("password").(string),
legacy_sid: "", legacy_sid: "",
bvs_user: d.Get("bvs_user").(string),
bvs_password: d.Get("bvs_password").(string),
domain: d.Get("domain").(string),
jwt: d.Get("jwt").(string), jwt: d.Get("jwt").(string),
app_id: d.Get("app_id").(string), app_id: d.Get("app_id").(string),
app_secret: d.Get("app_secret").(string), app_secret: d.Get("app_secret").(string),
oauth2_url: d.Get("oauth2_url").(string), oauth2_url: d.Get("oauth2_url").(string),
decort_username: "", decort_username: "",
token: config.Token{},
path_cfg: d.Get("path_cfg").(string),
path_token: d.Get("path_token").(string),
time_to_refresh: int64(d.Get("time_to_refresh").(int)),
} }
allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool) allow_unverified_ssl := d.Get("allow_unverified_ssl").(bool)
if ret_config.controller_url == "" { if ret_config.controller_url == "" {
return nil, fmt.Errorf("Empty DECORT cloud controller URL provided.") return nil, fmt.Errorf("empty DECORT cloud controller URL provided")
} }
// this should have already been done by StateFunc defined in Schema, but we want to be sure // this should have already been done by StateFunc defined in Schema, but we want to be sure
@@ -107,33 +116,53 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
switch ret_config.auth_mode_txt { switch ret_config.auth_mode_txt {
case "jwt": case "jwt":
if ret_config.jwt == "" { if ret_config.jwt == "" {
return nil, fmt.Errorf("Authenticator mode 'jwt' specified but no JWT provided.") return nil, fmt.Errorf("authenticator mode 'jwt' specified but no JWT provided")
} }
ret_config.auth_mode_code = MODE_JWT ret_config.auth_mode_code = MODE_JWT
case "oauth2": case "decs3o":
if ret_config.oauth2_url == "" { if ret_config.oauth2_url == "" {
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no OAuth2 URL provided.") return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no OAuth2 URL provided")
} }
if ret_config.app_id == "" { if ret_config.app_id == "" {
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Application ID provided.") return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Application ID provided")
} }
if ret_config.app_secret == "" { if ret_config.app_secret == "" {
return nil, fmt.Errorf("Authenticator mode 'oauth2' specified but no Secret ID provided.") return nil, fmt.Errorf("authenticator mode 'decs3o' specified but no Secret ID provided")
} }
ret_config.auth_mode_code = MODE_OAUTH2 ret_config.auth_mode_code = MODE_DECS3O
case "legacy": case "legacy":
// //
ret_config.legacy_user = d.Get("user").(string) ret_config.legacy_user = d.Get("user").(string)
if ret_config.legacy_user == "" { if ret_config.legacy_user == "" {
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no user provided.") return nil, fmt.Errorf("authenticator mode 'legacy' specified but no user provided")
} }
ret_config.legacy_password = d.Get("password").(string) ret_config.legacy_password = d.Get("password").(string)
if ret_config.legacy_password == "" { if ret_config.legacy_password == "" {
return nil, fmt.Errorf("Authenticator mode 'legacy' specified but no password provided.") return nil, fmt.Errorf("authenticator mode 'legacy' specified but no password provided")
} }
ret_config.auth_mode_code = MODE_LEGACY ret_config.auth_mode_code = MODE_LEGACY
case "bvs":
if ret_config.bvs_user == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no user provided")
}
if ret_config.bvs_password == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no password provided")
}
if ret_config.oauth2_url == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no bvs URL provided")
}
if ret_config.app_id == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Application ID provided")
}
if ret_config.app_secret == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Secret ID provided")
}
if ret_config.domain == "" {
return nil, fmt.Errorf("authenticator mode 'bvs' specified but no Domain provided")
}
ret_config.auth_mode_code = MODE_BVS
default: default:
return nil, fmt.Errorf("Unknown authenticator mode %q provided.", ret_config.auth_mode_txt) return nil, fmt.Errorf("unknown authenticator mode %q provided", ret_config.auth_mode_txt)
} }
if allow_unverified_ssl { if allow_unverified_ssl {
@@ -158,7 +187,6 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
Username: ret_config.legacy_user, Username: ret_config.legacy_user,
Password: ret_config.legacy_password, Password: ret_config.legacy_password,
DecortURL: ret_config.controller_url, DecortURL: ret_config.controller_url,
Retries: 0,
SSLSkipVerify: allow_unverified_ssl, SSLSkipVerify: allow_unverified_ssl,
} }
@@ -170,30 +198,30 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
if !ok { if !ok {
return nil, err return nil, err
} }
case MODE_OAUTH2: case MODE_DECS3O:
// on success getOAuth2JWT will set config.jwt to the obtained JWT, so there is no // on success getDECS3OJWT will set config.jwt to the obtained JWT, so there is no
// need to set it once again here // need to set it once again here
_, err := ret_config.getOAuth2JWT() // _, err := ret_config.getDECS3OJWT()
if err != nil { // if err != nil {
return nil, err // return nil, err
} // }
// we are not verifying the JWT when parsing because actual verification is done on the // we are not verifying the JWT when parsing because actual verification is done on the
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user") // OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
// and JWT issuer name (claim "iss") // and JWT issuer name (claim "iss")
parser := jwt.Parser{} // parser := jwt.Parser{}
token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{}) // token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
if err != nil { // if err != nil {
return nil, err // return nil, err
} // }
if claims, ok := token.Claims.(jwt.MapClaims); ok { // if claims, ok := token.Claims.(jwt.MapClaims); ok {
var tbuf bytes.Buffer // var tbuf bytes.Buffer
tbuf.WriteString(claims["username"].(string)) // tbuf.WriteString(claims["username"].(string))
tbuf.WriteString("@") // tbuf.WriteString("@")
tbuf.WriteString(claims["iss"].(string)) // tbuf.WriteString(claims["iss"].(string))
ret_config.decort_username = tbuf.String() // ret_config.decort_username = tbuf.String()
} else { // } else {
return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.") // return nil, fmt.Errorf("failed to extract user and iss fields from JWT token in oauth2 mode")
} // }
sdkConf := config.Config{ sdkConf := config.Config{
AppID: ret_config.app_id, AppID: ret_config.app_id,
@@ -204,10 +232,27 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
} }
ret_config.caller = decort.New(sdkConf) ret_config.caller = decort.New(sdkConf)
case MODE_BVS:
sdkConf := config.BVSConfig{
AppID: ret_config.app_id,
AppSecret: ret_config.app_secret,
SSOURL: ret_config.oauth2_url,
DecortURL: ret_config.controller_url,
SSLSkipVerify: allow_unverified_ssl,
Username: ret_config.bvs_user,
Password: ret_config.bvs_password,
Domain: ret_config.domain,
Token: ret_config.token,
PathCfg: ret_config.path_cfg,
PathToken: ret_config.path_token,
TimeToRefresh: ret_config.time_to_refresh,
}
ret_config.caller = decort.NewBVS(sdkConf)
default: default:
// FYI, this should never happen due to all above checks, but we want to be fool proof // FYI, this should never happen due to all above checks, but we want to be fool proof
return nil, fmt.Errorf("Unknown authenticator mode code %d provided.", ret_config.auth_mode_code) return nil, fmt.Errorf("unknown authenticator mode code %d provided", ret_config.auth_mode_code)
} }
// All checks passed successfully, credentials corresponding to the selected authenticator mode // All checks passed successfully, credentials corresponding to the selected authenticator mode
@@ -215,57 +260,57 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
return ret_config, nil return ret_config, nil
} }
func (config *ControllerCfg) GetDecortUsername() string { // func (config *ControllerCfg) GetDecortUsername() string {
return config.decort_username // return config.decort_username
} // }
func (config *ControllerCfg) getOAuth2JWT() (string, error) { // func (config *ControllerCfg) getDECS3OJWT() (string, error) {
// Obtain JWT from the Oauth2 provider using application ID and application secret provided in config. // // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
if config.auth_mode_code == MODE_UNDEF { // if config.auth_mode_code == MODE_UNDEF {
return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.") // return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode")
} // }
if config.auth_mode_code != MODE_OAUTH2 { // if config.auth_mode_code != MODE_DECS3O {
return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt) // return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q", config.auth_mode_txt)
} // }
params := url.Values{} // params := url.Values{}
params.Add("grant_type", "client_credentials") // params.Add("grant_type", "client_credentials")
params.Add("client_id", config.app_id) // params.Add("client_id", config.app_id)
params.Add("client_secret", config.app_secret) // params.Add("client_secret", config.app_secret)
params.Add("response_type", "id_token") // params.Add("response_type", "id_token")
params.Add("validity", "3600") // params.Add("validity", "3600")
params_str := params.Encode() // params_str := params.Encode()
req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str)) // req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str))
if err != nil { // if err != nil {
return "", err // return "", err
} // }
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") // req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Length", strconv.Itoa(len(params_str))) // req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
resp, err := config.cc_client.Do(req) // resp, err := config.cc_client.Do(req)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
if resp.StatusCode != http.StatusOK { // if resp.StatusCode != http.StatusOK {
// fmt.Println("response Status:", resp.Status) // // fmt.Println("response Status:", resp.Status)
// fmt.Println("response Headers:", resp.Header) // // fmt.Println("response Headers:", resp.Header)
// fmt.Println("response Headers:", req.URL) // // fmt.Println("response Headers:", req.URL)
return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q", // return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q",
resp.StatusCode, req.URL, config.app_id, params_str) // resp.StatusCode, req.URL, config.app_id, params_str)
} // }
defer resp.Body.Close() // defer resp.Body.Close()
responseData, err := ioutil.ReadAll(resp.Body) // responseData, err := io.ReadAll(resp.Body)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
// validation successful - store JWT in the corresponding field of the ControllerCfg structure // // validation successful - store JWT in the corresponding field of the ControllerCfg structure
config.jwt = strings.TrimSpace(string(responseData)) // config.jwt = strings.TrimSpace(string(responseData))
return config.jwt, nil // return config.jwt, nil
} // }
func (config *ControllerCfg) validateJWT(jwt string) (bool, error) { func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
/* /*
@@ -276,13 +321,13 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
*/ */
if jwt == "" { if jwt == "" {
if config.jwt == "" { if config.jwt == "" {
return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided.") return false, fmt.Errorf("validateJWT method called, but no meaningful JWT provided")
} }
jwt = config.jwt jwt = config.jwt
} }
if config.oauth2_url == "" { if config.oauth2_url == "" {
return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided.") return false, fmt.Errorf("validateJWT method called, but no OAuth2 URL provided")
} }
req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil) req, err := http.NewRequest("POST", config.controller_url+"/restmachine/cloudapi/account/list", nil)
@@ -299,7 +344,7 @@ func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
return false, err return false, err
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q.", return false, fmt.Errorf("validateJWT: unexpected status code %d when validating JWT against %q",
resp.StatusCode, req.URL) resp.StatusCode, req.URL)
} }
defer resp.Body.Close() defer resp.Body.Close()
@@ -315,10 +360,10 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
reason, the method will return false and error. reason, the method will return false and error.
*/ */
if config.auth_mode_code == MODE_UNDEF { if config.auth_mode_code == MODE_UNDEF {
return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode.") return false, fmt.Errorf("validateLegacyUser method called for undefined authorization mode")
} }
if config.auth_mode_code != MODE_LEGACY { if config.auth_mode_code != MODE_LEGACY {
return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q.", config.auth_mode_txt) return false, fmt.Errorf("validateLegacyUser method called for incompatible authorization mode %q", config.auth_mode_txt)
} }
params := url.Values{} params := url.Values{}
@@ -339,12 +384,12 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
return false, err return false, err
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q.", return false, fmt.Errorf("validateLegacyUser: unexpected status code %d when validating legacy user %q against %q",
resp.StatusCode, config.legacy_user, config.controller_url) resp.StatusCode, config.legacy_user, config.controller_url)
} }
defer resp.Body.Close() defer resp.Body.Close()
responseData, err := ioutil.ReadAll(resp.Body) responseData, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@@ -356,100 +401,32 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
} }
func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI { func (config *ControllerCfg) CloudAPI() *cloudapi.CloudAPI {
if config.auth_mode_code == MODE_LEGACY { switch config.auth_mode_code {
case MODE_LEGACY:
client, _ := config.caller.(*decort.LegacyDecortClient) client, _ := config.caller.(*decort.LegacyDecortClient)
return client.CloudAPI() return client.CloudAPI()
case MODE_DECS3O:
client, _ := config.caller.(*decort.DecortClient)
return client.CloudAPI()
case MODE_BVS:
client, _ := config.caller.(*decort.BVSDecortClient)
return client.CloudAPI()
default:
return &cloudapi.CloudAPI{}
} }
client, _ := config.caller.(*decort.DecortClient)
return client.CloudAPI()
} }
func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker { func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker {
if config.auth_mode_code == MODE_LEGACY { switch config.auth_mode_code {
case MODE_LEGACY:
client, _ := config.caller.(*decort.LegacyDecortClient) client, _ := config.caller.(*decort.LegacyDecortClient)
return client.CloudBroker() return client.CloudBroker()
case MODE_DECS3O:
client, _ := config.caller.(*decort.DecortClient)
return client.CloudBroker()
case MODE_BVS:
client, _ := config.caller.(*decort.BVSDecortClient)
return client.CloudBroker()
default:
return &cloudbroker.CloudBroker{}
} }
client, _ := config.caller.(*decort.DecortClient)
return client.CloudBroker()
}
func (config *ControllerCfg) DecortAPICall(ctx context.Context, method string, api_name string, url_values *url.Values) (json_resp string, err error) { //nolint:unparam
// This is a convenience wrapper around standard HTTP request methods that is aware of the
// authorization mode for which the provider was initialized and compiles request accordingly.
if config.cc_client == nil {
// this should never happen if ClientConfig was properly called prior to decortAPICall
return "", fmt.Errorf("decortAPICall method called with unconfigured DECORT cloud controller HTTP client.")
}
// Example: to create api_params, one would generally do the following:
//
// data := []byte(`{"machineId": "2638"}`)
// api_params := bytes.NewBuffer(data))
//
// Or:
//
// params := url.Values{}
// params.Add("machineId", "2638")
// params.Add("username", "u")
// params.Add("password", "b")
// req, _ := http.NewRequest(method, url, strings.NewReader(params.Encode()))
//
if config.auth_mode_code == MODE_UNDEF {
return "", fmt.Errorf("decortAPICall method called for unknown authorization mode.")
}
if config.auth_mode_code == MODE_LEGACY {
url_values.Add("authkey", config.legacy_sid)
}
params_str := url_values.Encode()
req, err := http.NewRequest(method, config.controller_url+api_name, strings.NewReader(params_str))
if err != nil {
return "", err
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
req.Header.Set("Accept", "application/json")
if config.auth_mode_code == MODE_OAUTH2 || config.auth_mode_code == MODE_JWT {
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
}
var resp *http.Response
var body []byte
for i := 0; i < 5; i++ {
resp, err = config.cc_client.Do(req)
if err != nil {
return "", err
}
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
resp.Body.Close()
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
if resp.StatusCode == http.StatusOK {
return string(body), nil
} else {
if resp.StatusCode == http.StatusInternalServerError {
log.Warnf("got 500, retrying %d/5", i+1)
time.Sleep(time.Second * 5)
continue
}
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
}
}
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
} }

View File

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

View File

@@ -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 LocationsListAPI = "/restmachine/cloudapi/locations/list" // Returns list of GridRecord on success const LOCATIONS_LIST_API = "/restmachine/cloudapi/locations/list" // Returns list of GridRecord on success

View File

@@ -41,13 +41,13 @@ func UtilityLocationGetDefaultGridID(ctx context.Context, m interface{}) (int, e
return 0, err return 0, err
} }
if len(locList) == 0 { if len(locList.Data) == 0 {
DefaultGridID = 0 DefaultGridID = 0
return 0, fmt.Errorf("utilityLocationGetDefaultGridID: retrieved 0 length locations list") return 0, fmt.Errorf("utilityLocationGetDefaultGridID: retrieved 0 length locations list")
} }
DefaultGridID = int(locList[0].GID) DefaultGridID = int(locList.Data[0].GID)
log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList[0].Name) log.Debugf("utilityLocationGetDefaultGridID: default location GridID %d, name %s", DefaultGridID, locList.Data[0].Name)
return DefaultGridID, nil return DefaultGridID, nil
} }

View File

@@ -1,151 +1,269 @@
/* /*
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/image" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vfpool"
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image" cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice" cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit"
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg" cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep" cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu" cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
) cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
func newDataSourcesMap() map[string]*schema.Resource { cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
return map[string]*schema.Resource{ cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
"decort_account": account.DataSourceAccount(), cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
"decort_resgroup": rg.DataSourceResgroup(), cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
"decort_kvmvm": kvmvm.DataSourceCompute(), cb_node "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/node"
"decort_kvmvm_list": kvmvm.DataSourceComputeList(), cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(), cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(), cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(), cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(), cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user"
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(), cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool"
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(), cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(), // cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
"decort_k8s": k8s.DataSourceK8s(), )
"decort_k8s_list": k8s.DataSourceK8sList(),
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(), func newDataSourcesMap() map[string]*schema.Resource {
"decort_k8s_wg": k8s.DataSourceK8sWg(), return map[string]*schema.Resource{
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(), "decort_account": account.DataSourceAccount(),
"decort_k8s_computes": k8s.DataSourceK8sComputes(), "decort_resgroup": rg.DataSourceResgroup(),
"decort_vins": vins.DataSourceVins(), "decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_vins_list": vins.DataSourceVinsList(), "decort_kvmvm_list": kvmvm.DataSourceComputeList(),
"decort_vins_audits": vins.DataSourceVinsAudits(), "decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
"decort_vins_ip_list": vins.DataSourceVinsIpList(), "decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(), "decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(), "decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(), "decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
"decort_snapshot_list": snapshot.DataSourceSnapshotList(), "decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
"decort_disk": disks.DataSourceDisk(), "decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
"decort_disk_list": disks.DataSourceDiskList(), "decort_k8s": k8s.DataSourceK8s(),
"decort_rg_list": rg.DataSourceRgList(), "decort_k8s_list": k8s.DataSourceK8sList(),
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(), "decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(), "decort_k8s_wg": k8s.DataSourceK8sWg(),
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(), "decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
"decort_rg_audits": rg.DataSourceRgAudits(), "decort_k8s_computes": k8s.DataSourceK8sComputes(),
"decort_rg_list_computes": rg.DataSourceRgListComputes(), "decort_k8ci_list": k8s.DataSourceK8CIList(),
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(), "decort_vins": vins.DataSourceVins(),
"decort_rg_list_lb": rg.DataSourceRgListLb(), "decort_vins_list": vins.DataSourceVinsList(),
"decort_rg_list_pfw": rg.DataSourceRgListPfw(), "decort_vins_audits": vins.DataSourceVinsAudits(),
"decort_rg_list_vins": rg.DataSourceRgListVins(), "decort_vins_ip_list": vins.DataSourceVinsIpList(),
"decort_rg_usage": rg.DataSourceRgUsage(), "decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(), "decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(), "decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(), "decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(), "decort_vins_static_route": vins.DataSourceStaticRoute(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(), "decort_snapshot_list": snapshot.DataSourceSnapshotList(),
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(), "decort_disk": disks.DataSourceDisk(),
"decort_account_list": account.DataSourceAccountList(), "decort_disk_list": disks.DataSourceDiskList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(), "decort_rg_list": rg.DataSourceRgList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(), "decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
"decort_account_vins_list": account.DataSourceAccountVinsList(), "decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(), "decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
"decort_account_rg_list": account.DataSourceAccountRGList(), "decort_rg_audits": rg.DataSourceRgAudits(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(), "decort_rg_list_computes": rg.DataSourceRgListComputes(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(), "decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(), "decort_rg_list_lb": rg.DataSourceRgListLb(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(), "decort_rg_list_pfw": rg.DataSourceRgListPfw(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(), "decort_rg_list_vins": rg.DataSourceRgListVins(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(), "decort_rg_usage": rg.DataSourceRgUsage(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(), "decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_bservice": bservice.DataSourceBasicService(), "decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(), "decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(), "decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(), "decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
"decort_extnet_list": extnet.DataSourceExtnetList(), "decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(), "decort_disk_replication": disks.DataSourceDiskReplication(),
"decort_extnet": extnet.DataSourceExtnet(), "decort_account_list": account.DataSourceAccountList(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(), "decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_locations_list": locations.DataSourceLocationsList(), "decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_location_url": locations.DataSourceLocationUrl(), "decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_image_list": image.DataSourceImageList(), "decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_image": image.DataSourceImage(), "decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_lb": lb.DataSourceLB(), "decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_lb_list": lb.DataSourceLBList(), "decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(), "decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_cb_account": cb_account.DataSourceAccount(), "decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_cb_account_list": cb_account.DataSourceAccountList(), "decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(), "decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_cb_account_deleted_list": cb_account.DataSourceAccountDeletedList(), "decort_bservice": bservice.DataSourceBasicService(),
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(), "decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(), "decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(), "decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(), "decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(), "decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_cb_disk": cb_disks.DataSourceDisk(), "decort_extnet": extnet.DataSourceExtnet(),
"decort_cb_disk_list": cb_disks.DataSourceDiskList(), "decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_cb_image": cb_image.DataSourceImage(), "decort_locations_list": locations.DataSourceLocationsList(),
"decort_cb_grid": cb_grid.DataSourceGrid(), "decort_location_url": locations.DataSourceLocationUrl(),
"decort_cb_grid_list": cb_grid.DataSourceGridList(), "decort_image_list": image.DataSourceImageList(),
"decort_cb_image_list": cb_image.DataSourceImageList(), "decort_image": image.DataSourceImage(),
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(), "decort_lb": lb.DataSourceLB(),
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(), "decort_lb_list": lb.DataSourceLBList(),
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(), "decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
"decort_cb_sep_list": cb_sep.DataSourceSepList(), "decort_flipgroup": flipgroup.DataSourceFlipgroup(),
"decort_cb_sep": cb_sep.DataSourceSep(), "decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(), "decort_stack": stack.DataSourceStack(),
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(), "decort_stack_list": stack.DataSourceStackList(),
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(), "decort_vfpool": vfpool.DataSourceVFPool(),
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(), "decort_vfpool_list": vfpool.DataSourceVFPoolList(),
"decort_cb_vgpu": cb_vgpu.DataSourceVGPU(), "decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
"decort_cb_rg_list": cb_rg.DataSourceRgList(), "decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
} "decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
} "decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
"decort_cb_account": cb_account.DataSourceAccount(),
"decort_cb_account_list": cb_account.DataSourceAccountList(),
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
"decort_cb_account_available_templates_list": cb_account.DataSourceAccountAvailableTemplatesList(),
"decort_cb_audit": cb_audit.DataSourceAudit(),
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
"decort_cb_image": cb_image.DataSourceImage(),
"decort_cb_grid": cb_grid.DataSourceGrid(),
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
"decort_cb_grid_list_emails": cb_grid.DataSourceGridListEmails(),
"decort_cb_grid_list_consumption": cb_grid.DataSourceGridListConsumption(),
"decort_cb_grid_get_consumption": cb_grid.DataSourceGridGetConsumption(),
"decort_cb_image_list": cb_image.DataSourceImageList(),
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
"decort_cb_kvmvm": cb_kvmvm.DataSourceCompute(),
"decort_cb_kvmvm_affinity_relations": cb_kvmvm.DataSourceComputeAffinityRelations(),
"decort_cb_kvmvm_audits": cb_kvmvm.DataSourceComputeAudits(),
"decort_cb_kvmvm_boot_order_get": cb_kvmvm.DataSourceComputeBootOrderGet(),
"decort_cb_kvmvm_get_audits": cb_kvmvm.DataSourceComputeGetAudits(),
"decort_cb_kvmvm_get_console_url": cb_kvmvm.DataSourceComputeGetConsoleUrl(),
"decort_cb_kvmvm_get_log": cb_kvmvm.DataSourceComputeGetLog(),
"decort_cb_kvmvm_list": cb_kvmvm.DataSourceComputeList(),
"decort_cb_kvmvm_list_deleted": cb_kvmvm.DataSourceComputeListDeleted(),
"decort_cb_kvmvm_migrate_storage_info": cb_kvmvm.DataSourceComputeMigrateStorageInfo(),
"decort_cb_kvmvm_pci_device_list": cb_kvmvm.DataSourceComputePCIDeviceList(),
"decort_cb_kvmvm_pfw_list": cb_kvmvm.DataSourceComputePfwList(),
"decort_cb_kvmvm_snapshot_list": cb_kvmvm.DataSourceComputeSnapshotList(),
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
"decort_cb_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(),
}
}

View File

@@ -40,8 +40,8 @@ func Provider() *schema.Provider {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
StateFunc: statefuncs.StateFuncToLower, StateFunc: statefuncs.StateFuncToLower,
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.", Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
}, },
"oauth2_url": { "oauth2_url": {
@@ -49,7 +49,7 @@ func Provider() *schema.Provider {
Optional: true, Optional: true,
StateFunc: statefuncs.StateFuncToLower, StateFunc: statefuncs.StateFuncToLower,
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil), DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
Description: "OAuth2 application URL in 'oauth2' authentication mode.", Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
}, },
"controller_url": { "controller_url": {
@@ -74,18 +74,39 @@ func Provider() *schema.Provider {
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.", Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
}, },
"bvs_user": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
},
"bvs_password": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
},
"domain": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
},
"app_id": { "app_id": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil), DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.", Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
}, },
"app_secret": { "app_secret": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil), DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.", Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
}, },
"jwt": { "jwt": {
@@ -101,6 +122,25 @@ 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(),

View File

@@ -1,89 +1,113 @@
/* /*
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/image" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks" cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image" cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s" cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm" 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_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
cb_pfw "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pfw" cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg" cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep" cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
cb_snapshot "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/snapshot" cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins" cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
) cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
func newResourcesMap() map[string]*schema.Resource { cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user"
return map[string]*schema.Resource{ cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool"
"decort_resgroup": rg.ResourceResgroup(), cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
"decort_kvmvm": kvmvm.ResourceCompute(), )
"decort_disk": disks.ResourceDisk(),
"decort_disk_snapshot": disks.ResourceDiskSnapshot(), func newResourcesMap() map[string]*schema.Resource {
"decort_vins": vins.ResourceVins(), return map[string]*schema.Resource{
"decort_pfw": pfw.ResourcePfw(), "decort_resgroup": rg.ResourceResgroup(),
"decort_k8s": k8s.ResourceK8s(), "decort_kvmvm": kvmvm.ResourceCompute(),
"decort_k8s_wg": k8s.ResourceK8sWg(), "decort_disk": disks.ResourceDisk(),
"decort_snapshot": snapshot.ResourceSnapshot(), "decort_disk_snapshot": disks.ResourceDiskSnapshot(),
"decort_account": account.ResourceAccount(), "decort_disk_replication": disks.ResourceDiskReplication(),
"decort_bservice": bservice.ResourceBasicService(), "decort_vins": vins.ResourceVins(),
"decort_bservice_group": bservice.ResourceBasicServiceGroup(), "decort_pfw": pfw.ResourcePfw(),
"decort_image": image.ResourceImage(), "decort_k8s": k8s.ResourceK8s(),
"decort_image_virtual": image.ResourceImageVirtual(), "decort_k8s_wg": k8s.ResourceK8sWg(),
"decort_lb": lb.ResourceLB(), "decort_k8s_cp": k8s.ResourceK8sCP(),
"decort_lb_backend": lb.ResourceLBBackend(), "decort_snapshot": snapshot.ResourceSnapshot(),
"decort_lb_backend_server": lb.ResourceLBBackendServer(), "decort_account": account.ResourceAccount(),
"decort_lb_frontend": lb.ResourceLBFrontend(), "decort_bservice": bservice.ResourceBasicService(),
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(), "decort_bservice_group": bservice.ResourceBasicServiceGroup(),
"decort_image": image.ResourceImage(),
"decort_cb_account": cb_account.ResourceAccount(), "decort_image_from_blank_compute": image.ResourceImageFromBlankCompute(),
"decort_cb_disk": cb_disks.ResourceDisk(), "decort_image_from_platform_disk": image.ResourceImageFromPlatformDisk(),
"decort_cb_image": cb_image.ResourceImage(), "decort_image_virtual": image.ResourceImageVirtual(),
"decort_cb_virtual_image":cb_image.ResourceVirtualImage(), "decort_lb": lb.ResourceLB(),
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(), "decort_lb_backend": lb.ResourceLBBackend(),
"decort_cb_delete_images":cb_image.ResourceDeleteImages(), "decort_lb_backend_server": lb.ResourceLBBackendServer(),
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(), "decort_lb_frontend": lb.ResourceLBFrontend(),
"decort_cb_sep": cb_sep.ResourceSep(), "decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
"decort_cb_sep_config": cb_sep.ResourceSepConfig(), "decort_flipgroup": flipgroup.ResourceFlipgroup(),
"decort_cb_resgroup": cb_rg.ResourceResgroup(), "decort_vins_static_route": vins.ResourceStaticRoute(),
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
"decort_cb_vins": cb_vins.ResourceVins(), "decort_cb_account": cb_account.ResourceAccount(),
"decort_cb_pfw": cb_pfw.ResourcePfw(), "decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
"decort_cb_k8s": cb_k8s.ResourceK8s(), "decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(), "decort_cb_disk": cb_disks.ResourceDisk(),
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(), "decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
} "decort_cb_disk_replication": cb_disks.ResourceDiskReplication(),
} "decort_cb_image": cb_image.ResourceImage(),
"decort_cb_image_from_blank_compute": cb_image.ResourceImageFromBlankCompute(),
"decort_cb_image_from_platform_disk": cb_image.ResourceImageFromPlatformDisk(),
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
"decort_cb_sep": cb_sep.ResourceSep(),
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
"decort_cb_vins": cb_vins.ResourceVins(),
"decort_cb_k8ci": cb_k8ci.ResourceK8CI(),
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
"decort_cb_vins_static_route": cb_vins.ResourceStaticRoute(),
"decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
"decort_cb_lb": cb_lb.ResourceLB(),
"decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
"decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
"decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
"decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
"decort_cb_rg": cb_rg.ResourceResgroup(),
"decort_cb_user": cb_user.ResourceUser(),
"decort_cb_vfpool": cb_vfpool.ResourceVFPool(),
}
}

View File

@@ -41,9 +41,11 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
// TODO: resources (additional ds / additional request inside body (?))
func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
acc, err := utilityAccountCheckPresence(ctx, d, m) acc, err := utilityAccountCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -98,6 +100,10 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeFloat, Type: schema.TypeFloat,
Computed: true, Computed: true,
}, },
"cu_dm": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_i": { "cu_i": {
Type: schema.TypeFloat, Type: schema.TypeFloat,
Computed: true, Computed: true,
@@ -268,13 +274,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"resources": { // "resources": {
Type: schema.TypeList, // Type: schema.TypeList,
Computed: true, // Computed: true,
Elem: &schema.Resource{ // Elem: &schema.Resource{
Schema: resourcesSchemaMake(), // Schema: resourcesSchemaMake(),
}, // },
}, // },
"ckey": { "ckey": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -301,6 +307,13 @@ 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,

View File

@@ -1,127 +1,128 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountAuditsList(accountAuditsList)) d.SetId(id.String())
d.Set("items", flattenAccountAuditsList(accountAuditsList))
return nil
} return nil
}
func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceAccountAuditsListSchemaMake() 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",
"items": { },
Type: schema.TypeList, "items": {
Computed: true, Type: schema.TypeList,
Description: "Search Result", Computed: true,
Elem: &schema.Resource{ Description: "Search Result",
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"call": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "call": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"responsetime": { },
Type: schema.TypeFloat, "responsetime": {
Computed: true, Type: schema.TypeFloat,
}, Computed: true,
"statuscode": { },
Type: schema.TypeInt, "statuscode": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"timestamp": { },
Type: schema.TypeFloat, "timestamp": {
Computed: true, Type: schema.TypeFloat,
}, Computed: true,
"user": { },
Type: schema.TypeString, "user": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
} },
return res }
} return res
}
func DataSourceAccountAuditsList() *schema.Resource {
return &schema.Resource{ func DataSourceAccountAuditsList() *schema.Resource {
SchemaVersion: 1, return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountAuditsListRead,
ReadContext: dataSourceAccountAuditsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, Timeouts: &schema.ResourceTimeout{
Default: &constants.Timeout60s, Read: &constants.Timeout30s,
}, Default: &constants.Timeout60s,
},
Schema: dataSourceAccountAuditsListSchemaMake(),
} Schema: dataSourceAccountAuditsListSchemaMake(),
} }
}

View File

@@ -1,202 +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 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 { 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountComputesList(accountComputesList)) d.SetId(id.String())
d.Set("items", flattenAccountComputesList(accountComputesList))
return nil d.Set("entry_count", accountComputesList.EntryCount)
}
return nil
func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountComputesListSchemaMake() 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,
"items": { Description: "ID of the account",
Type: schema.TypeList, },
Computed: true, "compute_id": {
Description: "Search Result", Type: schema.TypeInt,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "Filter by compute ID",
"account_id": { },
Type: schema.TypeInt, "name": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"account_name": { Description: "Filter by compute name",
Type: schema.TypeString, },
Computed: true, "rg_name": {
}, Type: schema.TypeString,
"cpus": { Optional: true,
Type: schema.TypeInt, Description: "Filter by RG name",
Computed: true, },
}, "rg_id": {
"created_by": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by RG ID",
}, },
"created_time": { "tech_status": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by tech. status",
"deleted_by": { },
Type: schema.TypeString, "ip_address": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"deleted_time": { Description: "Filter by IP address",
Type: schema.TypeInt, },
Computed: true, "extnet_name": {
}, Type: schema.TypeString,
"compute_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by extnet name",
Computed: true, },
}, "extnet_id": {
"compute_name": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by extnet ID",
}, },
"ram": { "sort_by": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "sort by one of supported fields, format +|-(field)",
"registered": { },
Type: schema.TypeBool, "page": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"rg_id": { Description: "Page number",
Type: schema.TypeInt, },
Computed: true, "size": {
}, Type: schema.TypeInt,
"rg_name": { Optional: true,
Type: schema.TypeString, Description: "Page size",
Computed: true, },
}, "items": {
"status": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Description: "Search Result",
}, Elem: &schema.Resource{
"tech_status": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"total_disks_size": { },
Type: schema.TypeInt, "account_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_by": { },
Type: schema.TypeString, "cpus": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, "created_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"user_managed": { },
Type: schema.TypeBool, "created_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"vins_connected": { },
Type: schema.TypeInt, "deleted_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, "deleted_time": {
}, Type: schema.TypeInt,
} Computed: true,
return res },
} "compute_id": {
Type: schema.TypeInt,
func DataSourceAccountComputesList() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, "compute_name": {
Type: schema.TypeString,
ReadContext: dataSourceAccountComputesListRead, Computed: true,
},
Timeouts: &schema.ResourceTimeout{ "ram": {
Read: &constants.Timeout30s, Type: schema.TypeInt,
Default: &constants.Timeout60s, Computed: true,
}, },
"registered": {
Schema: dataSourceAccountComputesListSchemaMake(), Type: schema.TypeBool,
} Computed: true,
} },
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"total_disks_size": {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
"vins_connected": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountComputesList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountComputesListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountComputesListSchemaMake(),
}
}

View File

@@ -1,110 +1,116 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("cu_c", accountConsumedUnits.CUC) d.SetId(id.String())
d.Set("cu_d", accountConsumedUnits.CUD) d.Set("cu_c", accountConsumedUnits.CUC)
d.Set("cu_i", accountConsumedUnits.CUI) d.Set("cu_d", accountConsumedUnits.CUD)
d.Set("cu_m", accountConsumedUnits.CUM) d.Set("cu_dm", accountConsumedUnits.CUDM)
d.Set("cu_np", accountConsumedUnits.CUNP) d.Set("cu_i", accountConsumedUnits.CUI)
d.Set("gpu_units", accountConsumedUnits.GPUUnits) d.Set("cu_m", accountConsumedUnits.CUM)
d.Set("cu_np", accountConsumedUnits.CUNP)
return nil d.Set("gpu_units", accountConsumedUnits.GPUUnits)
}
return nil
func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Required: true, "account_id": {
Description: "ID of the account", Type: schema.TypeInt,
}, Required: true,
"cu_c": { Description: "ID of the account",
Type: schema.TypeFloat, },
Computed: true, "cu_c": {
}, Type: schema.TypeFloat,
"cu_d": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_d": {
}, Type: schema.TypeFloat,
"cu_i": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_dm": {
}, Type: schema.TypeFloat,
"cu_m": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_i": {
}, Type: schema.TypeFloat,
"cu_np": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_m": {
}, Type: schema.TypeFloat,
"gpu_units": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_np": {
}, Type: schema.TypeFloat,
} Computed: true,
return res },
} "gpu_units": {
Type: schema.TypeFloat,
func DataSourceAccountConsumedUnits() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, }
return res
ReadContext: dataSourceAccountConsumedUnitsRead, }
Timeouts: &schema.ResourceTimeout{ func DataSourceAccountConsumedUnits() *schema.Resource {
Read: &constants.Timeout30s, return &schema.Resource{
Default: &constants.Timeout60s, SchemaVersion: 1,
},
ReadContext: dataSourceAccountConsumedUnitsRead,
Schema: dataSourceAccountConsumedUnitsSchemaMake(),
} Timeouts: &schema.ResourceTimeout{
} Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountConsumedUnitsSchemaMake(),
}
}

View File

@@ -1,90 +1,91 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("cu_result", result) d.SetId(id.String())
d.Set("cu_result", result)
return nil
} return nil
}
func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceAccountConsumedUnitsByTypeSchemaMake() 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_type": { },
Type: schema.TypeString, "cu_type": {
Required: true, Type: schema.TypeString,
Description: "cloud unit resource type", Required: true,
}, Description: "cloud unit resource type",
"cu_result": { },
Type: schema.TypeFloat, "cu_result": {
Computed: true, Type: schema.TypeFloat,
}, Computed: true,
} },
return res }
} return res
}
func DataSourceAccountConsumedUnitsByType() *schema.Resource {
return &schema.Resource{ func DataSourceAccountConsumedUnitsByType() *schema.Resource {
SchemaVersion: 1, return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, Timeouts: &schema.ResourceTimeout{
Default: &constants.Timeout60s, Read: &constants.Timeout30s,
}, Default: &constants.Timeout60s,
},
Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),
} Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),
} }
}

View File

@@ -1,70 +1,78 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountList(accountDeletedList)) d.SetId(id.String())
d.Set("items", flattenAccountList(accountDeletedList))
return nil d.Set("entry_count", accountDeletedList.EntryCount)
}
return nil
func DataSourceAccountDeletedList() *schema.Resource { }
return &schema.Resource{
SchemaVersion: 1, func dataSourceAccountDeletedListSchemaMake() map[string]*schema.Schema {
temp := dataSourceAccountListSchemaMake()
ReadContext: dataSourceAccountDeletedListRead, delete(temp, "status")
return temp
Timeouts: &schema.ResourceTimeout{ }
Read: &constants.Timeout30s,
Default: &constants.Timeout60s, func DataSourceAccountDeletedList() *schema.Resource {
}, return &schema.Resource{
SchemaVersion: 1,
Schema: dataSourceAccountListSchemaMake(),
} ReadContext: dataSourceAccountDeletedListRead,
}
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountDeletedListSchemaMake(),
}
}

View File

@@ -1,136 +1,177 @@
/* /*
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 { 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountDisksList(accountDisksList)) d.SetId(id.String())
d.Set("items", flattenAccountDisksList(accountDisksList))
return nil d.Set("entry_count", accountDisksList.EntryCount)
}
return nil
func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountDisksListSchemaMake() 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,
"items": { Description: "ID of the account",
Type: schema.TypeList, },
Computed: true, "disk_id": {
Description: "Search Result", Type: schema.TypeInt,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "Filter by disk ID",
"disk_id": { },
Type: schema.TypeInt, "name": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"disk_name": { Description: "Filter by disk name",
Type: schema.TypeString, },
Computed: true, "disk_max_size": {
}, Type: schema.TypeInt,
"pool": { Optional: true,
Type: schema.TypeString, Description: "Filter by disk max size",
Computed: true, },
}, "type": {
"sep_id": { Type: schema.TypeString,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Filter by disk type",
}, },
"shareable": { "sort_by": {
Type: schema.TypeBool, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "sort by one of supported fields, format +|-(field)",
"size_max": { },
Type: schema.TypeInt, "page": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"type": { Description: "Page number",
Type: schema.TypeString, },
Computed: true, "size": {
}, Type: schema.TypeInt,
}, Optional: true,
}, Description: "Page size",
}, },
} "items": {
return res Type: schema.TypeList,
} Computed: true,
Description: "Search Result",
func DataSourceAccountDisksList() *schema.Resource { Elem: &schema.Resource{
return &schema.Resource{ Schema: map[string]*schema.Schema{
SchemaVersion: 1, "disk_id": {
Type: schema.TypeInt,
ReadContext: dataSourceAccountDisksListRead, Computed: true,
},
Timeouts: &schema.ResourceTimeout{ "disk_name": {
Read: &constants.Timeout30s, Type: schema.TypeString,
Default: &constants.Timeout60s, Computed: true,
}, },
"pool": {
Schema: dataSourceAccountDisksListSchemaMake(), Type: schema.TypeString,
} Computed: true,
} },
"sep_id": {
Type: schema.TypeInt,
Computed: true,
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountDisksList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountDisksListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountDisksListSchemaMake(),
}
}

View File

@@ -1,207 +1,253 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 { 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList)) d.SetId(id.String())
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
return nil d.Set("entry_count", accountFlipGroupsList.EntryCount)
}
return nil
func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountFlipGroupsListSchemaMake() 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,
"items": { Description: "ID of the account",
Type: schema.TypeList, },
Computed: true, "name": {
Description: "Search Result", Type: schema.TypeString,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "Filter by name",
"account_id": { },
Type: schema.TypeInt, "vins_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"client_type": { Description: "Filter by ViNS ID",
Type: schema.TypeString, },
Computed: true, "vins_name": {
}, Type: schema.TypeString,
"conn_type": { Optional: true,
Type: schema.TypeString, Description: "Filter by ViNS name",
Computed: true, },
}, "extnet_id": {
"created_by": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by extnet ID",
}, },
"created_time": { "by_ip": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by IP",
"default_gw": { },
Type: schema.TypeString, "flipgroup_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"deleted_by": { Description: "Filter by flipgroup ID",
Type: schema.TypeString, },
Computed: true, "page": {
}, Type: schema.TypeInt,
"deleted_time": { Optional: true,
Type: schema.TypeInt, Description: "Page number",
Computed: true, },
}, "size": {
"desc": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Page size",
}, },
"gid": { "items": {
Type: schema.TypeInt, Type: schema.TypeList,
Computed: true, Computed: true,
}, Description: "Search Result",
"guid": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "account_id": {
}, Type: schema.TypeInt,
"fg_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "client_type": {
}, Type: schema.TypeString,
"ip": { Computed: true,
Type: schema.TypeString, },
Computed: true, "conn_type": {
}, Type: schema.TypeString,
"milestones": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_by": {
}, Type: schema.TypeString,
"fg_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "created_time": {
}, Type: schema.TypeInt,
"net_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "default_gw": {
}, Type: schema.TypeString,
"net_type": { Computed: true,
Type: schema.TypeString, },
Computed: true, "deleted_by": {
}, Type: schema.TypeString,
"netmask": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "deleted_time": {
}, Type: schema.TypeInt,
"status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "desc": {
}, Type: schema.TypeString,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "gid": {
}, Type: schema.TypeInt,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "guid": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "fg_id": {
} Type: schema.TypeInt,
return res Computed: true,
} },
"ip": {
func DataSourceAccountFlipGroupsList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"milestones": {
ReadContext: dataSourceAccountFlipGroupsListRead, Type: schema.TypeInt,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "fg_name": {
Default: &constants.Timeout60s, Type: schema.TypeString,
}, Computed: true,
},
Schema: dataSourceAccountFlipGroupsListSchemaMake(), "net_id": {
} Type: schema.TypeInt,
} Computed: true,
},
"net_type": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountFlipGroupsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountFlipGroupsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
}
}

View File

@@ -0,0 +1,137 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenResourceConsumption(d, accountResourceConsumptionRec)
return nil
}
func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceResourceLimitsSchemaMake(),
},
},
}
return res
}
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cu_c": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_d": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_dm": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_i": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_m": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_np": {
Type: schema.TypeFloat,
Computed: true,
},
"gpu_units": {
Type: schema.TypeFloat,
Computed: true,
},
}
return res
}
func DataSourceAccountResourceConsumptionGet() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountResourceConsumptionGetRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountResourceConsumptionGetSchemaMake(),
}
}

View File

@@ -1,184 +1,223 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 { for _, acc := range al.Data {
temp := map[string]interface{}{ temp := map[string]interface{}{
"acl": flattenRgAcl(acc.ACL), "acl": flattenRgAcl(acc.ACL),
"created_time": acc.CreatedTime, "compute_features": acc.ComputeFeatures,
"deleted_time": acc.DeletedTime, "created_time": acc.CreatedTime,
"account_id": acc.ID, "deleted_time": acc.DeletedTime,
"account_name": acc.Name, "account_id": acc.ID,
"status": acc.Status, "account_name": acc.Name,
"updated_time": acc.UpdatedTime, "status": acc.Status,
} "updated_time": acc.UpdatedTime,
res = append(res, temp) }
} res = append(res, temp)
return res }
} return res
}
func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func flattenRgAcl(rgAcls []account.RecordACL) []map[string]interface{} {
for _, rgAcl := range rgAcls { res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ for _, rgAcl := range rgAcls {
"explicit": rgAcl.IsExplicit, temp := map[string]interface{}{
"guid": rgAcl.GUID, "explicit": rgAcl.IsExplicit,
"right": rgAcl.Rights, "guid": rgAcl.GUID,
"status": rgAcl.Status, "right": rgAcl.Rights,
"type": rgAcl.Type, "status": rgAcl.Status,
"user_group_id": rgAcl.UgroupID, "type": rgAcl.Type,
} "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 {
accountList, err := utilityAccountListCheckPresence(ctx, d, m) func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { accountList, err := utilityAccountListCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String())
d.Set("items", flattenAccountList(accountList)) id := uuid.New()
d.SetId(id.String())
return nil d.Set("items", flattenAccountList(accountList))
} d.Set("entry_count", accountList.EntryCount)
func dataSourceAccountListSchemaMake() map[string]*schema.Schema { return nil
res := map[string]*schema.Schema{ }
"page": {
Type: schema.TypeInt, func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Optional: true, res := map[string]*schema.Schema{
Description: "Page number", "by_id": {
}, Type: schema.TypeInt,
"size": { Optional: true,
Type: schema.TypeInt, Description: "Filter by ID",
Optional: true, },
Description: "Page size", "name": {
}, Type: schema.TypeString,
"items": { Optional: true,
Type: schema.TypeList, Description: "Filter by name",
Computed: true, },
Elem: &schema.Resource{ "acl": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"acl": { Optional: true,
Type: schema.TypeList, Description: "Filter by ACL",
Computed: true, },
Elem: &schema.Resource{ "status": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"explicit": { Optional: true,
Type: schema.TypeBool, Description: "Filter by status",
Computed: true, },
}, "sort_by": {
"guid": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "sort by one of supported fields, format +|-(field)",
}, },
"right": { "page": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page number",
"status": { },
Type: schema.TypeString, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"type": { Description: "Page size",
Type: schema.TypeString, },
Computed: true, "items": {
}, Type: schema.TypeList,
"user_group_id": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "acl": {
}, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Resource{
"created_time": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "explicit": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
"deleted_time": { },
Type: schema.TypeInt, "guid": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"account_id": { },
Type: schema.TypeInt, "right": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"account_name": { },
Type: schema.TypeString, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"status": { },
Type: schema.TypeString, "type": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, "user_group_id": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
} },
return res "compute_features": {
} Type: schema.TypeList,
Computed: true,
func DataSourceAccountList() *schema.Resource { Elem: &schema.Schema{
return &schema.Resource{ Type: schema.TypeString,
SchemaVersion: 1, },
},
ReadContext: dataSourceAccountListRead, "created_time": {
Type: schema.TypeInt,
Timeouts: &schema.ResourceTimeout{ Computed: true,
Read: &constants.Timeout30s, },
Default: &constants.Timeout60s, "deleted_time": {
}, Type: schema.TypeInt,
Computed: true,
Schema: dataSourceAccountListSchemaMake(), },
} "account_id": {
} Type: schema.TypeInt,
Computed: true,
},
"account_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountListSchemaMake(),
}
}

View File

@@ -1,110 +1,116 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("cu_c", accountReservedUnits.CUC) d.SetId(id.String())
d.Set("cu_d", accountReservedUnits.CUD) d.Set("cu_c", accountReservedUnits.CUC)
d.Set("cu_i", accountReservedUnits.CUI) d.Set("cu_d", accountReservedUnits.CUD)
d.Set("cu_m", accountReservedUnits.CUM) d.Set("cu_dm", accountReservedUnits.CUDM)
d.Set("cu_np", accountReservedUnits.CUNP) d.Set("cu_i", accountReservedUnits.CUI)
d.Set("gpu_units", accountReservedUnits.GPUUnits) d.Set("cu_m", accountReservedUnits.CUM)
d.Set("cu_np", accountReservedUnits.CUNP)
return nil d.Set("gpu_units", accountReservedUnits.GPUUnits)
}
return nil
func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Required: true, "account_id": {
Description: "ID of the account", Type: schema.TypeInt,
}, Required: true,
"cu_c": { Description: "ID of the account",
Type: schema.TypeFloat, },
Computed: true, "cu_c": {
}, Type: schema.TypeFloat,
"cu_d": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_d": {
}, Type: schema.TypeFloat,
"cu_i": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_dm": {
}, Type: schema.TypeFloat,
"cu_m": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_i": {
}, Type: schema.TypeFloat,
"cu_np": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_m": {
}, Type: schema.TypeFloat,
"gpu_units": { Computed: true,
Type: schema.TypeFloat, },
Computed: true, "cu_np": {
}, Type: schema.TypeFloat,
} Computed: true,
return res },
} "gpu_units": {
Type: schema.TypeFloat,
func DataSourceAccountReservedUnits() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, }
return res
ReadContext: dataSourceAccountReservedUnitsRead, }
Timeouts: &schema.ResourceTimeout{ func DataSourceAccountReservedUnits() *schema.Resource {
Read: &constants.Timeout30s, return &schema.Resource{
Default: &constants.Timeout60s, SchemaVersion: 1,
},
ReadContext: dataSourceAccountReservedUnitsRead,
Schema: dataSourceAccountReservedUnitsSchemaMake(),
} Timeouts: &schema.ResourceTimeout{
} Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountReservedUnitsSchemaMake(),
}
}

View File

@@ -0,0 +1,170 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccResourceConsumption(accountResourceConsumptionList))
d.Set("entry_count", accountResourceConsumptionList.EntryCount)
return nil
}
func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeString,
Computed: true,
},
"data_name": {
Type: schema.TypeString,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeFloat,
Computed: true,
},
}
return res
}
func dataSourceAccResourceSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeFloat,
Computed: true,
},
"ext_ips": {
Type: schema.TypeInt,
Computed: true,
},
"ext_traffic": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"seps": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceSepsSchemaMake(),
},
},
}
return res
}
func DataSourceAccountResourceConsumptionList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountResourceConsumptionListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountResourceConsumptionListSchemaMake(),
}
}

View File

@@ -1,331 +1,377 @@
/* /*
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 { 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountRGList(accountRGList)) d.SetId(id.String())
d.Set("items", flattenAccountRGList(accountRGList))
return nil d.Set("entry_count", accountRGList.EntryCount)
}
return nil
func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceAccountRGListSchemaMake() 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,
"items": { Description: "ID of the account",
Type: schema.TypeList, },
Computed: true, "sort_by": {
Description: "Search Result", Type: schema.TypeString,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "sort by one of supported fields, format +|-(field)",
"computes": { },
Type: schema.TypeList, "page": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "Page number",
"started": { },
Type: schema.TypeInt, "size": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"stopped": { Description: "Page size",
Type: schema.TypeInt, },
Computed: true, "rg_id": {
}, Type: schema.TypeInt,
}, Optional: true,
}, Description: "Filter by RG ID",
}, },
"resources": { "vins_id": {
Type: schema.TypeList, Type: schema.TypeInt,
Computed: true, Optional: true,
Elem: &schema.Resource{ Description: "Filter by ViNS ID",
Schema: map[string]*schema.Schema{ },
"consumed": { "vm_id": {
Type: schema.TypeList, Type: schema.TypeInt,
Computed: true, Optional: true,
Elem: &schema.Resource{ Description: "Filter by VM ID",
Schema: map[string]*schema.Schema{ },
"cpu": { "name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by name",
"disksize": { },
Type: schema.TypeInt, "status": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"extips": { Description: "Filter by status",
Type: schema.TypeInt, },
Computed: true, "items": {
}, Type: schema.TypeList,
"exttraffic": { Computed: true,
Type: schema.TypeInt, Description: "Search Result",
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"gpu": { "computes": {
Type: schema.TypeInt, Type: schema.TypeList,
Computed: true, Computed: true,
}, Elem: &schema.Resource{
"ram": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "started": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "stopped": {
}, Type: schema.TypeInt,
Computed: true,
"limits": { },
Type: schema.TypeList, },
Computed: true, },
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "resources": {
"cpu": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"disksize": { "consumed": {
Type: schema.TypeInt, Type: schema.TypeList,
Computed: true, Computed: true,
}, Elem: &schema.Resource{
"extips": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "cpu": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"exttraffic": { },
Type: schema.TypeInt, "disksize": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"gpu": { },
Type: schema.TypeInt, "extips": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"ram": { },
Type: schema.TypeInt, "exttraffic": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "gpu": {
}, Type: schema.TypeInt,
"reserved": { Computed: true,
Type: schema.TypeList, },
Computed: true, "ram": {
Elem: &schema.Resource{ Type: schema.TypeInt,
Schema: map[string]*schema.Schema{ Computed: true,
"cpu": { },
Type: schema.TypeInt, },
Computed: true, },
}, },
"disksize": {
Type: schema.TypeInt, "limits": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"extips": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "cpu": {
}, Type: schema.TypeInt,
"exttraffic": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "disksize": {
}, Type: schema.TypeInt,
"gpu": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "extips": {
}, Type: schema.TypeInt,
"ram": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "exttraffic": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "gpu": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
"ram": {
"created_by": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"created_time": { },
Type: schema.TypeInt, },
Computed: true, "reserved": {
}, Type: schema.TypeList,
"deleted_by": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "cpu": {
"deleted_time": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "disksize": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "extips": {
"milestones": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "exttraffic": {
"rg_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "gpu": {
"status": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "ram": {
"updated_by": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"updated_time": { },
Type: schema.TypeInt, },
Computed: true, },
}, },
"vinses": { },
Type: schema.TypeInt,
Computed: true, "created_by": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, "created_time": {
} Type: schema.TypeInt,
return res Computed: true,
} },
"deleted_by": {
func DataSourceAccountRGList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Computed: true,
SchemaVersion: 1, },
"deleted_time": {
ReadContext: dataSourceAccountRGListRead, Type: schema.TypeInt,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "rg_id": {
Default: &constants.Timeout60s, Type: schema.TypeInt,
}, Computed: true,
},
Schema: dataSourceAccountRGListSchemaMake(), "milestones": {
} Type: schema.TypeInt,
} Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"vinses": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountRGList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountRGListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountRGListSchemaMake(),
}
}

View File

@@ -1,152 +1,191 @@
/* /*
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) res := make([]map[string]interface{}, 0, len(atl.Data))
for _, at := range atl { for _, at := range atl.Data {
temp := map[string]interface{}{ temp := map[string]interface{}{
"unc_path": at.UNCPath, "unc_path": at.UNCPath,
"account_id": at.AccountID, "account_id": at.AccountID,
"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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenAccountTemplatesList(accountTemplatesList)) d.SetId(id.String())
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
return nil d.Set("entry_count", accountTemplatesList.EntryCount)
} return nil
}
func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceAccountTemplatesListSchemaMake() 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",
"items": { },
Type: schema.TypeList, "include_deleted": {
Computed: true, Type: schema.TypeBool,
Description: "Search Result", Optional: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "image_id": {
"unc_path": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Find by image id",
}, },
"account_id": { "name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Optional: true,
}, Description: "Filter by name",
"desc": { },
Type: schema.TypeString, "type": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"template_id": { Description: "Filter by type",
Type: schema.TypeInt, },
Computed: true, "sort_by": {
}, Type: schema.TypeString,
"template_name": { Optional: true,
Type: schema.TypeString, Description: "sort by one of supported fields, format +|-(field)",
Computed: true, },
}, "page": {
"public": { Type: schema.TypeInt,
Type: schema.TypeBool, Optional: true,
Computed: true, Description: "Page number",
}, },
"size": { "size": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page size",
"status": { },
Type: schema.TypeString, "items": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"type": { Description: "Search Result",
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "unc_path": {
"username": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "account_id": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
} "desc": {
return res Type: schema.TypeString,
} Computed: true,
},
func DataSourceAccountTemplatessList() *schema.Resource { "template_id": {
return &schema.Resource{ Type: schema.TypeInt,
SchemaVersion: 1, Computed: true,
},
ReadContext: dataSourceAccountTemplatesListRead, "template_name": {
Type: schema.TypeString,
Timeouts: &schema.ResourceTimeout{ Computed: true,
Read: &constants.Timeout30s, },
Default: &constants.Timeout60s, "public": {
}, Type: schema.TypeBool,
Computed: true,
Schema: dataSourceAccountTemplatesListSchemaMake(), },
} "size": {
} Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"username": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountTemplatessList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountTemplatesListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountTemplatesListSchemaMake(),
}
}

View File

@@ -1,187 +1,238 @@
/* /*
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 { 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,
"vin_id": av.ID, "extnet_id": av.ExtnetId,
"vin_name": av.Name, "free_ips": av.FreeIPs,
"network": av.Network, "vin_id": av.ID,
"pri_vnf_dev_id": av.PriVNFDevID, "vin_name": av.Name,
"rg_id": av.RGID, "network": av.Network,
"rg_name": av.RGName, "pri_vnf_dev_id": av.PriVNFDevID,
"status": av.Status, "rg_id": av.RGID,
"updated_by": av.UpdatedBy, "rg_name": av.RGName,
"updated_time": av.UpdatedTime, "status": av.Status,
} "updated_by": av.UpdatedBy,
res = append(res, temp) "updated_time": av.UpdatedTime,
} }
return res res = append(res, temp)
}
} return res
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { }
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
if err != nil { func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return diag.FromErr(err) accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
} if err != nil {
d.SetId("")
id := uuid.New() return diag.FromErr(err)
d.SetId(id.String()) }
d.Set("items", flattenAccountVinsList(accountVinsList))
id := uuid.New()
return nil d.SetId(id.String())
} d.Set("items", flattenAccountVinsList(accountVinsList))
d.Set("entry_count", accountVinsList.EntryCount)
func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ return nil
"account_id": { }
Type: schema.TypeInt,
Required: true, func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
Description: "ID of the account", res := map[string]*schema.Schema{
}, "account_id": {
"items": { Type: schema.TypeInt,
Type: schema.TypeList, Required: true,
Computed: true, Description: "ID of the account",
Description: "Search Result", },
Elem: &schema.Resource{ "vins_id": {
Schema: map[string]*schema.Schema{ Type: schema.TypeInt,
"account_id": { Optional: true,
Type: schema.TypeInt, Description: "Filter by ViNS ID",
Computed: true, },
}, "name": {
"account_name": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Filter by name",
}, },
"computes": { "rg_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Filter by RG ID",
"created_by": { },
Type: schema.TypeString, "ext_ip": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"created_time": { Description: "Filter by external IP",
Type: schema.TypeInt, },
Computed: true, "sort_by": {
}, Type: schema.TypeString,
"deleted_by": { Optional: true,
Type: schema.TypeString, Description: "sort by one of supported fields, format +|-(field)",
Computed: true, },
}, "page": {
"deleted_time": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Page number",
}, },
"external_ip": { "size": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "Page size",
"vin_id": { },
Type: schema.TypeInt, "items": {
Computed: true, Type: schema.TypeList,
}, Computed: true,
"vin_name": { Description: "Search Result",
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "account_id": {
"network": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "account_name": {
"pri_vnf_dev_id": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "computes": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "created_by": {
"rg_name": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "created_time": {
"status": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "deleted_by": {
"updated_by": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "deleted_time": {
"updated_time": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "external_ip": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
} "extnet_id": {
return res Type: schema.TypeInt,
} Computed: true,
},
func DataSourceAccountVinsList() *schema.Resource { "free_ips": {
return &schema.Resource{ Type: schema.TypeInt,
SchemaVersion: 1, Computed: true,
},
ReadContext: dataSourceAccountVinsListRead, "vin_id": {
Type: schema.TypeInt,
Timeouts: &schema.ResourceTimeout{ Computed: true,
Read: &constants.Timeout30s, },
Default: &constants.Timeout60s, "vin_name": {
}, Type: schema.TypeString,
Computed: true,
Schema: dataSourceAccountVinsListSchemaMake(), },
} "network": {
} Type: schema.TypeString,
Computed: true,
},
"pri_vnf_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceAccountVinsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountVinsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountVinsListSchemaMake(),
}
}

View File

@@ -7,11 +7,12 @@ import (
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error { func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("dc_location", acc.DCLocation) d.Set("dc_location", acc.DCLocation)
d.Set("resources", flattenAccResources(acc.Resources)) // d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey) d.Set("ckey", acc.CKey)
d.Set("acl", flattenAccAcl(acc.ACL)) d.Set("acl", flattenAccAcl(acc.ACL))
d.Set("company", acc.Company) d.Set("company", acc.Company)
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)
@@ -21,7 +22,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("guid", acc.GUID) d.Set("guid", acc.GUID)
d.Set("account_id", acc.ID) d.Set("account_id", acc.ID)
d.Set("account_name", acc.Name) d.Set("account_name", acc.Name)
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits)) d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails) d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status) d.Set("status", acc.Status)
d.Set("updated_time", acc.UpdatedTime) d.Set("updated_time", acc.UpdatedTime)
@@ -79,11 +80,19 @@ func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
return res return res
} }
func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} { func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
d.Set("account_id", acc.AccountID)
d.Set("consumed", flattenAccResource(acc.Consumed))
d.Set("reserved", flattenAccResource(acc.Reserved))
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
}
func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ temp := map[string]interface{}{
"cu_c": rl.CUC, "cu_c": rl.CUC,
"cu_d": rl.CUD, "cu_d": rl.CUD,
"cu_dm": rl.CUDM,
"cu_i": rl.CUI, "cu_i": rl.CUI,
"cu_m": rl.CUM, "cu_m": rl.CUM,
"cu_np": rl.CUNP, "cu_np": rl.CUNP,
@@ -95,15 +104,15 @@ func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{}
} }
func flattenAccResources(r account.Resources) []map[string]interface{} { // func flattenAccResources(r account.Resources) []map[string]interface{} {
res := make([]map[string]interface{}, 0) // res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ // temp := map[string]interface{}{
"current": flattenAccResource(r.Current), // "current": flattenAccResource(r.Current),
"reserved": flattenAccResource(r.Reserved), // "reserved": flattenAccResource(r.Reserved),
} // }
res = append(res, temp) // res = append(res, temp)
return res // return res
} // }
func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} { func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
@@ -124,14 +133,28 @@ func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[stri
func flattenAccResource(r account.Resource) []map[string]interface{} { func flattenAccResource(r account.Resource) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ temp := map[string]interface{}{
"cpu": r.CPU, "cpu": r.CPU,
"disksize": r.DiskSize, "disk_size": r.DiskSize,
"extips": r.ExtIPs, "disk_size_max": r.DiskSizeMax,
"exttraffic": r.ExtTraffic, "ext_ips": r.ExtIPs,
"gpu": r.GPU, "ext_traffic": r.ExtTraffic,
"ram": r.RAM, "gpu": r.GPU,
"seps": flattenAccountSeps(r.SEPs), "ram": r.RAM,
"seps": flattenAccountSeps(r.SEPs),
} }
res = append(res, temp) res = append(res, temp)
return res return res
} }
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lrc.Data))
for _, rc := range lrc.Data {
temp := map[string]interface{}{
"consumed": flattenAccResource(rc.Consumed),
"reserved": flattenAccResource(rc.Reserved),
"account_id": rc.AccountID,
}
res = append(res, temp)
}
return res
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,62 +1,106 @@
/* /*
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,
} }
log.Debugf("utilityAccountComputesListCheckPresence: load account list") if compute_id, ok := d.GetOk("compute_id"); ok {
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req) req.ComputeID = uint64(compute_id.(int))
if err != nil { }
return nil, err
} if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
return accountComputesList, nil }
}
if rg_name, ok := d.GetOk("rg_name"); ok {
req.RGName = rg_name.(string)
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if ip_address, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ip_address.(string)
}
if extnet_name, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extnet_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
if err != nil {
return nil, err
}
return accountComputesList, nil
}

View File

@@ -1,70 +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 utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListAccounts, error) { func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
var (
pageVal uint64 = 0 req := account.ListDeletedRequest{}
sizeVal uint64 = 0
) if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
if page, ok := d.GetOk("page"); ok { }
pageVal = uint64(page.(int))
} if size, ok := d.GetOk("size"); ok {
if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int))
sizeVal = uint64(size.(int)) }
}
if by_id, ok := d.GetOk("by_id"); ok {
req := account.ListDeletedRequest{ req.ByID = uint64(by_id.(int))
Page: pageVal, }
Size: sizeVal,
} if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
log.Debugf("utilityAccountDeletedListCheckPresence: load") }
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
if err != nil { if name, ok := d.GetOk("name"); ok {
return nil, err req.Name = name.(string)
} }
return accountDeletedList, nil
} if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return accountDeletedList, nil
}

View File

@@ -1,60 +1,88 @@
/* /*
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,
} }
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req) if disk_id, ok := d.GetOk("disk_id"); ok {
if err != nil { req.DiskID = uint64(disk_id.(int))
return nil, err }
}
if name, ok := d.GetOk("name"); ok {
return accountDisksList, nil req.Name = name.(string)
} }
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = uint64(disk_max_size.(int))
}
if typeVal, ok := d.GetOk("type"); ok {
req.Type = typeVal.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
if err != nil {
return nil, err
}
return accountDisksList, nil
}

View File

@@ -42,7 +42,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (account.ListFLIPGroups, error) { func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListFLIPGroups, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
var id uint64 var id uint64
@@ -52,6 +52,38 @@ func utilityAccountFlipGroupsListCheckPresence(ctx context.Context, d *schema.Re
AccountID: id, AccountID: id,
} }
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vins_name, ok := d.GetOk("vins_name"); ok {
req.VINSName = vins_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if by_ip, ok := d.GetOk("by_ip"); ok {
req.ByIP = by_ip.(string)
}
if flipgroup_id, ok := d.GetOk("flipgroup_id"); ok {
req.FLIPGroupID = uint64(flipgroup_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountFlipGroupsListCheckPresence") log.Debugf("utilityAccountFlipGroupsListCheckPresence")
accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req) accountFlipGroupsList, err := c.CloudAPI().Account().ListFLIPGroups(ctx, req)
if err != nil { if err != nil {

View File

@@ -0,0 +1,61 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
id := uint64(d.Get("account_id").(int))
req:= account.GetResourceConsumptionRequest {
AccountID: id,
}
log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
accountResourceConsumptionRec, err := c.CloudAPI().Account().GetResourceConsumption(ctx, req)
if err != nil {
return nil, err
}
return accountResourceConsumptionRec, nil
}

View File

@@ -1,71 +1,83 @@
/* /*
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)
var ( req := account.ListRequest{}
pageVal uint64 = 0
sizeVal uint64 = 0 if page, ok := d.GetOk("page"); ok {
) req.Page = uint64(page.(int))
}
if page, ok := d.GetOk("page"); ok { if size, ok := d.GetOk("size"); ok {
pageVal = uint64(page.(int)) req.Size = uint64(size.(int))
} }
if size, ok := d.GetOk("size"); ok {
sizeVal = uint64(size.(int)) if by_id, ok := d.GetOk("by_id"); ok {
} req.ByID = uint64(by_id.(int))
}
req := account.ListRequest{
Page: pageVal, if name, ok := d.GetOk("name"); ok {
Size: sizeVal, req.Name = name.(string)
} }
log.Debugf("utilityAccountListCheckPresence: load account list") if acl, ok := d.GetOk("acl"); ok {
accountList, err := c.CloudAPI().Account().List(ctx, req) req.ACL = acl.(string)
if err != nil { }
return nil, err
} if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
return accountList, nil }
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountListCheckPresence: load account list")
accountList, err := c.CloudAPI().Account().List(ctx, req)
if err != nil {
return nil, err
}
return accountList, nil
}

View File

@@ -0,0 +1,55 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
log.Debugf("utilityAccountResourceConsumptionListCheckPresence: load")
accountResourceConsumptionList, err := c.CloudAPI().Account().ListResourceConsumption(ctx)
if err != nil {
return nil, err
}
return accountResourceConsumptionList, nil
}

View File

@@ -1,62 +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 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,
} }
log.Debugf("utilityAccountRGListCheckPresence: load account list") if page, ok := d.GetOk("page"); ok {
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req) req.Page = uint64(page.(int))
if err != nil { }
return nil, err
} if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
return accountRGList, nil }
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vm_id, ok := d.GetOk("vm_id"); ok {
req.VMID = uint64(vm_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountRGListCheckPresence: load account list")
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
if err != nil {
return nil, err
}
return accountRGList, nil
}

View File

@@ -1,62 +1,83 @@
/* /*
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)
var id uint64
id := uint64(d.Get("account_id").(int))
id = uint64(d.Get("account_id").(int))
req := account.ListTemplatesRequest{
req := account.ListTemplatesRequest{ AccountID: id,
AccountID: id, }
}
if include_deleted, ok := d.GetOk("include_deleted"); ok {
log.Debugf("utilityAccountTemplatesListCheckPresence: load") req.IncludeDeleted = include_deleted.(bool)
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req) }
if err != nil { if imageId, ok := d.GetOk("image_id"); ok {
return nil, err req.ImageID = uint64(imageId.(int))
} }
if name, ok := d.GetOk("name"); ok {
return accountTemplatesList, nil req.Name = name.(string)
} }
if typeTemplates, ok := d.GetOk("type"); ok {
req.Type = typeTemplates.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
if err != nil {
return nil, err
}
return accountTemplatesList, nil
}

View File

@@ -1,62 +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 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,
} }
log.Debugf("utilityAccountVinsListCheckPresence: load account list") if vins_id, ok := d.GetOk("vins_id"); ok {
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req) req.VINSID = uint64(vins_id.(int))
if err != nil { }
return nil, err
} if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
return accountVinsList, nil }
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
if err != nil {
return nil, err
}
return accountVinsList, nil
}

View File

@@ -1,297 +1,298 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} 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 {
res := map[string]*schema.Schema{ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
"service_id": { res := map[string]*schema.Schema{
Type: schema.TypeInt, "service_id": {
Required: true, Type: schema.TypeInt,
}, Required: true,
"account_id": { },
Type: schema.TypeInt, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"account_name": { },
Type: schema.TypeString, "account_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"base_domain": { },
Type: schema.TypeString, "base_domain": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"computes": { },
Type: schema.TypeList, "computes": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"account_id": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"architecture": { },
Type: schema.TypeString, "architecture": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"compgroup_id": { },
Type: schema.TypeInt, "compgroup_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"compgroup_name": { },
Type: schema.TypeString, "compgroup_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"compgroup_role": { },
Type: schema.TypeString, "compgroup_role": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"id": { },
Type: schema.TypeInt, "id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_id": { },
Type: schema.TypeInt, "rg_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"stack_id": { },
Type: schema.TypeInt, "stack_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"name": { },
Type: schema.TypeString, "name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"status": { },
Type: schema.TypeString, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"tech_status": { },
Type: schema.TypeString, "tech_status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
},
"cpu_total": {
Type: schema.TypeInt, "cpu_total": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"created_by": { },
Type: schema.TypeString, "created_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"created_time": { },
Type: schema.TypeInt, "created_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"deleted_by": { },
Type: schema.TypeString, "deleted_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"deleted_time": { },
Type: schema.TypeInt, "deleted_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"disk_total": { },
Type: schema.TypeString, "disk_total": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"gid": { },
Type: schema.TypeInt, "gid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"groups": { },
Type: schema.TypeList, "groups": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"computes": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "computes": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"consistency": { },
Type: schema.TypeBool, "consistency": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
"id": { },
Type: schema.TypeInt, "id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"name": { },
Type: schema.TypeString, "name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"status": { },
Type: schema.TypeString, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"tech_status": { },
Type: schema.TypeString, "tech_status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
"groups_name": { },
Type: schema.TypeList, // "groups_name": {
Computed: true, // Type: schema.TypeList,
Elem: &schema.Schema{ // Computed: true,
Type: schema.TypeString, // Elem: &schema.Schema{
}, // Type: schema.TypeString,
}, // },
"guid": { // },
Type: schema.TypeInt, "guid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"milestones": { },
Type: schema.TypeInt, "milestones": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"service_name": { },
Type: schema.TypeString, "service_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"parent_srv_id": { },
Type: schema.TypeInt, "parent_srv_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"parent_srv_type": { },
Type: schema.TypeString, "parent_srv_type": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"ram_total": { },
Type: schema.TypeInt, "ram_total": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_id": { },
Type: schema.TypeInt, "rg_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_name": { },
Type: schema.TypeString, "rg_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"snapshots": { },
Type: schema.TypeList, "snapshots": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"guid": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "guid": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"label": { },
Type: schema.TypeString, "label": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"timestamp": { },
Type: schema.TypeInt, "timestamp": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"valid": { },
Type: schema.TypeBool, "valid": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
}, },
}, },
}, },
},
"ssh_key": {
Type: schema.TypeString, "ssh_key": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"ssh_user": { },
Type: schema.TypeString, "ssh_user": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"status": { },
Type: schema.TypeString, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"tech_status": { },
Type: schema.TypeString, "tech_status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_by": { },
Type: schema.TypeString, "updated_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, "updated_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"user_managed": { },
Type: schema.TypeBool, "user_managed": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
} },
return res }
} return res
}
func DataSourceBasicService() *schema.Resource {
return &schema.Resource{ func DataSourceBasicService() *schema.Resource {
SchemaVersion: 1, return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceRead,
ReadContext: dataSourceBasicServiceRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, Timeouts: &schema.ResourceTimeout{
Default: &constants.Timeout60s, Read: &constants.Timeout30s,
}, Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSchemaMake(),
} Schema: dataSourceBasicServiceSchemaMake(),
} }
}

View File

@@ -1,70 +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 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenBasicServiceList(basicServiceDeletedList)) d.SetId(id.String())
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
return nil d.Set("entry_count", basicServiceDeletedList.EntryCount)
}
return nil
func DataSourceBasicServiceDeletedList() *schema.Resource { }
return &schema.Resource{
SchemaVersion: 1, func dataSourceBasicServiceDeletedListSchemaMake() map[string]*schema.Schema {
temp := dataSourceBasicServiceListSchemaMake()
ReadContext: dataSourceBasicServiceDeletedListRead,
delete(temp, "by_id")
Timeouts: &schema.ResourceTimeout{ delete(temp, "name")
Read: &constants.Timeout30s, delete(temp, "rg_name")
Default: &constants.Timeout60s, delete(temp, "status")
}, delete(temp, "tech_status")
delete(temp, "account_name")
Schema: dataSourceBasicServiceListSchemaMake(),
} return temp
} }
func DataSourceBasicServiceDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceDeletedListSchemaMake(),
}
}

View File

@@ -1,304 +1,305 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("account_id", bsg.AccountID) d.SetId(id.String())
d.Set("account_name", bsg.AccountName) d.Set("account_id", bsg.AccountID)
d.Set("computes", flattenBSGroupComputes(bsg.Computes)) d.Set("account_name", bsg.AccountName)
d.Set("consistency", bsg.Consistency) d.Set("computes", flattenBSGroupComputes(bsg.Computes))
d.Set("cpu", bsg.CPU) d.Set("consistency", bsg.Consistency)
d.Set("created_by", bsg.CreatedBy) d.Set("cpu", bsg.CPU)
d.Set("created_time", bsg.CreatedTime) d.Set("created_by", bsg.CreatedBy)
d.Set("deleted_by", bsg.DeletedBy) d.Set("created_time", bsg.CreatedTime)
d.Set("deleted_time", bsg.DeletedTime) d.Set("deleted_by", bsg.DeletedBy)
d.Set("disk", bsg.Disk) d.Set("deleted_time", bsg.DeletedTime)
d.Set("driver", bsg.Driver) d.Set("disk", bsg.Disk)
d.Set("extnets", bsg.ExtNets) d.Set("driver", bsg.Driver)
d.Set("gid", bsg.GID) d.Set("extnets", bsg.ExtNets)
d.Set("guid", bsg.GUID) d.Set("gid", bsg.GID)
d.Set("image_id", bsg.ImageID) d.Set("guid", bsg.GUID)
d.Set("milestones", bsg.Milestones) d.Set("image_id", bsg.ImageID)
d.Set("compgroup_name", bsg.Name) d.Set("milestones", bsg.Milestones)
d.Set("parents", bsg.Parents) d.Set("compgroup_name", bsg.Name)
d.Set("ram", bsg.RAM) d.Set("parents", bsg.Parents)
d.Set("rg_id", bsg.RGID) d.Set("ram", bsg.RAM)
d.Set("rg_name", bsg.RGName) d.Set("rg_id", bsg.RGID)
d.Set("role", bsg.Role) d.Set("rg_name", bsg.RGName)
d.Set("sep_id", bsg.SEPID) d.Set("role", bsg.Role)
d.Set("seq_no", bsg.SeqNo) d.Set("sep_id", bsg.SEPID)
d.Set("status", bsg.Status) d.Set("seq_no", bsg.SeqNo)
d.Set("tech_status", bsg.TechStatus) d.Set("status", bsg.Status)
d.Set("timeout_start", bsg.TimeoutStart) d.Set("tech_status", bsg.TechStatus)
d.Set("updated_by", bsg.UpdatedBy) d.Set("timeout_start", bsg.TimeoutStart)
d.Set("updated_time", bsg.UpdatedTime) d.Set("updated_by", bsg.UpdatedBy)
d.Set("vinses", bsg.VINSes) d.Set("updated_time", bsg.UpdatedTime)
return nil d.Set("vinses", bsg.VINSes)
} return nil
}
func flattenBSGroupOSUsers(bsgosus bservice.ListOSUsers) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func flattenBSGroupOSUsers(bsgosus bservice.ListOSUsers) []map[string]interface{} {
for _, bsgosu := range bsgosus { res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ for _, bsgosu := range bsgosus {
"login": bsgosu.Login, temp := map[string]interface{}{
"password": bsgosu.Password, "login": bsgosu.Login,
} "password": bsgosu.Password,
res = append(res, temp) }
} res = append(res, temp)
}
return res
} return res
}
func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0) func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]interface{} {
for _, bsgc := range bsgcs { res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ for _, bsgc := range bsgcs {
"id": bsgc.ID, temp := map[string]interface{}{
"ip_addresses": bsgc.IPAddresses, "id": bsgc.ID,
"name": bsgc.Name, "ip_addresses": bsgc.IPAddresses,
"os_users": flattenBSGroupOSUsers(bsgc.OSUsers), "name": bsgc.Name,
} "os_users": flattenBSGroupOSUsers(bsgc.OSUsers),
res = append(res, temp) }
} res = append(res, temp)
return res }
} return res
}
func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
"service_id": { res := map[string]*schema.Schema{
Type: schema.TypeInt, "service_id": {
Required: true, Type: schema.TypeInt,
}, Required: true,
"compgroup_id": { },
Type: schema.TypeInt, "compgroup_id": {
Required: true, Type: schema.TypeInt,
}, Required: true,
"account_id": { },
Type: schema.TypeInt, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"account_name": { },
Type: schema.TypeString, "account_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"computes": { },
Type: schema.TypeList, "computes": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"id": { Schema: map[string]*schema.Schema{
Type: schema.TypeInt, "id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"ip_addresses": { },
Type: schema.TypeList, "ip_addresses": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeString, Elem: &schema.Schema{
}, Type: schema.TypeString,
}, },
"name": { },
Type: schema.TypeString, "name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"os_users": { },
Type: schema.TypeList, "os_users": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"login": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "login": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"password": { },
Type: schema.TypeString, "password": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
}, },
}, },
}, },
}, },
"consistency": { },
Type: schema.TypeBool, "consistency": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
"cpu": { },
Type: schema.TypeInt, "cpu": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"created_by": { },
Type: schema.TypeString, "created_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"created_time": { },
Type: schema.TypeInt, "created_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"deleted_by": { },
Type: schema.TypeString, "deleted_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"deleted_time": { },
Type: schema.TypeInt, "deleted_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"disk": { },
Type: schema.TypeInt, "disk": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"driver": { },
Type: schema.TypeString, "driver": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"extnets": { },
Type: schema.TypeList, "extnets": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeInt, Elem: &schema.Schema{
}, Type: schema.TypeInt,
}, },
"gid": { },
Type: schema.TypeInt, "gid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"guid": { },
Type: schema.TypeInt, "guid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"image_id": { },
Type: schema.TypeInt, "image_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"milestones": { },
Type: schema.TypeInt, "milestones": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"compgroup_name": { },
Type: schema.TypeString, "compgroup_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"parents": { },
Type: schema.TypeList, "parents": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeInt, Elem: &schema.Schema{
}, Type: schema.TypeInt,
}, },
"ram": { },
Type: schema.TypeInt, "ram": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_id": { },
Type: schema.TypeInt, "rg_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"rg_name": { },
Type: schema.TypeString, "rg_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"role": { },
Type: schema.TypeString, "role": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"sep_id": { },
Type: schema.TypeInt, "sep_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"seq_no": { },
Type: schema.TypeInt, "seq_no": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"status": { },
Type: schema.TypeString, "status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"tech_status": { },
Type: schema.TypeString, "tech_status": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"timeout_start": { },
Type: schema.TypeInt, "timeout_start": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"updated_by": { },
Type: schema.TypeString, "updated_by": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, "updated_time": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"vinses": { },
Type: schema.TypeList, "vinses": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Schema{ Computed: true,
Type: schema.TypeInt, Elem: &schema.Schema{
}, Type: schema.TypeInt,
}, },
} },
return res }
} return res
}
func DataSourceBasicServiceGroup() *schema.Resource {
return &schema.Resource{ func DataSourceBasicServiceGroup() *schema.Resource {
SchemaVersion: 1, return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceGroupRead,
ReadContext: dataSourceBasicServiceGroupRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, Timeouts: &schema.ResourceTimeout{
Default: &constants.Timeout60s, Read: &constants.Timeout30s,
}, Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceGroupSchemaMake(),
} Schema: dataSourceBasicServiceGroupSchemaMake(),
} }
}

View File

@@ -1,228 +1,269 @@
/* /*
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 { 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenBasicServiceList(basicServiceList)) d.SetId(id.String())
d.Set("items", flattenBasicServiceList(basicServiceList))
return nil d.Set("entry_count", basicServiceList.EntryCount)
}
return nil
func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Optional: true, "by_id": {
Description: "ID of the account to query for BasicService instances", Type: schema.TypeInt,
}, Optional: true,
"rg_id": { Description: "Filter by ID",
Type: schema.TypeInt, },
Optional: true, "name": {
Description: "ID of the resource group to query for BasicService instances", Type: schema.TypeString,
}, Optional: true,
"page": { Description: "Filter by bservice name",
Type: schema.TypeInt, },
Optional: true, "rg_name": {
Description: "Page number", Type: schema.TypeString,
}, Optional: true,
"size": { Description: "Filter by resource group name",
Type: schema.TypeInt, },
Optional: true, "status": {
Description: "Page size", Type: schema.TypeString,
}, Optional: true,
"items": { Description: "Filter by status",
Type: schema.TypeList, },
Computed: true, "tech_status": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Optional: true,
"account_id": { Description: "Filter by tech status",
Type: schema.TypeInt, },
Computed: true, "account_name": {
}, Type: schema.TypeString,
"account_name": { Optional: true,
Type: schema.TypeString, Description: "Filter by account name",
Computed: true, },
}, "account_id": {
"base_domain": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "ID of the account to query for BasicService instances",
}, },
"created_by": { "rg_id": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Optional: true,
}, Description: "ID of the resource group to query for BasicService instances",
"created_time": { },
Type: schema.TypeInt, "sort_by": {
Computed: true, Type: schema.TypeString,
}, Optional: true,
"deleted_by": { Description: "sort by one of supported fields, format +|-(field)",
Type: schema.TypeString, },
Computed: true, "page": {
}, Type: schema.TypeInt,
"deleted_time": { Optional: true,
Type: schema.TypeInt, Description: "Page number",
Computed: true, },
}, "size": {
"gid": { Type: schema.TypeInt,
Type: schema.TypeInt, Optional: true,
Computed: true, Description: "Page size",
}, },
"groups": { "items": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Schema{ Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
}, "account_id": {
}, Type: schema.TypeInt,
"guid": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "account_name": {
}, Type: schema.TypeString,
"service_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "base_domain": {
}, Type: schema.TypeString,
"service_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "created_by": {
}, Type: schema.TypeString,
"parent_srv_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_time": {
}, Type: schema.TypeInt,
"parent_srv_type": { Computed: true,
Type: schema.TypeString, },
Computed: true, "deleted_by": {
}, Type: schema.TypeString,
"rg_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "deleted_time": {
}, Type: schema.TypeInt,
"rg_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "gid": {
}, Type: schema.TypeInt,
"ssh_user": { Computed: true,
Type: schema.TypeString, },
Computed: true, "groups": {
}, Type: schema.TypeList,
"status": { Computed: true,
Type: schema.TypeString, Elem: &schema.Schema{
Computed: true, Type: schema.TypeInt,
}, },
"tech_status": { },
Type: schema.TypeString, "guid": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"updated_by": { },
Type: schema.TypeString, "service_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"updated_time": { },
Type: schema.TypeInt, "service_name": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"user_managed": { },
Type: schema.TypeBool, "parent_srv_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "parent_srv_type": {
}, Type: schema.TypeString,
} Computed: true,
return res },
} "rg_id": {
Type: schema.TypeInt,
func DataSourceBasicServiceList() *schema.Resource { Computed: true,
return &schema.Resource{ },
SchemaVersion: 1, "rg_name": {
Type: schema.TypeString,
ReadContext: dataSourceBasicServiceListRead, Computed: true,
},
Timeouts: &schema.ResourceTimeout{ "ssh_user": {
Read: &constants.Timeout30s, Type: schema.TypeString,
Default: &constants.Timeout60s, Computed: true,
}, },
"status": {
Schema: dataSourceBasicServiceListSchemaMake(), 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,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceBasicServiceList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceListSchemaMake(),
}
}

View File

@@ -1,105 +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 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList)) d.SetId(id.String())
d.Set("items", flattenBasicServiceSnapshotsList(basicServiceSnapshotList))
return nil d.Set("entry_count", basicServiceSnapshotList.EntryCount)
} return nil
}
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
"service_id": { res := map[string]*schema.Schema{
Type: schema.TypeInt, "service_id": {
Required: true, Type: schema.TypeInt,
Description: "ID of the BasicService instance", Required: true,
}, Description: "ID of the BasicService instance",
"items": { },
Type: schema.TypeList, "items": {
Computed: true, Type: schema.TypeList,
Elem: &schema.Resource{ Computed: true,
Schema: map[string]*schema.Schema{ Elem: &schema.Resource{
"guid": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "guid": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"label": { },
Type: schema.TypeString, "label": {
Computed: true, Type: schema.TypeString,
}, Computed: true,
"timestamp": { },
Type: schema.TypeInt, "timestamp": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
"valid": { },
Type: schema.TypeBool, "valid": {
Computed: true, Type: schema.TypeBool,
}, Computed: true,
}, },
}, },
}, },
} },
return res "entry_count": {
} Type: schema.TypeInt,
Computed: true,
func DataSourceBasicServiceSnapshotList() *schema.Resource { },
return &schema.Resource{ }
SchemaVersion: 1, return res
}
ReadContext: dataSourceBasicServiceSnapshotListRead,
func DataSourceBasicServiceSnapshotList() *schema.Resource {
Timeouts: &schema.ResourceTimeout{ return &schema.Resource{
Read: &constants.Timeout30s, SchemaVersion: 1,
Default: &constants.Timeout60s,
}, ReadContext: dataSourceBasicServiceSnapshotListRead,
Schema: dataSourceBasicServiceSnapshotListSchemaMake(), Timeouts: &schema.ResourceTimeout{
} Read: &constants.Timeout30s,
} Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
}
}

View File

@@ -30,6 +30,7 @@ func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.Reco
d.Set("rg_name", bsg.RGName) d.Set("rg_name", bsg.RGName)
d.Set("role", bsg.Role) d.Set("role", bsg.Role)
d.Set("sep_id", bsg.SEPID) d.Set("sep_id", bsg.SEPID)
d.Set("sep_pool", bsg.PoolName)
d.Set("seq_no", bsg.SeqNo) d.Set("seq_no", bsg.SeqNo)
d.Set("status", bsg.Status) d.Set("status", bsg.Status)
d.Set("tech_status", bsg.TechStatus) d.Set("tech_status", bsg.TechStatus)
@@ -110,7 +111,7 @@ func flattenBasicServiceComputes(bscs bservice.ListComputes) []map[string]interf
} }
func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} { func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(bsrvss))
for _, bsrvs := range bsrvss { for _, bsrvs := range bsrvss {
temp := map[string]interface{}{ temp := map[string]interface{}{
"guid": bsrvs.GUID, "guid": bsrvs.GUID,
@@ -122,3 +123,17 @@ func flattenBasicServiceSnapshots(bsrvss bservice.ListSnapshots) []map[string]in
} }
return res return res
} }
func flattenBasicServiceSnapshotsList(bsrvss *bservice.ListInfoSnapshots) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(bsrvss.Data))
for _, bsrvs := range bsrvss.Data {
temp := map[string]interface{}{
"guid": bsrvs.GUID,
"label": bsrvs.Label,
"timestamp": bsrvs.Timestamp,
"valid": bsrvs.Valid,
}
res = append(res, temp)
}
return res
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -20,5 +20,5 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
rgId := uint64(d.Get("rg_id").(int)) rgId := uint64(d.Get("rg_id").(int))
return len(rgList.FilterByID(rgId)) != 0, nil return len(rgList.FilterByID(rgId).Data) != 0, nil
} }

View File

@@ -1,69 +1,73 @@
/* /*
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.ListRequest{} req := bservice.ListDeletedRequest{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int)) req.AccountID = uint64(accountId.(int))
} }
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 {
req.Page = uint64(page.(int)) if sortBy, ok := d.GetOk("sort_by"); ok {
} req.SortBy = sortBy.(string)
if size, ok := d.GetOk("size"); ok { }
req.Size = uint64(size.(int)) if page, ok := d.GetOk("page"); ok {
} req.Page = uint64(page.(int))
}
log.Debugf("utilityBasicServiceDeletedListCheckPresence") if size, ok := d.GetOk("size"); ok {
basicServiceDeletedList, err := c.CloudAPI().BService().ListDeleted(ctx, req) req.Size = uint64(size.(int))
if err != nil { }
return nil, err
} log.Debugf("utilityBasicServiceDeletedListCheckPresence")
basicServiceDeletedList, err := c.CloudAPI().BService().ListDeleted(ctx, req)
return basicServiceDeletedList, nil if err != nil {
} return nil, err
}
return basicServiceDeletedList, nil
}

View File

@@ -1,69 +1,96 @@
/* /*
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 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("utilityBasicServiceListCheckPresence") req.Size = uint64(size.(int))
basicServiceList, err := c.CloudAPI().BService().List(ctx, req) }
if err != nil {
return nil, err if by_id, ok := d.GetOk("by_id"); ok {
} req.ByID = uint64(by_id.(int))
}
return basicServiceList, nil
} if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if rg_name, ok := d.GetOk("rg_name"); ok {
req.RGName = rg_name.(string)
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if acc_name, ok := d.GetOk("account_name"); ok {
req.AccountName = acc_name.(string)
}
log.Debugf("utilityBasicServiceListCheckPresence")
basicServiceList, err := c.CloudAPI().BService().List(ctx, req)
if err != nil {
return nil, err
}
return basicServiceList, nil
}

View File

@@ -42,7 +42,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListSnapshots, error) { func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListInfoSnapshots, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
var id uint64 var id uint64

View File

@@ -47,6 +47,7 @@ import (
func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -293,6 +294,39 @@ 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,

View File

@@ -1,454 +1,538 @@
/* /*
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"
"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 dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
diskList, err := utilityDiskListCheckPresence(ctx, d, m) diskList, err := utilityDiskListCheckPresence(ctx, d, m)
if err != nil { if err != nil {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenDiskList(diskList)) d.SetId(id.String())
d.Set("items", flattenDiskList(diskList))
return nil d.Set("entry_count", diskList.EntryCount)
}
return nil
func dataSourceDiskListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Optional: true, "by_id": {
Description: "ID of the account the disks belong to", Type: schema.TypeInt,
}, Optional: true,
"type": { Description: "Find by ID",
Type: schema.TypeString, },
Optional: true, "name": {
Description: "type of the disks", Type: schema.TypeString,
}, Optional: true,
"page": { Description: "Find by name",
Type: schema.TypeInt, },
Optional: true, "account_name": {
Description: "Page number", Type: schema.TypeString,
}, Optional: true,
"size": { Description: "Find by account name",
Type: schema.TypeInt, },
Optional: true, "disk_max_size": {
Description: "Page size", Type: schema.TypeInt,
}, Optional: true,
"items": { Description: "Find by max disk size",
Type: schema.TypeList, },
Computed: true, "status": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Optional: true,
"account_id": { Description: "Find by status",
Type: schema.TypeInt, },
Computed: true, "shared": {
Description: "The unique ID of the subscriber-owner of the disk", Type: schema.TypeBool,
}, Optional: true,
"account_name": { Description: "Find by shared field",
Type: schema.TypeString, },
Computed: true, "account_id": {
Description: "The name of the subscriber '(account') to whom this disk belongs", Type: schema.TypeInt,
}, Optional: true,
"acl": { Description: "ID of the account the disks belong to",
Type: schema.TypeString, },
Computed: true, "type": {
}, Type: schema.TypeString,
// "boot_partition": { Optional: true,
// Type: schema.TypeInt, Description: "type of the disks",
// Computed: true, },
// Description: "Number of disk partitions", "sep_id": {
// }, Type: schema.TypeInt,
"computes": { Optional: true,
Type: schema.TypeList, Description: "find by sep ID",
Computed: true, },
Elem: &schema.Resource{ "pool_name": {
Schema: map[string]*schema.Schema{ Type: schema.TypeString,
"compute_id": { Optional: true,
Type: schema.TypeString, Description: "find by pool name",
Computed: true, },
}, "sort_by": {
"compute_name": { Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "sort by one of supported fields, format +|-(field)",
}, },
}, "page": {
}, Type: schema.TypeInt,
}, Optional: true,
"created_time": { Description: "Page number",
Type: schema.TypeInt, },
Computed: true, "size": {
Description: "Created time", Type: schema.TypeInt,
}, Optional: true,
"deleted_time": { Description: "Page size",
Type: schema.TypeInt, },
Computed: true, "items": {
Description: "Deleted time", Type: schema.TypeList,
}, Computed: true,
"desc": { Elem: &schema.Resource{
Type: schema.TypeString, Schema: map[string]*schema.Schema{
Computed: true, "account_id": {
Description: "Description of disk", Type: schema.TypeInt,
}, Computed: true,
"destruction_time": { Description: "The unique ID of the subscriber-owner of the disk",
Type: schema.TypeInt, },
Computed: true, "account_name": {
Description: "Time of final deletion", Type: schema.TypeString,
}, Computed: true,
"devicename": { Description: "The name of the subscriber '(account') to whom this disk belongs",
Type: schema.TypeString, },
Computed: true, "acl": {
Description: "Name of the device", Type: schema.TypeString,
}, Computed: true,
// "disk_path": { },
// Type: schema.TypeString, // "boot_partition": {
// Computed: true, // Type: schema.TypeInt,
// Description: "Disk path", // Computed: true,
// }, // Description: "Number of disk partitions",
"gid": { // },
Type: schema.TypeInt, "computes": {
Computed: true, Type: schema.TypeList,
Description: "ID of the grid (platform)", Computed: true,
}, Elem: &schema.Resource{
// "guid": { Schema: map[string]*schema.Schema{
// Type: schema.TypeInt, "compute_id": {
// Computed: true, Type: schema.TypeString,
// Description: "Disk ID on the storage side", Computed: true,
// }, },
"disk_id": { "compute_name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "The unique ID of the subscriber-owner of the disk", },
}, },
"image_id": { },
Type: schema.TypeInt, },
Computed: true, "created_time": {
Description: "Image ID", Type: schema.TypeInt,
}, Computed: true,
"images": { Description: "Created time",
Type: schema.TypeList, },
Computed: true, "deleted_time": {
Elem: &schema.Schema{ Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
}, Description: "Deleted time",
Description: "IDs of images using the disk", },
}, "desc": {
"iotune": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, Description: "Description of disk",
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "destruction_time": {
"read_bytes_sec": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Time of final deletion",
Description: "Number of bytes to read per second", },
}, "devicename": {
"read_bytes_sec_max": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Name of the device",
Description: "Maximum number of bytes to read", },
}, // "disk_path": {
"read_iops_sec": { // Type: schema.TypeString,
Type: schema.TypeInt, // Computed: true,
Computed: true, // Description: "Disk path",
Description: "Number of io read operations per second", // },
}, "gid": {
"read_iops_sec_max": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "ID of the grid (platform)",
Description: "Maximum number of io read operations", },
}, // "guid": {
"size_iops_sec": { // Type: schema.TypeInt,
Type: schema.TypeInt, // Computed: true,
Computed: true, // Description: "Disk ID on the storage side",
Description: "Size of io operations", // },
}, "disk_id": {
"total_bytes_sec": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "The unique ID of the subscriber-owner of the disk",
Description: "Total size bytes per second", },
}, "image_id": {
"total_bytes_sec_max": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Image ID",
Description: "Maximum total size of bytes per second", },
}, "images": {
"total_iops_sec": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Schema{
Description: "Total number of io operations per second", Type: schema.TypeString,
}, },
"total_iops_sec_max": { Description: "IDs of images using the disk",
Type: schema.TypeInt, },
Computed: true, "iotune": {
Description: "Maximum total number of io operations per second", Type: schema.TypeList,
}, Computed: true,
"write_bytes_sec": { Elem: &schema.Resource{
Type: schema.TypeInt, Schema: map[string]*schema.Schema{
Computed: true, "read_bytes_sec": {
Description: "Number of bytes to write per second", Type: schema.TypeInt,
}, Computed: true,
"write_bytes_sec_max": { Description: "Number of bytes to read per second",
Type: schema.TypeInt, },
Computed: true, "read_bytes_sec_max": {
Description: "Maximum number of bytes to write per second", Type: schema.TypeInt,
}, Computed: true,
"write_iops_sec": { Description: "Maximum number of bytes to read",
Type: schema.TypeInt, },
Computed: true, "read_iops_sec": {
Description: "Number of write operations per second", Type: schema.TypeInt,
}, Computed: true,
"write_iops_sec_max": { Description: "Number of io read operations per second",
Type: schema.TypeInt, },
Computed: true, "read_iops_sec_max": {
Description: "Maximum number of write operations per second", Type: schema.TypeInt,
}, Computed: true,
}, Description: "Maximum number of io read operations",
}, },
}, "size_iops_sec": {
// "iqn": { Type: schema.TypeInt,
// Type: schema.TypeString, Computed: true,
// Computed: true, Description: "Size of io operations",
// Description: "Disk IQN", },
// }, "total_bytes_sec": {
// "login": { Type: schema.TypeInt,
// Type: schema.TypeString, Computed: true,
// Computed: true, Description: "Total size bytes per second",
// Description: "Login to access the disk", },
// }, "total_bytes_sec_max": {
"machine_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Maximum total size of bytes per second",
Description: "Machine ID", },
}, "total_iops_sec": {
"machine_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, Description: "Total number of io operations per second",
Description: "Machine name", },
}, "total_iops_sec_max": {
// "milestones": { Type: schema.TypeInt,
// Type: schema.TypeInt, Computed: true,
// Computed: true, Description: "Maximum total number of io operations per second",
// Description: "Milestones", },
// }, "write_bytes_sec": {
"disk_name": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, Description: "Number of bytes to write per second",
Description: "Name of disk", },
}, "write_bytes_sec_max": {
"order": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Maximum number of bytes to write per second",
Description: "Disk order", },
}, "write_iops_sec": {
"params": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, Description: "Number of write operations per second",
Description: "Disk params", },
}, "write_iops_sec_max": {
"parent_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, Description: "Maximum number of write operations per second",
Description: "ID of the parent disk", },
}, },
// "passwd": { },
// Type: schema.TypeString, },
// Computed: true, // "iqn": {
// Description: "Password to access the disk", // Type: schema.TypeString,
// }, // Computed: true,
"pci_slot": { // Description: "Disk IQN",
Type: schema.TypeInt, // },
Computed: true, // "login": {
Description: "ID of the pci slot to which the disk is connected", // Type: schema.TypeString,
}, // Computed: true,
"pool": { // Description: "Login to access the disk",
Type: schema.TypeString, // },
Computed: true, "machine_id": {
Description: "Pool for disk location", Type: schema.TypeInt,
}, Computed: true,
"present_to": { Description: "Machine ID",
Type: schema.TypeList, },
Computed: true, "machine_name": {
Elem: &schema.Schema{ Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
}, Description: "Machine name",
}, },
// "purge_attempts": { // "milestones": {
// Type: schema.TypeInt, // Type: schema.TypeInt,
// Computed: true, // Computed: true,
// Description: "Number of deletion attempts", // Description: "Milestones",
// }, // },
"purge_time": { "disk_name": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "Time of the last deletion attempt", Description: "Name of disk",
}, },
// "reality_device_number": { "order": {
// Type: schema.TypeInt, Type: schema.TypeInt,
// Computed: true, Computed: true,
// Description: "Reality device number", Description: "Disk order",
// }, },
// "reference_id": { "params": {
// Type: schema.TypeString, Type: schema.TypeString,
// Computed: true, Computed: true,
// Description: "ID of the reference to the disk", Description: "Disk params",
// }, },
"res_id": { "parent_id": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "Resource ID", Description: "ID of the parent disk",
}, },
"res_name": { // "passwd": {
Type: schema.TypeString, // Type: schema.TypeString,
Computed: true, // Computed: true,
Description: "Name of the resource", // Description: "Password to access the disk",
}, // },
"role": { "pci_slot": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "Disk role", Description: "ID of the pci slot to which the disk is connected",
}, },
"sep_id": { "pool": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "Storage endpoint provider ID to create disk", Description: "Pool for disk location",
}, },
"sep_type": { "present_to": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform", Elem: &schema.Schema{
}, Type: schema.TypeInt,
"shareable": { },
Type: schema.TypeBool, },
Computed: true, // "purge_attempts": {
}, // Type: schema.TypeInt,
"size_max": { // Computed: true,
Type: schema.TypeInt, // Description: "Number of deletion attempts",
Computed: true, // },
Description: "Size in GB", "purge_time": {
}, Type: schema.TypeInt,
"size_used": { Computed: true,
Type: schema.TypeFloat, Description: "Time of the last deletion attempt",
Computed: true, },
Description: "Number of used space, in GB", // "reality_device_number": {
}, // Type: schema.TypeInt,
"snapshots": { // Computed: true,
Type: schema.TypeList, // Description: "Reality device number",
Computed: true, // },
Elem: &schema.Resource{ // "reference_id": {
Schema: map[string]*schema.Schema{ // Type: schema.TypeString,
"guid": { // Computed: true,
Type: schema.TypeString, // Description: "ID of the reference to the disk",
Computed: true, // },
Description: "ID of the snapshot", "replication": {
}, Type: schema.TypeList,
"label": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
Description: "Name of the snapshot", "disk_id": {
}, Type: schema.TypeInt,
"res_id": { Computed: true,
Type: schema.TypeString, },
Computed: true, "pool_id": {
Description: "Reference to the snapshot", Type: schema.TypeString,
}, Computed: true,
"snap_set_guid": { },
Type: schema.TypeString, "role": {
Computed: true, Type: schema.TypeString,
Description: "The set snapshot ID", Computed: true,
}, },
"snap_set_time": { "self_volume_id": {
Type: schema.TypeInt, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "The set time of the snapshot", },
}, "storage_id": {
"timestamp": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
Description: "Snapshot time", "volume_id": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, },
"status": { },
Type: schema.TypeString, Description: "Replication status",
Computed: true, },
Description: "Disk status", "res_id": {
}, Type: schema.TypeString,
"tech_status": { Computed: true,
Type: schema.TypeString, Description: "Resource ID",
Computed: true, },
Description: "Technical status of the disk", "res_name": {
}, Type: schema.TypeString,
"type": { Computed: true,
Type: schema.TypeString, Description: "Name of the resource",
Computed: true, },
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", "role": {
}, Type: schema.TypeString,
"vmid": { Computed: true,
Type: schema.TypeInt, Description: "Disk role",
Computed: true, },
Description: "Virtual Machine ID (Deprecated)", "sep_id": {
}, Type: schema.TypeInt,
}, Computed: true,
}, Description: "Storage endpoint provider ID to create disk",
}, },
} "sep_type": {
return res 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",
func DataSourceDiskList() *schema.Resource { },
return &schema.Resource{ "shareable": {
SchemaVersion: 1, Type: schema.TypeBool,
Computed: true,
ReadContext: dataSourceDiskListRead, },
"size_max": {
Timeouts: &schema.ResourceTimeout{ Type: schema.TypeInt,
Read: &constants.Timeout30s, Computed: true,
Default: &constants.Timeout60s, Description: "Size in GB",
}, },
"size_used": {
Schema: dataSourceDiskListSchemaMake(), Type: schema.TypeFloat,
} Computed: true,
} Description: "Number of used space, in GB",
},
"snapshots": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the snapshot",
},
"label": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the snapshot",
},
"res_id": {
Type: schema.TypeString,
Computed: true,
Description: "Reference to the snapshot",
},
"snap_set_guid": {
Type: schema.TypeString,
Computed: true,
Description: "The set snapshot ID",
},
"snap_set_time": {
Type: schema.TypeInt,
Computed: true,
Description: "The set time of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "Snapshot time",
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Disk status",
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceDiskList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListSchemaMake(),
}
}

View File

@@ -44,17 +44,34 @@ import (
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m) listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("types", listTypes) d.Set("types", listTypes.Data)
d.Set("entry_count", listTypes.EntryCount)
return nil return nil
} }
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema { func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"types": { "types": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -63,6 +80,10 @@ func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
}, },
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
}, },
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
} }
return res return res
} }

View File

@@ -38,16 +38,18 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
) )
func flattenDiskListTypesDetailed(tld []interface{}) []map[string]interface{} { func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
for _, typeListDetailed := range tld { for _, typeListDetailed := range tld.Data {
toMap := typeListDetailed.(map[string]interface{}) toMap := typeListDetailed.(map[string]interface{})
temp := map[string]interface{}{ temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})), "pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": toMap["sepId"].(float64), "sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
} }
res = append(res, temp) res = append(res, temp)
} }
@@ -59,8 +61,9 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
for _, pool := range pools { for _, pool := range pools {
toMap := pool.(map[string]interface{}) toMap := pool.(map[string]interface{})
temp := map[string]interface{}{ temp := map[string]interface{}{
"name": toMap["name"].(string), "name": toMap["name"].(string),
"types": toMap["types"].([]interface{}), "system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
} }
res = append(res, temp) res = append(res, temp)
} }
@@ -71,17 +74,34 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m) listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed)) d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
d.Set("entry_count", listTypesDetailed.EntryCount)
return nil return nil
} }
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema { func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": { "items": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -97,6 +117,10 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "Pool name", Description: "Pool name",
}, },
"system": {
Type: schema.TypeString,
Computed: true,
},
"types": { "types": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -113,9 +137,17 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "Storage endpoint provider ID to create disk", Description: "Storage endpoint provider ID to create disk",
}, },
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
}, },
}, },
}, },
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
} }
return res return res
} }

View File

@@ -44,12 +44,14 @@ import (
func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskListUnattachedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m) diskListUnattached, err := utilityDiskListUnattachedCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("items", flattenDiskListUnattached(diskListUnattached)) d.Set("items", flattenDiskListUnattached(diskListUnattached))
d.Set("entry_count", diskListUnattached.EntryCount)
return nil return nil
} }
@@ -71,12 +73,61 @@ func DataSourceDiskListUnattached() *schema.Resource {
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by ID",
},
"account_name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by account name",
},
"disk_max_size": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by max disk size",
},
"status": {
Type: schema.TypeString,
Optional: true,
Description: "Find by status",
},
"account_id": { "account_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
Description: "ID of the account the disks belong to", Description: "ID of the account the disks belong to",
}, },
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Description: "find by sep ID",
},
"pool_name": {
Type: schema.TypeString,
Optional: true,
Description: "find by pool name",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": { "items": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -330,6 +381,11 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Computed: true, Computed: true,
Description: "Storage endpoint provider ID to create disk", Description: "Storage endpoint provider ID to create disk",
}, },
"shareable": {
Type: schema.TypeBool,
Computed: true,
Description: "shareable",
},
"size_max": { "size_max": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -401,6 +457,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
}, },
}, },
}, },
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
} }
return res return res
} }

View File

@@ -0,0 +1,480 @@
/*
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(),
}
}

View File

@@ -45,6 +45,7 @@ import (
func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }

View File

@@ -44,6 +44,7 @@ import (
func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }

View File

@@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -42,18 +43,471 @@ import (
) )
func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceDiskListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
diskList, err := utilityDiskListCheckPresence(ctx, d, m) diskList, err := utilityDiskListDeletedCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("items", flattenDiskList(diskList)) d.Set("items", flattenDiskList(diskList))
d.Set("entry_count", diskList.EntryCount)
return nil return nil
} }
func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by disk ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by disk name",
},
"account_name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by account name",
},
"disk_max_size": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by max disk size",
},
"shared": {
Type: schema.TypeBool,
Optional: true,
Description: "Find shared disks",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
Description: "The unique ID of the subscriber-owner of the disk",
},
"account_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the subscriber '(account') to whom this disk belongs",
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
// "boot_partition": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Number of disk partitions",
// },
"computes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeString,
Computed: true,
},
"compute_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Created time",
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Deleted time",
},
"desc": {
Type: schema.TypeString,
Computed: true,
Description: "Description of disk",
},
"destruction_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Time of final deletion",
},
"devicename": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the device",
},
// "disk_path": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Disk path",
// },
"gid": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the grid (platform)",
},
// "guid": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Disk ID on the storage side",
// },
"disk_id": {
Type: schema.TypeInt,
Computed: true,
Description: "The unique ID of the subscriber-owner of the disk",
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image ID",
},
"images": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "IDs of images using the disk",
},
"iotune": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"read_bytes_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of bytes to read per second",
},
"read_bytes_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum number of bytes to read",
},
"read_iops_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of io read operations per second",
},
"read_iops_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum number of io read operations",
},
"size_iops_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Size of io operations",
},
"total_bytes_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Total size bytes per second",
},
"total_bytes_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum total size of bytes per second",
},
"total_iops_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Total number of io operations per second",
},
"total_iops_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum total number of io operations per second",
},
"write_bytes_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of bytes to write per second",
},
"write_bytes_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum number of bytes to write per second",
},
"write_iops_sec": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of write operations per second",
},
"write_iops_sec_max": {
Type: schema.TypeInt,
Computed: true,
Description: "Maximum number of write operations per second",
},
},
},
},
// "iqn": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Disk IQN",
// },
// "login": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Login to access the disk",
// },
"machine_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Machine ID",
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
Description: "Machine name",
},
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"disk_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of disk",
},
"order": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk order",
},
"params": {
Type: schema.TypeString,
Computed: true,
Description: "Disk params",
},
"parent_id": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the parent disk",
},
// "passwd": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Password to access the disk",
// },
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the pci slot to which the disk is connected",
},
"pool": {
Type: schema.TypeString,
Computed: true,
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
// "purge_attempts": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Number of deletion attempts",
// },
"purge_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Time of the last deletion attempt",
},
"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)",
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceDiskListDeleted() *schema.Resource { func DataSourceDiskListDeleted() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
@@ -64,6 +518,6 @@ func DataSourceDiskListDeleted() *schema.Resource {
Default: &constants.Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceDiskListSchemaMake(), Schema: dataSourceDiskDeletedListSchemaMake(),
} }
} }

View File

@@ -16,9 +16,9 @@ func flattenDiskSnapshot(d *schema.ResourceData, snapshot disks.ItemSnapshot) {
d.Set("snap_set_time", snapshot.SnapSetTime) d.Set("snap_set_time", snapshot.SnapSetTime)
} }
func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interface{} { func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(ul.Data))
for _, unattachedDisk := range ul { for _, unattachedDisk := range ul.Data {
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL) unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
tmp := map[string]interface{}{ tmp := map[string]interface{}{
"_ckey": unattachedDisk.CKey, "_ckey": unattachedDisk.CKey,
@@ -56,6 +56,7 @@ func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interf
"res_name": unattachedDisk.ResName, "res_name": unattachedDisk.ResName,
"role": unattachedDisk.Role, "role": unattachedDisk.Role,
"sep_id": unattachedDisk.SEPID, "sep_id": unattachedDisk.SEPID,
"shareable": unattachedDisk.Shareable,
"size_max": unattachedDisk.SizeMax, "size_max": unattachedDisk.SizeMax,
"size_used": unattachedDisk.SizeUsed, "size_used": unattachedDisk.SizeUsed,
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots), "snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
@@ -71,7 +72,6 @@ func flattenDiskListUnattached(ul disks.ListDisksUnattached) []map[string]interf
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,6 +102,7 @@ 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)
@@ -119,8 +120,73 @@ 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) res := make([]interface{}, 0, len(sl))
for _, snapshot := range sl { for _, snapshot := range sl {
temp := map[string]interface{}{ temp := map[string]interface{}{
"guid": snapshot.GUID, "guid": snapshot.GUID,
@@ -136,9 +202,9 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
return res return res
} }
func flattenDiskList(dl disks.ListDisks) []map[string]interface{} { func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(dl.Data))
for _, disk := range dl { for _, disk := range dl.Data {
diskAcl, _ := json.Marshal(disk.ACL) diskAcl, _ := json.Marshal(disk.ACL)
temp := map[string]interface{}{ temp := map[string]interface{}{
"account_id": disk.AccountID, "account_id": disk.AccountID,
@@ -165,6 +231,7 @@ 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,

View File

@@ -2,9 +2,11 @@ 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"
) )
@@ -19,7 +21,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
return false, err return false, err
} }
return len(accountList.FilterByID(accountId)) != 0, nil return len(accountList.FilterByID(accountId).Data) != 0, nil
} }
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
@@ -32,5 +34,28 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
return false, err return false, err
} }
return len(locationList.FilterByGID(gid)) != 0, nil return len(locationList.FilterByGID(gid).Data) != 0, nil
}
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
} }

View File

@@ -95,6 +95,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
diskId, err := c.CloudAPI().Disks().Create(ctx, req) diskId, err := c.CloudAPI().Disks().Create(ctx, req)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -142,7 +143,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
} }
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg) // c := m.(*controller.ControllerCfg)
warnings := dc.Warnings{} warnings := dc.Warnings{}
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
@@ -157,23 +158,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.Set("disk_id", 0) d.Set("disk_id", 0)
d.SetId("") d.SetId("")
return resourceDiskCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true // hasChangeState = true
req := disks.RestoreRequest{ // req := disks.RestoreRequest{
DiskID: disk.ID, // DiskID: disk.ID,
} // }
if reason, ok := d.GetOk("reason"); ok { // if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string) // req.Reason = reason.(string)
} else { // } else {
req.Reason = "Terraform automatic restore" // req.Reason = "Terraform automatic restore"
} // }
_, err := c.CloudAPI().Disks().Restore(ctx, req) // _, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil { // if err != nil {
warnings.Add(err) // warnings.Add(err)
} // }
case status.Assigned: case status.Assigned:
case status.Modeled: case status.Modeled:
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status) return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
@@ -218,6 +220,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -227,7 +230,8 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
case status.Destroyed, status.Purged: case status.Destroyed, status.Purged:
d.Set("disk_id", 0) d.Set("disk_id", 0)
d.SetId("") d.SetId("")
return resourceDiskCreate(ctx, d, m) return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted: case status.Deleted:
hasChangeState = true hasChangeState = true
req := disks.RestoreRequest{ req := disks.RestoreRequest{
@@ -271,7 +275,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
Size: uint64(newSize.(int)), Size: uint64(newSize.(int)),
} }
_, err := c.CloudAPI().Disks().Resize(ctx, req) _, err := c.CloudAPI().Disks().Resize2(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -375,9 +379,9 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
func resourceDiskSchemaMake() map[string]*schema.Schema { func resourceDiskSchemaMake() map[string]*schema.Schema {
rets := map[string]*schema.Schema{ rets := map[string]*schema.Schema{
"account_id": { "account_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, //ForceNew: true,
Description: "The unique ID of the subscriber-owner of the disk", Description: "The unique ID of the subscriber-owner of the disk",
}, },
"disk_name": { "disk_name": {
@@ -391,9 +395,9 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Description: "Size in GB", Description: "Size in GB",
}, },
"gid": { "gid": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, //ForceNew: true,
Description: "ID of the grid (platform)", Description: "ID of the grid (platform)",
}, },
"pool": { "pool": {
@@ -667,6 +671,39 @@ 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,

View File

@@ -0,0 +1,642 @@
/*
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(),
}
}

View File

@@ -83,6 +83,7 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func resourceDiskSnapshotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk, err := utilityDiskCheckPresence(ctx, d, m) disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -169,15 +170,15 @@ func resourceDiskSnapshotDelete(ctx context.Context, d *schema.ResourceData, m i
func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema { func resourceDiskSnapshotSchemaMake() map[string]*schema.Schema {
rets := map[string]*schema.Schema{ rets := map[string]*schema.Schema{
"disk_id": { "disk_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, //ForceNew: true,
Description: "The unique ID of the subscriber-owner of the disk", Description: "The unique ID of the subscriber-owner of the disk",
}, },
"label": { "label": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, //ForceNew: true,
Description: "Name of the snapshot", Description: "Name of the snapshot",
}, },
"rollback": { "rollback": {

View File

@@ -1,70 +1,97 @@
/* /*
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 page, ok := d.GetOk("page"); ok { if by_id, ok := d.GetOk("by_id"); ok {
req.Page = uint64(page.(int)) req.ByID = uint64(by_id.(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 diskType, ok := d.GetOk("type"); ok { if account_name, ok := d.GetOk("account_name"); ok {
req.Type = strings.ToUpper(diskType.(string)) req.AccountName = account_name.(string)
} }
if accountId, ok := d.GetOk("accountId"); ok { if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.AccountID = uint64(accountId.(int)) req.DiskMaxSize = int64(disk_max_size.(int))
} }
if status, ok := d.GetOk("status"); ok {
log.Debugf("utilityDiskListCheckPresence: load disk list") req.Status = status.(string)
diskList, err := c.CloudAPI().Disks().List(ctx, req) }
if err != nil { if shared, ok := d.GetOk("shared"); ok {
return nil, err req.Shared = shared.(bool)
} }
if accountId, ok := d.GetOk("account_id"); ok {
return diskList, nil req.AccountID = uint64(accountId.(int))
} }
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
if pool_name, ok := d.GetOk("pool_name"); ok {
req.Pool = pool_name.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudAPI().Disks().List(ctx, req)
if err != nil {
return nil, err
}
return diskList, nil
}

View File

@@ -0,0 +1,96 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisks, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListDeletedRequest{}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if typev, ok := d.GetOk("type"); ok {
req.Type = typev.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_name, ok := d.GetOk("account_name"); ok {
req.AccountName = account_name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = int64(disk_max_size.(int))
}
if shared, ok := d.GetOk("shared"); ok {
req.Shared = shared.(bool)
}
log.Debugf("utilityDiskListDeletedCheckPresence: load disk list")
diskList, err := c.CloudAPI().Disks().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return diskList, nil
}

View File

@@ -9,12 +9,43 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
) )
func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (disks.ListDisksUnattached, error) { func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListDisksUnattached, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := disks.ListUnattachedRequest{} req := disks.ListUnattachedRequest{}
if accountId, ok := d.GetOk("accountId"); ok {
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if account_name, ok := d.GetOk("account_name"); ok {
req.AccountName = account_name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = int64(disk_max_size.(int))
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int)) req.AccountID = uint64(accountId.(int))
} }
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
if pool_name, ok := d.GetOk("pool_name"); ok {
req.Pool = pool_name.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list") log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req) unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)

View File

@@ -0,0 +1,174 @@
/*
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
}

View File

@@ -41,12 +41,22 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
) )
func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]interface{}, error) { func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{ req := disks.ListTypesRequest{
Detailed: true, Detailed: true,
} }
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed") log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req) listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
if err != nil { if err != nil {

View File

@@ -41,12 +41,22 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
) )
func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]interface{}, error) { func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{ req := disks.ListTypesRequest{
Detailed: false, Detailed: false,
} }
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed") log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req) typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
if err != nil { if err != nil {

View File

@@ -1,291 +1,286 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
limitations under the License. See the License for the specific language governing permissions and
*/ limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud /*
Orchestration Technology) with Terraform by Hashicorp. Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://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
builds seamlessly. 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
*/ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package extnet
package extnet
import (
"context" import (
"strconv" "context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
e, err := utilityExtnetCheckPresence(ctx, d, m) func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { e, err := utilityExtnetCheckPresence(ctx, d, m)
return diag.FromErr(err) if err != nil {
} d.SetId("")
return diag.FromErr(err)
d.SetId(strconv.FormatUint(e.ID, 10)) }
flattenExtnet(d, e)
d.SetId(strconv.FormatUint(e.ID, 10))
return nil flattenExtnet(d, e)
}
return nil
func dataSourceExtnetSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"net_id": { func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Required: true, "net_id": {
}, Type: schema.TypeInt,
"ckey": { Required: true,
Type: schema.TypeString, },
Computed: true, "ckey": {
}, Type: schema.TypeString,
"meta": { Computed: true,
Type: schema.TypeList, },
Computed: true, "meta": {
Elem: &schema.Schema{ Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
}, Elem: &schema.Schema{
Description: "meta", Type: schema.TypeString,
}, },
"check__ips": { Description: "meta",
Type: schema.TypeList, },
Computed: true, "check_ips": {
Elem: &schema.Schema{ Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
}, Elem: &schema.Schema{
}, Type: schema.TypeString,
"check_ips": { },
Type: schema.TypeList, },
Computed: true, "default": {
Elem: &schema.Schema{ Type: schema.TypeBool,
Type: schema.TypeString, Computed: true,
}, },
}, "default_qos": {
"default": { Type: schema.TypeList,
Type: schema.TypeBool, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"default_qos": { "e_rate": {
Type: schema.TypeList, Type: schema.TypeInt,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "e_burst": {
"e_rate": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "guid": {
"e_burst": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "in_burst": {
"guid": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "in_rate": {
"in_burst": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, },
"in_rate": { },
Type: schema.TypeInt, },
Computed: true, "desc": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
}, "dns": {
"desc": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeString,
"dns": { },
Type: schema.TypeList, },
Computed: true, "excluded": {
Elem: &schema.Schema{ Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
}, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"excluded": { "client_type": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "mac": {
"client_type": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "ip": {
"mac": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "type": {
"ip": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "vm_id": {
"type": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"vm_id": { },
Type: schema.TypeInt, },
Computed: true, "free_ips": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "gateway": {
"free_ips": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "gid": {
"gateway": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "guid": {
"gid": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "ipcidr": {
"guid": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "milestones": {
"ipcidr": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "net_name": {
"milestones": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "network": {
"net_name": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "network_id": {
"network": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "pre_reservations_num": {
"network_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "prefix": {
"pre_reservations_num": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "pri_vnf_dev_id": {
"prefix": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "reservations": {
"pri_vnf_dev_id": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"reservations": { "client_type": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ "domainname": {
"client_type": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "hostname": {
"domainname": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "desc": {
"hostname": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "ip": {
"desc": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "mac": {
"ip": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "type": {
"mac": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "vm_id": {
"type": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, },
"vm_id": { },
Type: schema.TypeInt, },
Computed: true, "shared_with": {
}, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"shared_with": { },
Type: schema.TypeList, },
Computed: true, "status": {
Elem: &schema.Schema{ Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
}, },
}, "vlan_id": {
"status": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "vnfs": {
"vlan_id": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Resource{
}, Schema: map[string]*schema.Schema{
"vnfs": { "dhcp": {
Type: schema.TypeList, Type: schema.TypeInt,
Computed: true, Computed: true,
Elem: &schema.Resource{ },
Schema: map[string]*schema.Schema{ },
"dhcp": { },
Type: schema.TypeInt, },
Computed: true, }
}, return res
}, }
},
}, func DataSourceExtnet() *schema.Resource {
} return &schema.Resource{
return res SchemaVersion: 1,
}
ReadContext: dataSourceExtnetRead,
func DataSourceExtnet() *schema.Resource {
return &schema.Resource{ Timeouts: &schema.ResourceTimeout{
SchemaVersion: 1, Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
ReadContext: dataSourceExtnetRead, },
Timeouts: &schema.ResourceTimeout{ Schema: dataSourceExtnetSchemaMake(),
Read: &constants.Timeout30s, }
Default: &constants.Timeout60s, }
},
Schema: dataSourceExtnetSchemaMake(),
}
}

View File

@@ -1,137 +1,167 @@
/* /*
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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenExtnetComputesList(extnetComputesList)) d.SetId(id.String())
d.Set("items", flattenExtnetComputesList(extnetComputesList))
return nil d.Set("entry_count", extnetComputesList.EntryCount)
} return nil
}
func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
"account_id": { res := map[string]*schema.Schema{
Type: schema.TypeInt, "account_id": {
Required: true, Type: schema.TypeInt,
Description: "filter by account ID", Required: true,
}, Description: "filter by account ID",
"items": { },
Type: schema.TypeList, "rg_id": {
Computed: true, Type: schema.TypeInt,
Elem: &schema.Resource{ Optional: true,
Schema: map[string]*schema.Schema{ Description: "Filter by RG ID",
"account_id": { },
Type: schema.TypeInt, "compute_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"account_name": { Description: "Filter by compute ID",
Type: schema.TypeString, },
Computed: true, "sort_by": {
}, Type: schema.TypeString,
"extnets": { Optional: true,
Type: schema.TypeList, Description: "sort by one of supported fields, format +|-(field)",
Computed: true, },
Elem: &schema.Resource{ "page": {
Schema: map[string]*schema.Schema{ Type: schema.TypeInt,
"net_id": { Optional: true,
Type: schema.TypeInt, Description: "Page number",
Computed: true, },
}, "size": {
"ipaddr": { Type: schema.TypeInt,
Type: schema.TypeString, Optional: true,
Computed: true, Description: "Page size",
}, },
"ipcidr": { "items": {
Type: schema.TypeString, Type: schema.TypeList,
Computed: true, Computed: true,
}, Elem: &schema.Resource{
"name": { Schema: map[string]*schema.Schema{
Type: schema.TypeString, "account_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
}, },
}, "account_name": {
}, Type: schema.TypeString,
"id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "extnets": {
}, Type: schema.TypeList,
"name": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "net_id": {
"rg_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "ipaddr": {
"rg_name": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "ipcidr": {
}, Type: schema.TypeString,
}, Computed: true,
}, },
} "name": {
return res Type: schema.TypeString,
} Computed: true,
},
func DataSourceExtnetComputesList() *schema.Resource { },
return &schema.Resource{ },
SchemaVersion: 1, },
"id": {
ReadContext: dataSourceExtnetComputesListRead, Type: schema.TypeInt,
Computed: true,
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "name": {
Default: &constants.Timeout60s, Type: schema.TypeString,
}, Computed: true,
},
Schema: dataSourceExtnetComputesListSchemaMake(), "rg_id": {
} Type: schema.TypeInt,
} Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceExtnetComputesList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceExtnetComputesListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceExtnetComputesListSchemaMake(),
}
}

View File

@@ -1,85 +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 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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32) d.SetId(id.String())
if err != nil { extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32)
return diag.FromErr(err) if err != nil {
} return diag.FromErr(err)
d.Set("net_id", extnetIdInt) }
d.Set("net_id", extnetIdInt)
return nil
} return nil
}
func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{ func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
"net_id": { res := map[string]*schema.Schema{
Type: schema.TypeInt, "net_id": {
Computed: true, Type: schema.TypeInt,
}, Computed: true,
} },
return res }
} return res
}
func DataSourceExtnetDefault() *schema.Resource {
return &schema.Resource{ func DataSourceExtnetDefault() *schema.Resource {
SchemaVersion: 1, return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceExtnetDefaultRead,
ReadContext: dataSourceExtnetDefaultRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s, Timeouts: &schema.ResourceTimeout{
Default: &constants.Timeout60s, Read: &constants.Timeout30s,
}, Default: &constants.Timeout60s,
},
Schema: dataSourceExtnetDefaultSchemaMake(),
} Schema: dataSourceExtnetDefaultSchemaMake(),
} }
}

View File

@@ -1,111 +1,155 @@
/* /*
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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenExtnetList(extnetList)) d.SetId(id.String())
d.Set("items", flattenExtnetList(extnetList))
return nil d.Set("entry_count", extnetList.EntryCount)
}
return nil
func dataSourceExtnetListSchemaMake() map[string]*schema.Schema { }
res := map[string]*schema.Schema{
"account_id": { func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, res := map[string]*schema.Schema{
Optional: true, "account_id": {
Description: "filter by account ID", Type: schema.TypeInt,
}, Optional: true,
"page": { Description: "Find by account ID",
Type: schema.TypeInt, },
Optional: true, "by_id": {
Description: "Page number", Type: schema.TypeInt,
}, Optional: true,
"size": { Description: "Find by ID",
Type: schema.TypeInt, },
Optional: true, "name": {
Description: "Page size", Type: schema.TypeString,
}, Optional: true,
"items": { Description: "Find by name",
Type: schema.TypeList, },
Computed: true, "network": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Optional: true,
"net_id": { },
Type: schema.TypeInt, "vlan_id": {
Computed: true, Type: schema.TypeInt,
}, Optional: true,
"ipcidr": { Description: "Find by VLAN ID",
Type: schema.TypeString, },
Computed: true, "vnfdev_id": {
}, Type: schema.TypeInt,
"name": { Optional: true,
Type: schema.TypeString, Description: "Find by VnfDEV ID",
Computed: true, },
}, "status": {
}, Type: schema.TypeString,
}, Optional: true,
}, Description: "Find by status",
} },
return res "sort_by": {
} Type: schema.TypeString,
Optional: true,
func DataSourceExtnetList() *schema.Resource { Description: "sort by one of supported fields, format +|-(field)",
return &schema.Resource{ },
SchemaVersion: 1, "page": {
Type: schema.TypeInt,
ReadContext: dataSourceExtnetListRead, Optional: true,
Description: "Page number",
Timeouts: &schema.ResourceTimeout{ },
Read: &constants.Timeout30s, "size": {
Default: &constants.Timeout60s, Type: schema.TypeInt,
}, Optional: true,
Description: "Page size",
Schema: dataSourceExtnetListSchemaMake(), },
} "items": {
} Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"net_id": {
Type: schema.TypeInt,
Computed: true,
},
"ipcidr": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceExtnetList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceExtnetListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceExtnetListSchemaMake(),
}
}

View File

@@ -9,8 +9,7 @@ import (
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) { func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
d.Set("ckey", e.CKey) d.Set("ckey", e.CKey)
d.Set("meta", flattens.FlattenMeta(e.Meta)) d.Set("meta", flattens.FlattenMeta(e.Meta))
d.Set("check__ips", e.CheckIPs) d.Set("check_ips", e.CheckIPs)
d.Set("check_ips", e.CheckIps)
d.Set("default", e.Default) d.Set("default", e.Default)
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS)) d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
d.Set("desc", e.Description) d.Set("desc", e.Description)
@@ -36,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
} }
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} { func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(ex))
for _, item := range ex { for _, item := range ex {
temp := map[string]interface{}{ temp := map[string]interface{}{
"client_type": item.ClientType, "client_type": item.ClientType,
@@ -52,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
} }
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} { func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(ers))
for _, er := range ers { for _, er := range ers {
temp := map[string]interface{}{ temp := map[string]interface{}{
"client_type": er.ClientType, "client_type": er.ClientType,
@@ -93,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
} }
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} { func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(ecs))
for _, ec := range ecs { for _, ec := range ecs {
temp := map[string]interface{}{ temp := map[string]interface{}{
"net_id": ec.ID, "net_id": ec.ID,
@@ -106,9 +105,9 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
return res return res
} }
func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]interface{} { func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(ecl.Data))
for _, ec := range ecl { for _, ec := range ecl.Data {
temp := map[string]interface{}{ temp := map[string]interface{}{
"account_id": ec.AccountID, "account_id": ec.AccountID,
"account_name": ec.AccountName, "account_name": ec.AccountName,
@@ -123,13 +122,14 @@ func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]inter
return res return res
} }
func flattenExtnetList(el extnet.ListExtNets) []map[string]interface{} { func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0, len(el.Data))
for _, e := range el { for _, e := range el.Data {
temp := map[string]interface{}{ temp := map[string]interface{}{
"net_id": e.ID, "net_id": e.ID,
"ipcidr": e.IPCIDR, "ipcidr": e.IPCIDR,
"name": e.Name, "name": e.Name,
"status": e.Status,
} }
res = append(res, temp) res = append(res, temp)
} }

View File

@@ -1,58 +1,74 @@
/* /*
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)),
} }
log.Debugf("utilityExtnetComputesListCheckPresence") if rg_id, ok := d.GetOk("rg_id"); ok {
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req) req.RGID = uint64(rg_id.(int))
if err != nil { }
return nil, err if compute_id, ok := d.GetOk("compute_id"); ok {
} req.ComputeID = uint64(compute_id.(int))
}
return extnetComputesList, nil if sortBy, ok := d.GetOk("sort_by"); ok {
} req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityExtnetComputesListCheckPresence")
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
if err != nil {
return nil, err
}
return extnetComputesList, nil
}

View File

@@ -1,66 +1,87 @@
/* /*
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 page, ok := d.GetOk("page"); ok { if by_id, ok := d.GetOk("by_id"); ok {
req.Page = uint64(page.(int)) req.ByID = uint64(by_id.(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 network, ok := d.GetOk("network"); ok {
log.Debugf("utilityExtnetListCheckPresence") req.Network = network.(string)
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req) }
if err != nil { if vlan_id, ok := d.GetOk("vlan_id"); ok {
return nil, err req.VLANID = uint64(vlan_id.(int))
} }
if vnfdev_id, ok := d.GetOk("vnfdev_id"); ok {
return extnetList, nil req.VNFDevID = uint64(vnfdev_id.(int))
} }
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityExtnetListCheckPresence")
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req)
if err != nil {
return nil, err
}
return extnetList, nil
}

View File

@@ -1,123 +1,184 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors: Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Tim Tkachev, <tvtkachev@basistech.ru>
you may not use this file except in compliance with the License.
You may obtain a copy of the License at Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
http://www.apache.org/licenses/LICENSE-2.0 You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software http://www.apache.org/licenses/LICENSE-2.0
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Unless required by applicable law or agreed to in writing, software
See the License for the specific language governing permissions and distributed under the License is distributed on an "AS IS" BASIS,
limitations under the License. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/ See the License for the specific language governing permissions and
limitations under the License.
/* */
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp. /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort Orchestration Technology) with Terraform by Hashicorp.
Please see README.md to learn where to place source code so that it Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
builds seamlessly.
Please see README.md to learn where to place source code so that it
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki builds seamlessly.
*/
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
package account */
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" package flipgroup
func dataSourceAccountFlipGroupSchemaMake() map[string]*schema.Schema { import (
return map[string]*schema.Schema{ "context"
"account_id": { "fmt"
Type: schema.TypeInt,
Computed: true, "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
}, "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"client_type": { "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
Type: schema.TypeString, )
Computed: true,
}, func dataSourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
"conn_type": { fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
Type: schema.TypeString, if err != nil {
Computed: true, d.SetId("")
}, return diag.FromErr(err)
"created_by": { }
Type: schema.TypeString,
Computed: true, flattenFlipgroup(d, fg)
}, d.SetId(fmt.Sprint(fg.ID))
"created_time": {
Type: schema.TypeInt, return nil
Computed: true, }
},
"default_gw": { func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, return map[string]*schema.Schema{
Computed: true, "flipgroup_id": {
}, Type: schema.TypeInt,
"deleted_by": { Required: true,
Type: schema.TypeString, Description: "Flipgroupd ID",
Computed: true, },
}, "account_id": {
"deleted_time": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "account_name": {
"desc": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "client_ids": {
"gid": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"guid": { },
Type: schema.TypeInt, },
Computed: true, "client_type": {
}, Type: schema.TypeString,
"fg_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "conn_id": {
}, Type: schema.TypeInt,
"ip": { Computed: true,
Type: schema.TypeString, },
Computed: true, "conn_type": {
}, Type: schema.TypeString,
"milestones": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "created_by": {
}, Type: schema.TypeString,
"fg_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "created_time": {
}, Type: schema.TypeInt,
"net_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "default_gw": {
}, Type: schema.TypeString,
"net_type": { Computed: true,
Type: schema.TypeString, },
Computed: true, "deleted_by": {
}, Type: schema.TypeString,
"netmask": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "deleted_time": {
}, Type: schema.TypeInt,
"status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "desc": {
}, Type: schema.TypeString,
"updated_by": { Computed: true,
Type: schema.TypeString, },
Computed: true, "gid": {
}, Type: schema.TypeInt,
"updated_time": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "guid": {
}, Type: schema.TypeInt,
} Computed: true,
} },
"ip": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"net_id": {
Type: schema.TypeInt,
Computed: true,
},
"net_type": {
Type: schema.TypeString,
Computed: true,
},
"network": {
Type: schema.TypeString,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func DataSourceFlipgroup() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceFlipgroupRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout180s,
Default: &constants.Timeout180s,
},
Schema: dataSourceFlipgroupSchemaMake(),
}
}

View File

@@ -0,0 +1,246 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package flipgroup
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceFlipgroupList(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
fg_list, err := utilityFlipgroupListCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenFlipgroupList(fg_list))
d.Set("entry_count", fg_list.EntryCount)
return nil
}
func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by Name",
},
"vins_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by ViNS ID",
},
"vins_name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by ViNS name",
},
"extnet_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by ExtNetID",
},
"by_ip": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by IP-address",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by RG ID",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
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": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"flipgroup_id": {
Type: schema.TypeInt,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"client_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"client_type": {
Type: schema.TypeString,
Computed: true,
},
"conn_id": {
Type: schema.TypeInt,
Computed: true,
},
"conn_type": {
Type: schema.TypeString,
Computed: true,
},
"default_gw": {
Type: schema.TypeString,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"net_id": {
Type: schema.TypeInt,
Computed: true,
},
"net_type": {
Type: schema.TypeString,
Computed: true,
},
"ip": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"net_mask": {
Type: schema.TypeInt,
Computed: true,
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"meta": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func DataSourceFlipGroupList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceFlipgroupList,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout180s,
Default: &constants.Timeout180s,
},
Schema: dataSourceFlipgroupListSchemaMake(),
}
}

View File

@@ -0,0 +1,99 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package flipgroup
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"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) {
d.Set("account_id", fg.AccountID)
d.Set("account_name", fg.AccountName)
d.Set("client_ids", fg.ClientIDs)
d.Set("client_type", fg.ClientType)
d.Set("conn_id", fg.ConnID)
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("deleted_by", fg.DeletedBy)
d.Set("deleted_time", fg.DeletedTime)
d.Set("desc", fg.Description)
d.Set("gid", fg.GID)
d.Set("guid", fg.GUID)
d.Set("flipgroup_id", fg.ID)
d.Set("ip", fg.IP)
d.Set("milestones", fg.Milestones)
d.Set("name", fg.Name)
d.Set("net_id", fg.NetID)
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("updated_by", fg.UpdatedBy)
d.Set("updated_time", fg.UpdatedTime)
}
func flattenFlipgroupList(fg_list *flipgroup.ListFLIPGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, fg := range fg_list.Data {
temp := map[string]interface{}{
"ckey": fg.CKey,
"meta": flattens.FlattenMeta(fg.Meta),
"account_id": fg.AccountID,
"client_ids": fg.ClientIDs,
"client_type": fg.ClientType,
"conn_id": fg.ConnID,
"conn_type": fg.ConnType,
"default_gw": fg.DefaultGW,
"desc": fg.Description,
"gid": fg.GID,
"guid": fg.GUID,
"flipgroup_id": fg.ID,
"ip": fg.IP,
"milestones": fg.Milestones,
"name": fg.Name,
"net_id": fg.NetID,
"net_type": fg.NetType,
"net_mask": fg.NetMask,
"status": fg.Status,
}
res = append(res, temp)
}
return res
}

View File

@@ -0,0 +1,306 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package flipgroup
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
"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"
log "github.com/sirupsen/logrus"
)
func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceFlipgroupCreate called with name: %s, accountID %v", d.Get("name").(string), d.Get("account_id").(int))
c := m.(*controller.ControllerCfg)
req := flipgroup.CreateRequest{
AccountID: uint64(d.Get("account_id").(int)),
Name: d.Get("name").(string),
NetType: d.Get("net_type").(string),
NetID: uint64(d.Get("net_id").(int)),
ClientType: d.Get("client_type").(string),
IP: d.Get("ip").(string),
Description: d.Get("desc").(string),
}
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(fmt.Sprint(resp.ID))
var warnings dc.Warnings
if client_ids, ok := d.GetOk("client_ids"); ok {
casted := client_ids.([]interface{})
addComputesAfterCreation(ctx, &warnings, c, casted, resp.ID)
}
defer resourceFlipgroupRead(ctx, d, m)
return warnings.Get()
}
func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
flattenFlipgroup(d, fg)
return nil
}
func resourceFlipgroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceFlipgroupUpdate called with id: %v", d.Get("flipgroup_id").(int))
c := m.(*controller.ControllerCfg)
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
var warnings dc.Warnings
basicUpdate := false
req := flipgroup.EditRequest{FLIPGroupID: fg.ID}
if d.HasChange("desc") {
req.Description = d.Get("desc").(string)
basicUpdate = true
}
if d.HasChange("name") {
req.Name = d.Get("name").(string)
basicUpdate = true
}
if basicUpdate {
_, err := c.CloudAPI().FLIPGroup().Edit(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("client_ids") {
handleClientIDsUpdate(ctx, d, c, fg, &warnings)
}
defer resourceFlipgroupRead(ctx, d, m)
return warnings.Get()
}
func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceFlipgroupDelete called with id: %v", d.Get("flipgroup_id").(int))
c := m.(*controller.ControllerCfg)
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
req := flipgroup.DeleteRequest{
FLIPGroupID: fg.ID,
}
_, err = c.CloudAPI().FLIPGroup().Delete(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
Description: "Account ID",
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Flipgroup name",
},
"net_id": {
Type: schema.TypeInt,
Required: true,
Description: "EXTNET or ViNS ID",
},
"net_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, true),
Description: "Network type, EXTNET or VINS",
},
"client_type": {
Type: schema.TypeString,
Required: true,
Description: "Type of client, 'compute' ('vins' will be later)",
ValidateFunc: validation.StringInSlice([]string{"compute"}, true),
},
"ip": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "IP address to associate with this group. If empty, the platform will autoselect IP address",
},
"desc": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Text description of this Flipgroup instance",
},
"client_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
Description: "List of clients attached to this Flipgroup instance",
},
"flipgroup_id": {
Type: schema.TypeInt,
Computed: true,
},
"account_name": {
Type: schema.TypeString,
Computed: true,
},
"conn_id": {
Type: schema.TypeInt,
Computed: true,
},
"conn_type": {
Type: schema.TypeString,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"default_gw": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"network": {
Type: schema.TypeString,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func ResourceFlipgroup() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
CreateContext: resourceFlipgroupCreate,
ReadContext: resourceFlipgroupRead,
UpdateContext: resourceFlipgroupUpdate,
DeleteContext: resourceFlipgroupDelete,
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout300s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceFlipgroupSchemaMake(),
}
}

View File

@@ -0,0 +1,205 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package flipgroup
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
log "github.com/sirupsen/logrus"
)
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.RecordFLIPGroup, warn *dc.Warnings) {
addedClients := make([]interface{}, 0)
removedClients := make([]interface{}, 0)
old_set, new_set := d.GetChange("client_ids")
oldSlice := old_set.([]interface{})
newSlice := new_set.([]interface{})
for _, oldElem := range oldSlice {
if !containsClient(newSlice, oldElem) {
removedClients = append(removedClients, oldElem)
}
}
for _, newElem := range newSlice {
if !containsClient(oldSlice, newElem) {
addedClients = append(addedClients, newElem)
}
}
log.Debugf("Found client_ids change with %v deletion(s) and %v addition(s) [flipgroupID=%v]", len(removedClients), len(addedClients), fg.ID)
if len(addedClients) > 0 {
for _, id := range addedClients {
req := flipgroup.ComputeAddRequest{
FLIPGroupID: fg.ID,
ComputeID: uint64(id.(int)),
}
if _, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req); err != nil {
warn.Add(err)
}
}
}
if len(removedClients) > 0 {
for _, id := range removedClients {
req := flipgroup.ComputeRemoveRequest{
FLIPGroupID: fg.ID,
ComputeID: uint64(id.(int)),
}
if _, err := c.CloudAPI().FLIPGroup().ComputeRemove(ctx, req); err != nil {
warn.Add(err)
}
}
}
}
func containsClient(set []interface{}, check interface{}) bool {
for _, elem := range set {
elemConv := elem.(int)
checkConv := check.(int)
if elemConv == checkConv {
return true
}
}
return false
}
func addComputesAfterCreation(ctx context.Context, warnings *dc.Warnings, c *controller.ControllerCfg, compute_ids []interface{}, flipgroupID uint64) {
if len(compute_ids) == 0 {
return
}
log.Debugf("Adding %v computes to flipgroup [id=%v]...", len(compute_ids), flipgroupID)
for _, elem := range compute_ids {
compute_id := uint64(elem.(int))
req := flipgroup.ComputeAddRequest{
FLIPGroupID: flipgroupID,
ComputeID: compute_id,
}
_, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req)
if err != nil {
warnings.Add(err)
}
}
}
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.RecordFLIPGroup, error) {
c := m.(*controller.ControllerCfg)
req := flipgroup.GetRequest{}
if d.Id() == "" {
req.FLIPGroupID = uint64(d.Get("flipgroup_id").(int))
} else {
id, _ := strconv.ParseUint(d.Id(), 10, 64)
req.FLIPGroupID = id
}
fg, err := c.CloudAPI().FLIPGroup().Get(ctx, req)
if err != nil {
return nil, err
}
return fg, err
}
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ListFLIPGroups, error) {
c := m.(*controller.ControllerCfg)
req := flipgroup.ListRequest{}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if vinsId, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vinsId.(int))
}
if vinsName, ok := d.GetOk("vins_name"); ok {
req.VINSName = vinsName.(string)
}
if extNetId, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extNetId.(int))
}
if byIp, ok := d.GetOk("by_ip"); ok {
req.ByIP = byIp.(string)
}
if rgId, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgId.(int))
}
if byId, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byId.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if 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)
if err != nil {
return nil, err
}
return fg_list, err
}

View File

@@ -34,8 +34,8 @@ package image
import ( import (
"context" "context"
"strconv"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
@@ -44,12 +44,11 @@ import (
func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
image, err := utilityImageCheckPresence(ctx, d, m) image, err := utilityImageCheckPresence(ctx, d, m)
if err != nil { if err != nil {
d.SetId("")
return diag.FromErr(err) return diag.FromErr(err)
} }
id := uuid.New() d.SetId(strconv.Itoa(int(image.ID)))
d.SetId(id.String())
flattenImage(d, image) flattenImage(d, image)

View File

@@ -1,99 +1,165 @@
/* /*
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 {
return diag.FromErr(err) d.SetId("")
} return diag.FromErr(err)
id := uuid.New() }
d.SetId(id.String()) id := uuid.New()
d.Set("items", flattenImageList(imageList)) d.SetId(id.String())
d.Set("items", flattenImageList(imageList))
return nil d.Set("entry_count", imageList.EntryCount)
}
return nil
func dataSourceImageListSchemaMake() map[string]*schema.Schema { }
rets := map[string]*schema.Schema{
"account_id": { func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, rets := map[string]*schema.Schema{
Optional: true, "sep_id": {
Description: "optional account ID to include account images", Type: schema.TypeInt,
}, Optional: true,
"page": { Description: "Filter by Storage Endpoint ID",
Type: schema.TypeInt, },
Optional: true, "by_id": {
Description: "page number", Type: schema.TypeInt,
}, Optional: true,
"size": { Description: "Filter by ID",
Type: schema.TypeInt, },
Optional: true, "name": {
Description: "page size", Type: schema.TypeString,
}, Optional: true,
"items": { Description: "Filter by name",
Type: schema.TypeList, },
Computed: true, "status": {
Description: "image list", Type: schema.TypeString,
Elem: &schema.Resource{ Optional: true,
Schema: dataSourceImageSchemaMake(), Description: "Filter by status",
}, },
}, "architecture": {
} Type: schema.TypeString,
Optional: true,
return rets Description: "Filter by architecture",
} },
"type_image": {
func DataSourceImageList() *schema.Resource { Type: schema.TypeString,
return &schema.Resource{ Optional: true,
SchemaVersion: 1, Description: "Filter by image type",
},
ReadContext: dataSourceImageListRead, "image_size": {
Type: schema.TypeInt,
Timeouts: &schema.ResourceTimeout{ Optional: true,
Read: &constants.Timeout30s, Description: "Filter by image size",
Default: &constants.Timeout60s, },
}, "sep_name": {
Type: schema.TypeString,
Schema: dataSourceImageListSchemaMake(), Optional: true,
} Description: "Filter by SEP name",
} },
"pool": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by pool",
},
"public": {
Type: schema.TypeBool,
Optional: true,
Description: "Find public/private images",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Description: "Find hot resizable images",
},
"bootable": {
Type: schema.TypeBool,
Optional: true,
Description: "Find bootable images",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Description: "image list",
Elem: &schema.Resource{
Schema: dataSourceImageSchemaMake(),
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
}
func DataSourceImageList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceImageListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceImageListSchemaMake(),
}
}

View File

@@ -1,6 +1,9 @@
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"
) )
@@ -20,14 +23,17 @@ 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", img.ACL) d.Set("acl", FlattenACL(img.ACL))
d.Set("architecture", img.Architecture) d.Set("architecture", img.Architecture)
d.Set("boot_type", img.BootType) d.Set("boot_type", img.BootType)
d.Set("bootable", img.Bootable) d.Set("bootable", img.Bootable)
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)
@@ -41,6 +47,7 @@ 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)
@@ -58,30 +65,46 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("version", img.Version) d.Set("version", img.Version)
} }
func flattenImageList(il image.ListImages) []map[string]interface{} { func flattenImageList(il *image.ListImages) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
for _, img := range il { for _, img := range il.Data {
temp := map[string]interface{}{ temp := map[string]interface{}{
"account_id": img.AccountID, "account_id": img.AccountID,
"architecture": img.Architecture, "architecture": img.Architecture,
"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,
"pool_name": img.Pool, "network_interface_naming": img.NetworkInterfaceNaming,
"sep_id": img.SepID, "pool_name": img.Pool,
"size": img.Size, "sep_id": img.SepID,
"status": img.Status, "size": img.Size,
"type": img.Type, "status": img.Status,
"username": img.Username, "type": img.Type,
"virtual": img.Virtual, "username": img.Username,
"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 ""
}
}

View File

@@ -1,216 +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 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": {
"unc_path": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "ckey": {
"ckey": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "account_id": {
"account_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "acl": {
"acl": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "architecture": {
"architecture": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "boot_type": {
"boot_type": { Type: schema.TypeString,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "bootable": {
"bootable": { Type: schema.TypeBool,
Type: schema.TypeBool, Computed: true,
Computed: true, },
}, "compute_ci_id": {
"compute_ci_id": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "cd_presented_to": {
"deleted_time": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "deleted_time": {
"desc": { Type: schema.TypeInt,
Type: schema.TypeString, Computed: true,
Computed: true, },
}, "desc": {
"drivers": { Type: schema.TypeString,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Schema{ "drivers": {
Type: schema.TypeString, Type: schema.TypeList,
}, Computed: true,
}, Elem: &schema.Schema{
"enabled": { Type: schema.TypeString,
Type: schema.TypeBool, },
Computed: true, },
}, "enabled": {
"gid": { Type: schema.TypeBool,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "gid": {
"guid": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "guid": {
"history": { Type: schema.TypeInt,
Type: schema.TypeList, Computed: true,
Computed: true, },
Elem: &schema.Resource{ "history": {
Schema: map[string]*schema.Schema{ Type: schema.TypeList,
"guid": { Computed: true,
Type: schema.TypeString, Elem: &schema.Resource{
Computed: true, Schema: map[string]*schema.Schema{
}, "guid": {
"id": { Type: schema.TypeString,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "id": {
"timestamp": { Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
Computed: true, },
}, "timestamp": {
}, Type: schema.TypeInt,
}, Computed: true,
}, },
"hot_resize": { },
Type: schema.TypeBool, },
Computed: true, },
}, "hot_resize": {
Type: schema.TypeBool,
"last_modified": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "last_modified": {
}, Type: schema.TypeInt,
"link_to": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "link_to": {
}, Type: schema.TypeInt,
"milestones": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "milestones": {
}, Type: schema.TypeInt,
"image_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "image_name": {
}, Type: schema.TypeString,
"password": { Computed: true,
Type: schema.TypeString, },
Computed: true, "network_interface_naming": {
}, Type: schema.TypeString,
"pool_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "password": {
}, Type: schema.TypeString,
"provider_name": { Computed: true,
Type: schema.TypeString, },
Computed: true, "pool_name": {
}, Type: schema.TypeString,
"purge_attempts": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "provider_name": {
}, Type: schema.TypeString,
"present_to": { Computed: true,
Type: schema.TypeList, },
Computed: true, "purge_attempts": {
Elem: &schema.Schema{ Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
}, },
}, "present_to": {
"res_id": { Type: schema.TypeList,
Type: schema.TypeString, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"rescuecd": { },
Type: schema.TypeBool, },
Computed: true, "res_id": {
}, Type: schema.TypeString,
"sep_id": { Computed: true,
Type: schema.TypeInt, },
Computed: true, "rescuecd": {
}, Type: schema.TypeBool,
"shared_with": { Computed: true,
Type: schema.TypeList, },
Computed: true, "sep_id": {
Elem: &schema.Schema{ Type: schema.TypeInt,
Type: schema.TypeInt, Computed: true,
}, },
}, "shared_with": {
"size": { Type: schema.TypeList,
Type: schema.TypeInt, Computed: true,
Computed: true, Elem: &schema.Schema{
}, Type: schema.TypeInt,
"status": { },
Type: schema.TypeString, },
Computed: true, "size": {
}, Type: schema.TypeInt,
"tech_status": { Computed: true,
Type: schema.TypeString, },
Computed: true, "status": {
}, Type: schema.TypeString,
"type": { Computed: true,
Type: schema.TypeString, },
Computed: true, "tech_status": {
}, Type: schema.TypeString,
"username": { Computed: true,
Type: schema.TypeString, },
Computed: true, "type": {
}, Type: schema.TypeString,
"version": { Computed: true,
Type: schema.TypeString, },
Computed: true, "username": {
}, Type: schema.TypeString,
} Computed: true,
} },
"version": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -94,6 +94,10 @@ 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,

View File

@@ -1,159 +1,160 @@
/* /*
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["gid"] = &schema.Schema{ sch["image_id"] = &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Optional: true,
Description: "grid (platform) ID where this template should be create in", Computed: true,
} Description: "image id",
}
sch["image_id"] = &schema.Schema{
Type: schema.TypeInt, sch["boot_type"] = &schema.Schema{
Optional: true, Type: schema.TypeString,
Computed: true, Required: true,
Description: "image id", ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
} Description: "Boot type of image bios or uefi",
}
sch["boot_type"] = &schema.Schema{
Type: schema.TypeString, sch["type"] = &schema.Schema{
Required: true, Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), Required: true,
Description: "Boot type of image bios or uefi", ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
} Description: "Image type linux, windows or other",
}
sch["type"] = &schema.Schema{
Type: schema.TypeString, sch["hot_resize"] = &schema.Schema{
Required: true, Type: schema.TypeBool,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), Optional: true,
Description: "Image type linux, windows or other", Computed: true,
} Description: "Does this machine supports hot resize",
}
sch["hot_resize"] = &schema.Schema{
Type: schema.TypeBool, sch["username"] = &schema.Schema{
Optional: true, Type: schema.TypeString,
Computed: true, Optional: true,
Description: "Does this machine supports hot resize", Computed: true,
} Description: "Optional username for the image",
}
sch["username"] = &schema.Schema{
Type: schema.TypeString, sch["password"] = &schema.Schema{
Optional: true, Type: schema.TypeString,
Computed: true, Optional: true,
Description: "Optional username for the image", Computed: true,
} Description: "Optional password for the image",
}
sch["password"] = &schema.Schema{
Type: schema.TypeString, sch["account_id"] = &schema.Schema{
Optional: true, Type: schema.TypeInt,
Computed: true, Required: true,
Description: "Optional password for the image", Description: "AccountId to make the image exclusive",
} }
sch["account_id"] = &schema.Schema{ sch["username_dl"] = &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Description: "username for upload binary media",
Description: "AccountId to make the image exclusive", }
}
sch["password_dl"] = &schema.Schema{
sch["username_dl"] = &schema.Schema{ Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Optional: true, Description: "password for upload binary media",
Description: "username for upload binary media", }
}
sch["pool_name"] = &schema.Schema{
sch["password_dl"] = &schema.Schema{ Type: schema.TypeString,
Type: schema.TypeString, Optional: true,
Optional: true, Computed: true,
Description: "password for upload binary media", Description: "pool for image create",
} }
sch["pool_name"] = &schema.Schema{ sch["sep_id"] = &schema.Schema{
Type: schema.TypeString, Type: schema.TypeInt,
Optional: true, Optional: true,
Computed: true, Computed: true,
Description: "pool for image create", Description: "storage endpoint provider ID",
} }
sch["sep_id"] = &schema.Schema{ sch["architecture"] = &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Computed: true,
Description: "storage endpoint provider ID", ValidateFunc: validation.StringInSlice([]string{"X86_64", "PPC64_LE"}, true),
} Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
}
sch["architecture"] = &schema.Schema{
Type: schema.TypeString, sch["drivers"] = &schema.Schema{
Optional: true, Type: schema.TypeList,
Computed: true, Required: true,
ValidateFunc: validation.StringInSlice([]string{"X86_64", "PPC64_LE"}, true), Elem: &schema.Schema{
Description: "binary architecture of this image, one of X86_64 of PPC64_LE", Type: schema.TypeString,
} },
}
sch["drivers"] = &schema.Schema{
Type: schema.TypeList, sch["permanently"] = &schema.Schema{
Required: true, Type: schema.TypeBool,
Elem: &schema.Schema{ Optional: true,
Type: schema.TypeString, Default: false,
}, Description: "whether to completely delete the image",
} }
sch["permanently"] = &schema.Schema{ sch["network_interface_naming"] = &schema.Schema{
Type: schema.TypeBool, Type: schema.TypeString,
Optional: true, Optional: true,
Default: false, Computed: true,
Description: "whether to completely delete the image", ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true),
} Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming",
}
return sch
} return sch
}

View File

@@ -2,9 +2,12 @@ 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"
) )
@@ -19,7 +22,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
return false, err return false, err
} }
return len(accounts.FilterByID(accountId)) != 0, nil return len(accounts.FilterByID(accountId).Data) != 0, nil
} }
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
@@ -32,5 +35,48 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
return false, err return false, err
} }
return len(locationList.FilterByGID(gid)) != 0, nil return len(locationList.FilterByGID(gid).Data) != 0, nil
}
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
} }

View File

@@ -1,272 +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 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))
haveGID, err := existGID(ctx, d, m) haveAccountID, err := existAccountID(ctx, d, m)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
if !haveGID { if !haveAccountID {
return diag.Errorf("resourceImageCreate: can't create Image because GID %d is not allowed or does not exist", d.Get("gid").(int)) return diag.Errorf("resourceImageCreate: can't create Image because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
} }
if _, ok := d.GetOk("account_id"); ok { c := m.(*controller.ControllerCfg)
haveAccountID, err := existAccountID(ctx, d, m) req := image.CreateRequest{
if err != nil { AccountID: uint64(d.Get("account_id").(int)),
return diag.FromErr(err) Name: d.Get("name").(string),
} URL: d.Get("url").(string),
BootType: d.Get("boot_type").(string),
if !haveAccountID { ImageType: d.Get("type").(string),
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{}) {
c := m.(*controller.ControllerCfg) drivers = append(drivers, driver.(string))
req := image.CreateRequest{} }
req.Name = d.Get("name").(string) req.Drivers = drivers
req.URL = d.Get("url").(string)
req.GID = uint64(d.Get("gid").(int)) if hotresize, ok := d.GetOk("hot_resize"); ok {
req.BootType = d.Get("boot_type").(string) req.HotResize = hotresize.(bool)
req.ImageType = d.Get("type").(string) }
if username, ok := d.GetOk("username"); ok {
drivers := []string{} req.Username = username.(string)
for _, driver := range d.Get("drivers").([]interface{}) { }
drivers = append(drivers, driver.(string)) if password, ok := d.GetOk("password"); ok {
} req.Password = password.(string)
}
req.Drivers = drivers if usernameDL, ok := d.GetOk("username_dl"); ok {
req.UsernameDL = usernameDL.(string)
if hotresize, ok := d.GetOk("hot_resize"); ok { }
req.HotResize = hotresize.(bool) if passwordDL, ok := d.GetOk("password_dl"); ok {
} req.PasswordDL = passwordDL.(string)
if username, ok := d.GetOk("username"); ok { }
req.Username = username.(string) if sepId, ok := d.GetOk("sep_id"); ok {
} req.SEPID = uint64(sepId.(int))
if password, ok := d.GetOk("password"); ok { }
req.Password = password.(string) if poolName, ok := d.GetOk("pool_name"); ok {
} req.Pool = poolName.(string)
if accountId, ok := d.GetOk("account_id"); ok { }
req.AccountID = uint64(accountId.(int)) if architecture, ok := d.GetOk("architecture"); ok {
} req.Architecture = architecture.(string)
if usernameDL, ok := d.GetOk("username_dl"); ok { }
req.UsernameDL = usernameDL.(string) if networkInterfaceNaming, ok := d.GetOk("network_interface_naming"); ok {
} 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 sepId, ok := d.GetOk("sep_id"); ok { if err != nil {
req.SEPID = uint64(sepId.(int)) d.SetId("")
} return diag.FromErr(err)
if poolName, ok := d.GetOk("pool_name"); ok { }
req.Pool = poolName.(string)
} d.SetId(strconv.FormatUint(imageId, 10))
if architecture, ok := d.GetOk("architecture"); ok { d.Set("image_id", imageId)
req.Architecture = architecture.(string)
} _, err = utilityImageCheckPresence(ctx, d, m)
if err != nil {
imageId, err := c.CloudAPI().Image().Create(ctx, req) return diag.FromErr(err)
if err != nil { }
return diag.FromErr(err)
} return resourceImageRead(ctx, d, m)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId) func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
_, err = utilityImageCheckPresence(ctx, d, m)
if err != nil { img, err := utilityImageCheckPresence(ctx, d, m)
return diag.FromErr(err) if img == nil {
} d.SetId("")
return diag.FromErr(err)
return resourceImageRead(ctx, d, m) }
}
switch img.Status {
func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { case status.Modeled:
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id()) return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
case status.Creating:
img, err := utilityImageCheckPresence(ctx, d, m) case status.Created:
if img == nil { case status.Destroyed, status.Purged:
d.SetId("") d.SetId("")
return diag.FromErr(err) return diag.Errorf("The resource cannot be updated because it has been destroyed")
} // return resourceImageCreate(ctx, d, m)
}
switch img.Status {
case status.Modeled: flattenImage(d, img)
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
case status.Creating: return nil
case status.Created: }
case status.Destroyed, status.Purged:
d.SetId("") func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
return resourceImageCreate(ctx, d, m) log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
}
_, err := utilityImageCheckPresence(ctx, d, m)
flattenImage(d, img) if err != nil {
d.SetId("")
return nil return diag.FromErr(err)
} }
func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { c := m.(*controller.ControllerCfg)
log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id()) req := image.DeleteRequest{
ImageID: uint64(d.Get("image_id").(int)),
_, err := utilityImageCheckPresence(ctx, d, m) }
if err != nil {
return diag.FromErr(err) if permanently, ok := d.GetOk("permanently"); ok {
} req.Permanently = permanently.(bool)
}
c := m.(*controller.ControllerCfg)
req := image.DeleteRequest{ _, err = c.CloudAPI().Image().Delete(ctx, req)
ImageID: uint64(d.Get("image_id").(int)), if err != nil {
} return diag.FromErr(err)
}
if permanently, ok := d.GetOk("permanently"); ok {
req.Permanently = permanently.(bool) d.SetId("")
}
return nil
_, err = c.CloudAPI().Image().Delete(ctx, req) }
if err != nil {
return diag.FromErr(err) func resourceImageRename(ctx context.Context, d *schema.ResourceData, m interface{}) error {
} log.Debugf("resourceImageEditName: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
d.SetId("") req := image.RenameRequest{
ImageID: uint64(d.Get("image_id").(int)),
return nil Name: d.Get("name").(string),
} }
func resourceImageRename(ctx context.Context, d *schema.ResourceData, m interface{}) error { _, err := c.CloudAPI().Image().Rename(ctx, req)
log.Debugf("resourceImageEditName: called for %s, id: %s", d.Get("name").(string), d.Id()) if err != nil {
c := m.(*controller.ControllerCfg) return err
req := image.RenameRequest{ }
ImageID: uint64(d.Get("image_id").(int)),
Name: d.Get("name").(string), return nil
} }
_, err := c.CloudAPI().Image().Rename(ctx, req) func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
if err != nil { log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
return err
} haveGID, err := existGID(ctx, d, m)
if err != nil {
return nil return diag.FromErr(err)
} }
func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { if !haveGID {
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id()) return diag.Errorf("resourceImageUpdate: can't update Image because GID %d is not allowed or does not exist", d.Get("gid").(int))
}
haveGID, err := existGID(ctx, d, m)
if err != nil { haveAccountID, err := existAccountID(ctx, d, m)
return diag.FromErr(err) if err != nil {
} return diag.FromErr(err)
}
if !haveGID {
return diag.Errorf("resourceImageUpdate: can't update Image because GID %d is not allowed or does not exist", d.Get("gid").(int)) 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))
}
if _, ok := d.GetOk("account_id"); ok {
haveAccountID, err := existAccountID(ctx, d, m) image, err := utilityImageCheckPresence(ctx, d, m)
if err != nil { if image == nil {
return diag.FromErr(err) if err != nil {
} return diag.FromErr(err)
}
if !haveAccountID { return nil
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:
image, err := utilityImageCheckPresence(ctx, d, m) return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status)
if image == nil { case status.Creating:
if err != nil { case status.Created:
return diag.FromErr(err) case status.Destroyed, status.Purged:
} d.SetId("")
return nil return diag.Errorf("The resource cannot be updated because it has been destroyed")
} // return resourceImageCreate(ctx, d, m)
}
switch image.Status {
case status.Modeled: if d.HasChange("name") {
return diag.Errorf("The image is in status: %s, please, contact support for more information", image.Status) err := resourceImageRename(ctx, d, m)
case status.Creating: if err != nil {
case status.Created: return diag.FromErr(err)
case status.Destroyed, status.Purged: }
d.SetId("") }
return resourceImageCreate(ctx, d, m)
} return resourceImageRead(ctx, d, m)
}
if d.HasChange("name") {
err := resourceImageRename(ctx, d, m) func ResourceImage() *schema.Resource {
if err != nil { return &schema.Resource{
return diag.FromErr(err) SchemaVersion: 1,
}
} CreateContext: resourceImageCreate,
ReadContext: resourceImageRead,
return resourceImageRead(ctx, d, m) UpdateContext: resourceImageUpdate,
} DeleteContext: resourceImageDelete,
func ResourceImage() *schema.Resource { Importer: &schema.ResourceImporter{
return &schema.Resource{ StateContext: schema.ImportStatePassthroughContext,
SchemaVersion: 1, },
CreateContext: resourceImageCreate, Timeouts: &schema.ResourceTimeout{
ReadContext: resourceImageRead, Create: &constants.Timeout600s,
UpdateContext: resourceImageUpdate, Read: &constants.Timeout300s,
DeleteContext: resourceImageDelete, Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Importer: &schema.ResourceImporter{ Default: &constants.Timeout300s,
StateContext: schema.ImportStatePassthroughContext, },
},
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
Timeouts: &schema.ResourceTimeout{ }
Create: &constants.Timeout600s, }
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
}
}

View File

@@ -0,0 +1,508 @@
/*
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,
},
}
}

View File

@@ -0,0 +1,506 @@
/*
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,
},
}
}

View File

@@ -50,7 +50,7 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{ req := image.CreateVirtualRequest{
Name: d.Get("name").(string), Name: d.Get("name").(string),
TargetID: uint64(d.Get("target_id").(int)), TargetID: uint64(d.Get("link_to").(int)),
} }
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req) imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)

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