diff --git a/CHANGELOG.md b/CHANGELOG.md index d2fd7c24..34118976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,241 @@ -## Version 4.11.2 +## Version 4.12.0 ### Добавлено +#### account +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1244 | Вычисляемое поле `updated_by` в datasources `decort_account_list` и `decort_account_deleted_list` в cloudapi/account | +| BATF-1232 | Вычисляемое поле `deleted_by` в datasources `decort_account_list` и `decort_account_deleted_list` в cloudapi/account | +| BATF-1226 | Вычисляемое поле `updated_by` в resource `decort_cb_account` и datasources `decort_cb_account`, `decort_cb_account_list`, `decort_cb_account_list_deleted` и `decort_cb_account_computes_list` в cloudbroker/account | +| BATF-1226 | Вычисляемое поле `updated_by` в resource `decort_account` и datasource `decort_account` в cloudapi/account | + +#### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1231 | Опциональные поля `rg_id` и `compute_id` в datasource `decort_cb_disk_list` в cloudbroker/disks | +| BATF-1231 | Опциональные поля `rg_id` и `compute_id` в datasource `decort_disk_list` в cloudapi/disks | +| BATF-1224 | Опциональное поле `block_size` в resource `decort_cb_disk` в cloudbroker/disks | +| BATF-1224 | Вычисляемое поле `block_size` в datasources `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` и `decort_cb_disk_list_unattached` в cloudbroker/disks | +| BATF-1224 | Вычисляемое поле `block_size` в datasources `decort_disk`, `decort_disk_list`, `decort_disk_list_deleted` и `decort_disk_list_unattached` и в resource `decort_disk` в cloudapi/disks | +| BATF-1247 | Вычисляемое поле `to_clean` в datasource `decort_disk_list_unattached` в cloudapi/disks и в datasource `decort_cb_disk_list_unattached` в cloudbroker/disks | +| BATF-1245 | Вычисляемое поле `independent` в datasources `decort_disk`, `decort_disk_list` и `decort_disk_list_deleted` в cloudapi/disks и в datasources `decort_cb_disk`, `decort_cb_disk_list` и `decort_cb_disk_list_deleted` в cloudbroker/disks | +| BATF-1245 | Вычисляемое поле `independent` в resource `decort_disk` в cloudapi/disks и в resource `decort_cb_disk` в cloudbroker/disks | +| BATF-1252 | Вычисляемое поле `present_to` в datasource `decort_disk_list_unattached` в cloudapi/disks | +| BATF-1252 | Вычисляемое поле `provision` в datasources `decort_disk`, `decort_disk_list`, `decort_disk_list_deleted` и `decort_disk_list_unattached` и в resource `decort_disk` в cloudapi/disks | +| BATF-1252 | Вычисляемое поле `provision` в datasources `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` и `decort_cb_disk_list_unattached` и в resource `decort_cb_disk` в cloudbroker/disks | + +#### grid +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1265 | Вычисляемое поле `zero_access_enabled` в datasource `decort_cb_grid_list` в cloudbroker/grid | + +#### image +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1245 | Вычисляемое поле `independent` в datasource `decort_image` в cloudapi/image и в datasources `decort_cb_image` и `decort_cb_image_list` в cloudbroker/image | +| BATF-1245 | Вычисляемое поле `independent` в resources `decort_image` и `decort_image_virtual` в cloudapi/image и в resources `decort_cb_image` и `decort_cb_virtual_image` в cloudbroker/image | +| BATF-1256 | Вычисляемое поле `links_to` в datasources `decort_image` и `decort_image_list` и в resources `decort_image`, `decort_image_from_blank_compute` и `decort_image_from_platform_disk` в cloudapi/image | +| BATF-1256 | Вычисляемое поле `links_to` в datasources `decort_cb_image` и `decort_cb_image_list` и в resources `decort_cb_image`, `decort_cb_image_from_blank_compute` и `decort_cb_image_from_platform_disk` в cloudbroker/image | +| BATF-1255 | Resource `decort_cb_multi_image` в cloudbroker/image | +| BATF-1262 | Обязательное поле `storage_policy_id` в resources `decort_image_from_blank_compute` в cloudapi/image и в `decort_cb_image_from_blank_compute` в cloudbroker/image | + #### kvmvm | Идентификатор
задачи | Описание | | --- | --- | -| BATF-1270 | Опциональное поле `iotune` в блоке `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | \ No newline at end of file +| BATF-1251 | Вычисляемое поле `provision` в блоке `disks` в resource `decort_cb_kvmvm` и datasource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1251 | Вычисляемое поле `provision` в блоке `disks` в resource `decort_kvmvm` и datasource `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1251 | Вычисляемое поле `provision` в блоке `boot_disk` в resource `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1225 | Опциональное поле `block_size` в блоке `disks` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1225 | Вычисляемое поле `block_size` в блоке `disks` в datasource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1225 | Вычисляемое поле `block_size` в блоке `disks` в resource `decort_kvmvm` и datasource `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1229 | Вычисляемое поле `weight` в datasources `decort_cb_kvmvm`, `decort_cb_kvmvm_list` и `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm и в datasources `decort_kvmvm`, `decort_kvmvm_list` и `decort_kvmvm_list_deleted` в cloudapi/kvmvm | +| BATF-1229 | Опциональное поле `weight` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1229 | Вычисляемое поле `weight` в resource `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1245 | Вычисляемое поле `independent` в блоке `disks` в datasource `decort_kvmvm` в cloudapi/kvmvm и в datasource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1245 | Вычисляемое поле `independent` в блоке `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1264 | Ограничения на типы сетей при использования поля `security_groups` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1267 | Проверка типа сети ВМ на TRUNK для добавления опционального поля `mtu` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1001 | Проверка типа сети ВМ на SDN в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1270 | Опциональное поле `iotune` в блоке `disks` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1270 | Опциональное поле `iotune` в блоке `disks` в resource `decort_kvmvm` в cloudapi/kvmvm | +| BATF-1276 | Добавлено опциональное поле `create_blank` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1276 | Опциональное поле `alt_boot_id` в resource `decort_kvmvm` в cloudapi/kvmvm | + +#### locations +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1261 | Вычисляемое поле `ZeroAccessEnabled` в datasource `decort_locations_list` в cloudapi/locations | +| BATF-1275 | Вычисляемое поле `BROEnabled` в datasource `decort_locations_list` в cloudapi/locations | + +#### node +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1223 | Опциональное поле `zone_id` в datasource `decort_cb_node_list` в cloudbroker/node | +| BATF-1254 | Вычисляемое поле `thread_count` в блок `cpu_info` в datasources `decort_cb_node` и `decort_cb_node_list` в cloudbroker/node | + +#### rg +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1228 | Вычисляемое поле `email` в блоке `acl` в resource и datasource `decort_resgroup` в cloudapi/rg | +| BATF-1228 | Вычисляемое поле `email` в блоке `acl` в resource и datasource `decort_cb_rg` в cloudbroker/rg | + +#### storage policy +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1235 | Вычисляемое поле `sep_tech_status` в блок `access_seps_pools` в resource `decort_cb_storage_policy` и в datasource `decort_cb_storage_policy` в cloudbroker/stpolicy | +| BATF-1235 | Вычисляемое поле `sep_tech_status` в блок `access_seps_pools` datasource `decort_storage_policy` в cloudapi/stpolicy | + +#### vins +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1266 | Опциональное поле `enable_secgroups` в resource `decort_vins` в cloudapi/vins | + +#### SDN logical ports +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1271 | Опциональное поле `labels` в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `labels` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` в sdn/logicalports | +| BATF-1271 | Опциональное поле `migrate` в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `hypervisor_status` в блоке `status` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `logical_port_addresses` в блоке `bindings` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `external_network_id` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` в sdn/logicalports | +| BATF-1271 | Опциональное поле `operation_status` в datasource `decort_sdn_logical_port_list` в sdn/logicalports | +| BATF-1271 | Опциональное поле `hypervisor_status` в datasource `decort_sdn_logical_port_list` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `operation_status` в блоке `status` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `operation_status` в блоке `hypervisors` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | + + +#### SDN segments +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1157 | Опциональное поле `operation_status` в datasource `decort_sdn_segment_list` в sdn/segments | +| BATF-1157 | Опциональное поле `type` в resource `decort_sdn_segment` в sdn/segments | +| BATF-1157 | Вычисляемое поле `type` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` в sdn/segments | +| BATF-1157 | Вычисляемое поле `operation_status` в блоке `status` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` и в resource `decort_sdn_segment` в sdn/segments | +| BATF-1157 | Вычисляемое поле `operation_status` в блоке `hypervisors` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` и в resource `decort_sdn_segment` в sdn/segments | +| BATF-1157 | Вычисляемое поле `l2_connection_port` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` и в resource `decort_sdn_segment` в sdn/segments | + +#### SDN hypervisors +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1113 | Resource `decort_sdn_hypervisor` и datasources `decort_sdn_hypervisor` и `decort_sdn_hypervisor_list` в sdn/hypervisors | + +#### SDN access group +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1155 | Опциональное поле `owner_display_name` в datasource `decort_sdn_access_group_list` в sdn/access_group | + + +#### SDN network object group +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1115| Resource `decort_sdn_network_object_group`, datasources `decort_sdn_network_object_group` и `decort_sdn_network_object_group_list` в sdn/netobjgroups | + +#### zone +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1259 | Вычисляемые поля `drs`, `drs_uid`, `drs_name`, `sso_url`, `app_id` и `decort_url` в datasources `decort_zone` и `decort_zone_list` в cloudapi/zone и в datasources `decort_cb_zone` и `decort_cb_zone_list` в cloudbroker/zone | +| BATF-1259 | Опциональное поле `drs` и вычисляемые поля `drs`, `drs_uid`, `drs_name`, `sso_url`, `app_id` и `decort_url` в resource `decort_cb_zone` в cloudbroker/zone | +| BATF-1273 | Вычисляемые поля `ping_addr`, `broadcast_addr`, `ssl_skip_verify`, `domain` и `sso_type` в datasources `decort_zone` и `decort_zone_list` в cloudapi/zone и в datasources `decort_cb_zone` и `decort_cb_zone_list` в cloudbroker/zone | +| BATF-1273 | Вычисляемые поля `ping_addr`, `broadcast_addr`, `ssl_skip_verify`, `domain` и `sso_type` в resource `decort_cb_zone` в cloudbroker/zone | + +### Изменено + +#### kvmvm +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1249 | Минимальное значение опционального поля `mtu` в блоке `network` с 1 на 1500 в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | + +#### node +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1258 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в блоке `FreeResourcesInfo` в datasource `decort_cb_node` в cloudbroker/node | + +#### zone +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1253 | Поле `lb_ids` было переименовано в `lbs_ids` в datasource `decort_zone` в cloudapi/zone | + +### Исправлено + +#### flipgroup +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1283 | Установка поля `desc` с платформы в ресурсе `decort_cb_flipgroup` в cloudbroker/flipgroup | + +#### dpdknet +| Идентификатор
задачи | Описание | +| --- | --- +| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_dpdknet` в cloudbroker/dpdknet | + +#### extnet +| Идентификатор
задачи | Описание | +| --- | --- +| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_extnet` в cloudbroker/extnet | + +#### kvmvm +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1276 | Ошибка при старте ВМ с указанием поля `alt_boot_id` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | + +#### rg +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1214 | Поведение ресурса при использовании параметра `net_type` в блоке `def_net` со значением `PRIVATE` в resource `decort_resgroup` в cloudapi/rg и в resource `decort_cb_rg` в cloudbroker/rg | + +#### vins +| Идентификатор
задачи | Описание | +| --- | --- +| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_vins` в cloudbroker/vins | + +#### SDN logical ports +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1271 | Формирование списка `remove_addresses` при обновлении `logical_port_addresses` в resource `decort_sdn_logical_port` в sdn/logicalports | + +#### trunk +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1285 | Установка полей `account_ids`, `ovs_bridge`, `native_vlan_id`, `trunk_tags` с платформы в ресурсе `decort_cb_trunk ` в cloudbroker/trunk | + +#### vfpool +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1289 | Разрешено создавать пул виртуальных функций с блоком `config` при значении поля `enable` равным `false` в resource `decort_cb_vfpool` в cloudbroker/vfpool | +| BATF-1289 | Разрешено обновлять поля `name`, `description`, `account_access` и `rg_access` без блока `config` в resource `decort_cb_vfpool` в cloudbroker/vfpool | + +### Удалено + +#### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1233 | datasources `decort_disk_list_types`, `decort_disk_list_types_detailed` в cloudapi/disks и `decort_cb_disk_list_types`, `decort_cb_disk_list_types_detailed` в cloudbroker/disks | +| BATF-1233 | Опциональное поле `type` из resource `decort_disk` в cloudapi/disks и из resource `decort_cb_disk` в cloudbroker/disks | +| BATF-1233 | Вычисляемое поле `type` из datasources `decort_disk`, `decort_disk_list`, `decort_disk_list_deleted`, `decort_disk_list_unattached` и в cloudapi/disks и `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted`, `decort_cb_disk_list_unattached` и в cloudbroker/disks | + +#### kvmvm +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1233 | Опциональное поле `disk_type` из блока `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1227 | Опциональные поля `is` и `ipa_type` из resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1227 | Опциональные поля `is` и `ipa_type` из resource `decort_kvmvm` в cloudapi/kvmvm | + +#### storage policy +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1235 | Вычисляемое поле `storage_policy_id` из resource `decort_cb_storage_policy` в cloudbroker/stpolicy | + +#### SDN logical ports +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1271 | Вычисляемое поле `is_excluded_from_firewall` в блоке `bindings` из datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и из resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `common` в блоке `status` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | +| BATF-1271 | Вычисляемое поле `status` в блоке `hypervisors` в datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_list` и `decort_sdn_logical_port_get_by_unique_identifier` и в resource `decort_sdn_logical_port` в sdn/logicalports | + +#### SDN segments +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1157 | Datasource `decort_sdn_segment_get_status` в sdn/segments | +| BATF-1157 | Вычисляемое поле `common` в блоке `status` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` и в resource `decort_sdn_segment` в sdn/segments | +| BATF-1157 | Вычисляемое поле `status` в блоке `hypervisors` в datasources `decort_sdn_segment` и `decort_sdn_segment_list` и в resource `decort_sdn_segment` в sdn/segments | diff --git a/Makefile b/Makefile index c87f6772..4a2fda73 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ZIPDIR = ./zip BINARY=${NAME} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} MAINPATH = ./cmd/decort/ -VERSION=4.11.2 +VERSION=4.12.0 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) FILES = ${BINARY}_${VERSION}_darwin_amd64\ diff --git a/README.md b/README.md index 8316d73a..f379f63d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Terraform provider для платформы Digital Energy Cloud Orchestration | Версия DECORT API | Версия провайдера Terraform | | ------ | ------ | +| 4.6.0 | 4.12.x | | 4.5.0 | 4.11.x | | 4.4.0 | 4.10.x | | 4.3.0 | 4.9.x | @@ -82,7 +83,9 @@ Terraform provider для платформы Digital Energy Cloud Orchestration - Режим SDN: - Работа с access groups, - Работа с default security policies, - - Работа с segments + - Работа с hypervisors, + - Работа с segments, + - Работа с network object groups Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki @@ -100,13 +103,13 @@ chmod u+x install.sh ``` 6. Дождаться сообщения об успешной установке. Установщик выведет актуальный блок конфигурации провайдера, скопируйте его ```bash -DECORT provider version 4.11.0 has been successfully installed +DECORT provider version 4.12.0 has been successfully installed Copy this provider configuration to main.tf file: terraform { required_providers { decort = { - version = "4.11.0" + version = "4.12.0" source = "basis/decort/decort" } } @@ -165,13 +168,13 @@ Windows: - host_name - имя хоста, держателя провайдера, например, basis - namespace - пространство имен хоста, например decort - type - тип провайдера, может совпадать с пространством имен, например, decort -- version - версия провайдера, например 4.11.0 +- version - версия провайдера, например 4.12.0 - target - архитектура операционной системы, например windows_amd64 В примере ниже используется путь до провайдера на машине с ОС Linux: ```bash -~/.terraform.d/plugins/basis/decort/decort/4.11.0/linux_amd64/tf-provider +~/.terraform.d/plugins/basis/decort/decort/4.12.0/linux_amd64/tf-provider ^ ^ ^ ^ ^ ^ host_name | | | | | | | | | | | @@ -196,7 +199,7 @@ Windows: terraform { required_providers { decort = { - version = "4.11.0" + version = "4.12.0" source = "basis/decort/decort" } } diff --git a/docs/data-sources/account.md b/docs/data-sources/account.md index ba59c0ca..30f6939f 100644 --- a/docs/data-sources/account.md +++ b/docs/data-sources/account.md @@ -49,6 +49,7 @@ description: |- - `send_access_emails` (Boolean) - `status` (String) - `storage_policy_ids` (List of Number) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/data-sources/account_deleted_list.md b/docs/data-sources/account_deleted_list.md index 4f472678..0adab393 100644 --- a/docs/data-sources/account_deleted_list.md +++ b/docs/data-sources/account_deleted_list.md @@ -51,9 +51,11 @@ Read-Only: - `acl` (List of Object) (see [below for nested schema](#nestedobjatt--items--acl)) - `compute_features` (List of String) - `created_time` (Number) +- `deleted_by` (String) - `deleted_time` (Number) - `desc` (String) - `status` (String) +- `updated_by` (String) - `updated_time` (Number) - `zone_ids` (List of Number) diff --git a/docs/data-sources/account_list.md b/docs/data-sources/account_list.md index d3bc6a84..509348ae 100644 --- a/docs/data-sources/account_list.md +++ b/docs/data-sources/account_list.md @@ -52,9 +52,11 @@ Read-Only: - `acl` (List of Object) (see [below for nested schema](#nestedobjatt--items--acl)) - `compute_features` (List of String) - `created_time` (Number) +- `deleted_by` (String) - `deleted_time` (Number) - `desc` (String) - `status` (String) +- `updated_by` (String) - `updated_time` (Number) - `zone_ids` (List of Number) diff --git a/docs/data-sources/cb_account.md b/docs/data-sources/cb_account.md index 088e3380..c3a9dff7 100644 --- a/docs/data-sources/cb_account.md +++ b/docs/data-sources/cb_account.md @@ -49,6 +49,7 @@ description: |- - `status` (String) - `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/data-sources/cb_account_list.md b/docs/data-sources/cb_account_list.md index f73e2aad..1d5725c2 100644 --- a/docs/data-sources/cb_account_list.md +++ b/docs/data-sources/cb_account_list.md @@ -71,6 +71,7 @@ Read-Only: - `status` (String) - `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/data-sources/cb_account_list_deleted.md b/docs/data-sources/cb_account_list_deleted.md index 07715658..76dc470e 100644 --- a/docs/data-sources/cb_account_list_deleted.md +++ b/docs/data-sources/cb_account_list_deleted.md @@ -69,6 +69,7 @@ Read-Only: - `status` (String) - `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/data-sources/cb_disk.md b/docs/data-sources/cb_disk.md index 05a38afe..28751371 100644 --- a/docs/data-sources/cb_disk.md +++ b/docs/data-sources/cb_disk.md @@ -29,6 +29,7 @@ description: |- - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedatt--computes)) @@ -46,6 +47,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedatt--iotune)) - `iqn` (String) - `login` (String) @@ -59,6 +61,7 @@ description: |- - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -78,7 +81,6 @@ description: |- - `storage_policy_id` (Number) Storage policy ID - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/data-sources/cb_disk_list.md b/docs/data-sources/cb_disk_list.md index ace64ac9..505986f6 100644 --- a/docs/data-sources/cb_disk_list.md +++ b/docs/data-sources/cb_disk_list.md @@ -20,10 +20,12 @@ description: |- - `account_id` (Number) ID of the account the disks belong to - `account_name` (String) Find by account name - `by_id` (Number) Find by ID +- `compute_id` (Number) Find by compute id - `disk_max_size` (Number) Find by max disk size - `name` (String) Find by name - `page` (Number) Page number - `pool` (String) Find by pool name +- `rg_id` (Number) Find by rg id - `sep_id` (Number) Find by sep id - `shared` (Boolean) Find by shared field - `size` (Number) Page size @@ -31,7 +33,6 @@ description: |- - `status` (String) Find by status - `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -57,6 +58,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedobjatt--items--computes)) @@ -74,6 +76,7 @@ Read-Only: - `guid` (Number) - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--items--iotune)) - `iqn` (String) - `login` (String) @@ -87,6 +90,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -106,7 +110,6 @@ Read-Only: - `storage_policy_id` (Number) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/data-sources/cb_disk_list_deleted.md b/docs/data-sources/cb_disk_list_deleted.md index d6cffefc..86318a6c 100644 --- a/docs/data-sources/cb_disk_list_deleted.md +++ b/docs/data-sources/cb_disk_list_deleted.md @@ -27,7 +27,6 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -53,6 +52,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedobjatt--items--computes)) @@ -70,6 +70,7 @@ Read-Only: - `guid` (Number) - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--items--iotune)) - `iqn` (String) - `login` (String) @@ -83,6 +84,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -102,7 +104,6 @@ Read-Only: - `storage_policy_id` (Number) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/data-sources/cb_disk_list_types.md b/docs/data-sources/cb_disk_list_types.md deleted file mode 100644 index b01d816d..00000000 --- a/docs/data-sources/cb_disk_list_types.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "decort_cb_disk_list_types Data Source - terraform-provider-decort" -subcategory: "" -description: |- - ---- - -# decort_cb_disk_list_types (Data Source) - - - - - - -## Schema - -### Optional - -- `page` (Number) page number -- `size` (Number) page size -- `sort_by` (String) sort by one of supported fields, format +|-(field) -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - -### Read-Only - -- `entry_count` (Number) -- `id` (String) The ID of this resource. -- `items` (List of String) The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - - -### Nested Schema for `timeouts` - -Optional: - -- `default` (String) -- `read` (String) diff --git a/docs/data-sources/cb_disk_list_types_detailed.md b/docs/data-sources/cb_disk_list_types_detailed.md deleted file mode 100644 index 400afc18..00000000 --- a/docs/data-sources/cb_disk_list_types_detailed.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "decort_cb_disk_list_types_detailed Data Source - terraform-provider-decort" -subcategory: "" -description: |- - ---- - -# decort_cb_disk_list_types_detailed (Data Source) - - - - - - -## Schema - -### Optional - -- `page` (Number) page number -- `size` (Number) page size -- `sort_by` (String) sort by one of supported fields, format +|-(field) -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - -### Read-Only - -- `entry_count` (Number) -- `id` (String) The ID of this resource. -- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) - - -### Nested Schema for `timeouts` - -Optional: - -- `default` (String) -- `read` (String) - - - -### Nested Schema for `items` - -Read-Only: - -- `pools` (List of Object) (see [below for nested schema](#nestedobjatt--items--pools)) -- `sep_id` (Number) -- `sep_name` (String) - - -### Nested Schema for `items.pools` - -Read-Only: - -- `name` (String) -- `system` (String) -- `types` (List of String) diff --git a/docs/data-sources/cb_disk_list_unattached.md b/docs/data-sources/cb_disk_list_unattached.md index d8d42f44..01bde6cb 100644 --- a/docs/data-sources/cb_disk_list_unattached.md +++ b/docs/data-sources/cb_disk_list_unattached.md @@ -29,7 +29,6 @@ description: |- - `status` (String) Find by status - `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -56,6 +55,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `cache` (String) - `created_time` (Number) @@ -80,6 +80,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -94,7 +95,7 @@ Read-Only: - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) - `tech_status` (String) -- `type` (String) +- `to_clean` (Boolean) - `vmid` (Number) diff --git a/docs/data-sources/cb_grid_list.md b/docs/data-sources/cb_grid_list.md index e87ad5ee..3287f132 100644 --- a/docs/data-sources/cb_grid_list.md +++ b/docs/data-sources/cb_grid_list.md @@ -54,6 +54,7 @@ Read-Only: - `network_modes` (List of String) - `resources` (List of Object) (see [below for nested schema](#nestedobjatt--items--resources)) - `sdn_support` (Boolean) +- `zero_access_enabled` (Boolean) ### Nested Schema for `items.resources` diff --git a/docs/data-sources/cb_image.md b/docs/data-sources/cb_image.md index 3c9fdc56..e2cee173 100644 --- a/docs/data-sources/cb_image.md +++ b/docs/data-sources/cb_image.md @@ -43,8 +43,10 @@ description: |- - `hot_resize` (Boolean) Does this machine supports hot resize - `id` (String) The ID of this resource. - `image_type` (String) Image type linux, windows or other +- `independent` (Boolean) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `name` (String) Name of the rescue disk - `network_interface_naming` (String) diff --git a/docs/data-sources/cb_image_list.md b/docs/data-sources/cb_image_list.md index c6a12e27..e5266720 100644 --- a/docs/data-sources/cb_image_list.md +++ b/docs/data-sources/cb_image_list.md @@ -73,8 +73,10 @@ Read-Only: - `hot_resize` (Boolean) - `image_id` (Number) - `image_type` (String) +- `independent` (Boolean) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `name` (String) - `network_interface_naming` (String) diff --git a/docs/data-sources/cb_kvmvm.md b/docs/data-sources/cb_kvmvm.md index fe4f041e..3dfc8f3e 100644 --- a/docs/data-sources/cb_kvmvm.md +++ b/docs/data-sources/cb_kvmvm.md @@ -62,6 +62,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) - `image_name` (String) +- `independent` (Boolean) - `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces)) - `live_migration_job_id` (Number) - `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso)) @@ -111,6 +112,7 @@ description: |- - `user_managed` (Boolean) - `vgpus` (List of Object) List of virtual GPUs (see [below for nested schema](#nestedatt--vgpus)) - `vnc_password` (String) +- `weight` (Number) - `zone_id` (Number) @@ -168,6 +170,7 @@ Read-Only: - `account_id` (Number) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `bus_number` (Number) - `cache` (String) @@ -185,6 +188,7 @@ Read-Only: - `guid` (Number) - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--disks--iotune)) - `iqn` (String) - `login` (String) @@ -197,6 +201,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) diff --git a/docs/data-sources/cb_kvmvm_list.md b/docs/data-sources/cb_kvmvm_list.md index 64daa5b0..429d0375 100644 --- a/docs/data-sources/cb_kvmvm_list.md +++ b/docs/data-sources/cb_kvmvm_list.md @@ -134,6 +134,7 @@ Read-Only: - `user_managed` (Boolean) - `vgpus` (List of Number) - `vins_connected` (Number) +- `weight` (Number) - `zone_id` (Number) diff --git a/docs/data-sources/cb_kvmvm_list_deleted.md b/docs/data-sources/cb_kvmvm_list_deleted.md index f2e9ac20..5138f95b 100644 --- a/docs/data-sources/cb_kvmvm_list_deleted.md +++ b/docs/data-sources/cb_kvmvm_list_deleted.md @@ -124,6 +124,7 @@ Read-Only: - `user_managed` (Boolean) - `vgpus` (List of Number) - `vins_connected` (Number) +- `weight` (Number) - `zone_id` (Number) @@ -172,6 +173,7 @@ Read-Only: - `disk_id` (Number) - `pci_slot` (Number) +- `sep_id` (Number) diff --git a/docs/data-sources/cb_node.md b/docs/data-sources/cb_node.md index 1387739d..73d30862 100644 --- a/docs/data-sources/cb_node.md +++ b/docs/data-sources/cb_node.md @@ -124,6 +124,7 @@ Read-Only: - `flags` (List of String) - `model_name` (String) - `phys_count` (Number) +- `thread_count` (Number) diff --git a/docs/data-sources/cb_node_list.md b/docs/data-sources/cb_node_list.md index f55a78e2..ba7b78bf 100644 --- a/docs/data-sources/cb_node_list.md +++ b/docs/data-sources/cb_node_list.md @@ -28,6 +28,7 @@ description: |- - `status` (String) find node by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `version` (String) find node by version +- `zone_id` (Number) find node by zone id ### Read-Only @@ -111,6 +112,7 @@ Read-Only: - `flags` (List of String) - `model_name` (String) - `phys_count` (Number) +- `thread_count` (Number) diff --git a/docs/data-sources/cb_rg.md b/docs/data-sources/cb_rg.md index 95db46cc..7df682b7 100644 --- a/docs/data-sources/cb_rg.md +++ b/docs/data-sources/cb_rg.md @@ -71,6 +71,7 @@ Optional: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/data-sources/cb_storage_policy.md b/docs/data-sources/cb_storage_policy.md index f978edfc..aa82291c 100644 --- a/docs/data-sources/cb_storage_policy.md +++ b/docs/data-sources/cb_storage_policy.md @@ -51,6 +51,7 @@ Read-Only: - `pool_names` (List of String) - `sep_id` (Number) - `sep_name` (String) +- `sep_tech_status` (String) diff --git a/docs/data-sources/cb_zone.md b/docs/data-sources/cb_zone.md index 50b58f4a..cc0d3989 100644 --- a/docs/data-sources/cb_zone.md +++ b/docs/data-sources/cb_zone.md @@ -26,12 +26,19 @@ description: |- ### Read-Only - `account_ids` (List of Number) +- `app_id` (String) - `auto_start` (Boolean) +- `broadcast_addr` (String) - `bservice_ids` (List of Number) - `compute_ids` (List of Number) - `created_time` (Number) +- `decort_url` (String) - `deletable` (Boolean) - `description` (String) +- `domain` (String) +- `drs` (Boolean) +- `drs_name` (String) +- `drs_uid` (String) - `extnet_ids` (List of Number) - `gid` (Number) - `guid` (Number) @@ -40,6 +47,10 @@ description: |- - `lb_ids` (List of Number) - `name` (String) - `node_ids` (List of Number) +- `ping_addr` (String) +- `ssl_skip_verify` (Boolean) +- `sso_type` (String) +- `sso_url` (String) - `status` (String) - `updated_time` (Number) - `vins_ids` (List of Number) diff --git a/docs/data-sources/cb_zone_list.md b/docs/data-sources/cb_zone_list.md index 88409396..7fab8233 100644 --- a/docs/data-sources/cb_zone_list.md +++ b/docs/data-sources/cb_zone_list.md @@ -49,14 +49,25 @@ Optional: Read-Only: +- `app_id` (String) - `auto_start` (Boolean) +- `broadcast_addr` (String) - `created_time` (Number) +- `decort_url` (String) - `deletable` (Boolean) - `description` (String) +- `domain` (String) +- `drs` (Boolean) +- `drs_name` (String) +- `drs_uid` (String) - `gid` (Number) - `guid` (Number) - `name` (String) - `node_ids` (List of Number) +- `ping_addr` (String) +- `ssl_skip_verify` (Boolean) +- `sso_type` (String) +- `sso_url` (String) - `status` (String) - `updated_time` (Number) - `zone_id` (Number) diff --git a/docs/data-sources/disk.md b/docs/data-sources/disk.md index 3cd581c3..f280ec60 100644 --- a/docs/data-sources/disk.md +++ b/docs/data-sources/disk.md @@ -29,6 +29,7 @@ description: |- - `account_name` (String) The name of the subscriber '(account') to whom this disk belongs - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedatt--computes)) - `created_by` (String) @@ -43,6 +44,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) Image ID - `images` (List of Number) IDs of images using the disk +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedatt--iotune)) - `machine_id` (Number) - `machine_name` (String) @@ -53,6 +55,7 @@ description: |- - `pci_slot` (Number) ID of the pci slot to which the disk is connected - `pool` (String) Pool for disk location - `present_to` (Map of Number) +- `provision` (String) - `purge_time` (Number) Time of the last deletion attempt - `replication` (List of Object) Replication status (see [below for nested schema](#nestedatt--replication)) - `res_id` (String) Resource ID @@ -69,7 +72,6 @@ description: |- - `storage_policy_id` (Number) Storage policy ID - `tech_status` (String) Technical status of the disk - `to_clean` (Boolean) -- `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) Virtual Machine ID (Deprecated) diff --git a/docs/data-sources/disk_list.md b/docs/data-sources/disk_list.md index b264cd7f..aa1acbf0 100644 --- a/docs/data-sources/disk_list.md +++ b/docs/data-sources/disk_list.md @@ -20,10 +20,12 @@ description: |- - `account_id` (Number) ID of the account the disks belong to - `account_name` (String) Find by account name - `by_id` (Number) Find by ID +- `compute_id` (Number) Find by compute ID - `disk_max_size` (Number) Find by max disk size - `name` (String) Find by name - `page` (Number) Page number - `pool_name` (String) find by pool name +- `rg_id` (Number) Find by rg ID - `sep_id` (Number) find by sep ID - `shared` (Boolean) Find by shared field - `size` (Number) Page size @@ -31,7 +33,6 @@ description: |- - `status` (String) Find by status - `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -57,6 +58,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedobjatt--items--computes)) - `created_by` (String) @@ -71,6 +73,7 @@ Read-Only: - `gid` (Number) - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--items--iotune)) - `machine_id` (Number) - `machine_name` (String) @@ -81,6 +84,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_time` (Number) - `replication` (List of Object) (see [below for nested schema](#nestedobjatt--items--replication)) - `res_id` (String) @@ -97,7 +101,6 @@ Read-Only: - `storage_policy_id` (Number) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/data-sources/disk_list_deleted.md b/docs/data-sources/disk_list_deleted.md index 71768326..afdaec8c 100644 --- a/docs/data-sources/disk_list_deleted.md +++ b/docs/data-sources/disk_list_deleted.md @@ -27,7 +27,6 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -53,6 +52,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedobjatt--items--computes)) - `created_by` (String) @@ -67,6 +67,7 @@ Read-Only: - `gid` (Number) - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--items--iotune)) - `machine_id` (Number) - `machine_name` (String) @@ -77,6 +78,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_time` (Number) - `replication` (List of Object) (see [below for nested schema](#nestedobjatt--items--replication)) - `res_id` (String) @@ -93,7 +95,6 @@ Read-Only: - `storage_policy_id` (Number) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/data-sources/disk_list_types.md b/docs/data-sources/disk_list_types.md deleted file mode 100644 index 28abc05a..00000000 --- a/docs/data-sources/disk_list_types.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "decort_disk_list_types Data Source - terraform-provider-decort" -subcategory: "" -description: |- - ---- - -# decort_disk_list_types (Data Source) - - - - - - -## Schema - -### Optional - -- `page` (Number) Page number -- `size` (Number) Page size -- `sort_by` (String) sort by one of supported fields, format +|-(field) -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - -### Read-Only - -- `entry_count` (Number) -- `id` (String) The ID of this resource. -- `types` (List of String) The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - - -### Nested Schema for `timeouts` - -Optional: - -- `default` (String) -- `read` (String) diff --git a/docs/data-sources/disk_list_types_detailed.md b/docs/data-sources/disk_list_types_detailed.md deleted file mode 100644 index 8b9f1a21..00000000 --- a/docs/data-sources/disk_list_types_detailed.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "decort_disk_list_types_detailed Data Source - terraform-provider-decort" -subcategory: "" -description: |- - ---- - -# decort_disk_list_types_detailed (Data Source) - - - - - - -## Schema - -### Optional - -- `page` (Number) Page number -- `size` (Number) Page size -- `sort_by` (String) sort by one of supported fields, format +|-(field) -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - -### Read-Only - -- `entry_count` (Number) -- `id` (String) The ID of this resource. -- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) - - -### Nested Schema for `timeouts` - -Optional: - -- `default` (String) -- `read` (String) - - - -### Nested Schema for `items` - -Read-Only: - -- `pools` (List of Object) (see [below for nested schema](#nestedobjatt--items--pools)) -- `sep_id` (Number) -- `sep_name` (String) - - -### Nested Schema for `items.pools` - -Read-Only: - -- `name` (String) -- `system` (String) -- `types` (List of String) diff --git a/docs/data-sources/disk_list_unattached.md b/docs/data-sources/disk_list_unattached.md index b2c165b1..c21236b1 100644 --- a/docs/data-sources/disk_list_unattached.md +++ b/docs/data-sources/disk_list_unattached.md @@ -29,7 +29,6 @@ description: |- - `status` (String) Find by status - `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) type of the disks ### Read-Only @@ -56,6 +55,7 @@ Read-Only: - `account_name` (String) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `cache` (String) - `created_time` (Number) @@ -79,6 +79,8 @@ Read-Only: - `passwd` (String) - `pci_slot` (Number) - `pool` (String) +- `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -93,7 +95,7 @@ Read-Only: - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) - `tech_status` (String) -- `type` (String) +- `to_clean` (Boolean) - `vmid` (Number) diff --git a/docs/data-sources/disk_replication.md b/docs/data-sources/disk_replication.md index 555eda6e..2d83f8eb 100644 --- a/docs/data-sources/disk_replication.md +++ b/docs/data-sources/disk_replication.md @@ -61,7 +61,6 @@ description: |- - `status` (String) Disk status - `status_replication` (String) Status of replication - `tech_status` (String) Technical status of the disk -- `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `vmid` (Number) Virtual Machine ID (Deprecated) diff --git a/docs/data-sources/image.md b/docs/data-sources/image.md index bf6dc026..cfa72fea 100644 --- a/docs/data-sources/image.md +++ b/docs/data-sources/image.md @@ -43,8 +43,10 @@ description: |- - `hot_resize` (Boolean) - `id` (String) The ID of this resource. - `image_name` (String) +- `independent` (Boolean) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `network_interface_naming` (String) - `password` (String) diff --git a/docs/data-sources/image_list.md b/docs/data-sources/image_list.md index 025d2ede..1b41ae20 100644 --- a/docs/data-sources/image_list.md +++ b/docs/data-sources/image_list.md @@ -67,6 +67,7 @@ Read-Only: - `image_id` (Number) - `image_name` (String) - `link_to` (Number) +- `links_to` (List of Number) - `network_interface_naming` (String) - `pool_name` (String) - `sep_id` (Number) diff --git a/docs/data-sources/kvmvm.md b/docs/data-sources/kvmvm.md index 935ff879..9088d505 100644 --- a/docs/data-sources/kvmvm.md +++ b/docs/data-sources/kvmvm.md @@ -105,6 +105,7 @@ description: |- - `userdata` (String) - `vgpus` (List of Object) List of virtual GPUs (see [below for nested schema](#nestedatt--vgpus)) - `vnc_password` (String) +- `weight` (Number) - `zone_id` (Number) @@ -200,6 +201,7 @@ Read-Only: - `account_id` (Number) - `acl` (String) - `blk_discard` (Boolean) +- `block_size` (String) - `boot_partition` (Number) - `bus_number` (Number) - `cache` (String) @@ -217,6 +219,7 @@ Read-Only: - `image_id` (Number) - `image_name` (String) - `images` (List of Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--disks--iotune)) - `iqn` (String) - `login` (String) @@ -228,6 +231,7 @@ Read-Only: - `pci_slot` (Number) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `purge_time` (Number) - `reality_device_number` (Number) - `replication` (List of Object) (see [below for nested schema](#nestedobjatt--disks--replication)) @@ -243,7 +247,6 @@ Read-Only: - `storage_policy_id` (Number) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) - `updated_time` (Number) diff --git a/docs/data-sources/kvmvm_list.md b/docs/data-sources/kvmvm_list.md index e33891f2..c6c5589d 100644 --- a/docs/data-sources/kvmvm_list.md +++ b/docs/data-sources/kvmvm_list.md @@ -126,6 +126,7 @@ Read-Only: - `user_managed` (Boolean) - `vgpus` (List of Number) - `vins_connected` (Number) +- `weight` (Number) - `zone_id` (Number) diff --git a/docs/data-sources/kvmvm_list_deleted.md b/docs/data-sources/kvmvm_list_deleted.md index d4d67745..dade17cf 100644 --- a/docs/data-sources/kvmvm_list_deleted.md +++ b/docs/data-sources/kvmvm_list_deleted.md @@ -123,6 +123,7 @@ Read-Only: - `user_managed` (Boolean) - `vgpus` (List of Number) - `vins_connected` (Number) +- `weight` (Number) - `zone_id` (Number) diff --git a/docs/data-sources/locations_list.md b/docs/data-sources/locations_list.md index 1a104cf8..531d26f3 100644 --- a/docs/data-sources/locations_list.md +++ b/docs/data-sources/locations_list.md @@ -47,6 +47,7 @@ Optional: Read-Only: - `auth_broker` (List of String) +- `bro_enabled` (Boolean) - `ckey` (String) - `flag` (String) - `gid` (Number) @@ -57,3 +58,4 @@ Read-Only: - `name` (String) - `network_modes` (List of String) - `sdn_support` (Boolean) +- `zero_access_enabled` (Boolean) diff --git a/docs/data-sources/resgroup.md b/docs/data-sources/resgroup.md index 584408a9..1380ade5 100644 --- a/docs/data-sources/resgroup.md +++ b/docs/data-sources/resgroup.md @@ -71,6 +71,7 @@ Optional: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/data-sources/rg_list.md b/docs/data-sources/rg_list.md index 982b4417..d99f2e00 100644 --- a/docs/data-sources/rg_list.md +++ b/docs/data-sources/rg_list.md @@ -88,6 +88,7 @@ Read-Only: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/data-sources/rg_list_deleted.md b/docs/data-sources/rg_list_deleted.md index cae870e6..1e95e851 100644 --- a/docs/data-sources/rg_list_deleted.md +++ b/docs/data-sources/rg_list_deleted.md @@ -86,6 +86,7 @@ Read-Only: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/data-sources/rg_list_lb.md b/docs/data-sources/rg_list_lb.md index ca4d6667..3083c698 100644 --- a/docs/data-sources/rg_list_lb.md +++ b/docs/data-sources/rg_list_lb.md @@ -85,6 +85,7 @@ Read-Only: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/data-sources/sdn_access_group_list.md b/docs/data-sources/sdn_access_group_list.md index 5b00925a..55ca1171 100644 --- a/docs/data-sources/sdn_access_group_list.md +++ b/docs/data-sources/sdn_access_group_list.md @@ -22,6 +22,7 @@ description: |- - `deleted` (Boolean) filter by deleted/not deleted group - `display_name` (String) filter by display name - `enabled` (Boolean) filter by enabled/disabled group +- `owner_display_name` (String) - `page` (Number) Page number - `per_page` (Number) Items per page - `sort_by` (String) sort by one of supported fields diff --git a/docs/data-sources/sdn_hypervisor.md b/docs/data-sources/sdn_hypervisor.md new file mode 100644 index 00000000..d139e2b8 --- /dev/null +++ b/docs/data-sources/sdn_hypervisor.md @@ -0,0 +1,72 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_hypervisor Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_hypervisor (Data Source) + + + + + + +## Schema + +### Required + +- `name` (String) + +### Optional + +- `port_info` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `created_at` (String) +- `display_name` (String) +- `hostname` (String) +- `id` (String) The ID of this resource. +- `ip` (String) +- `ports` (List of Object) (see [below for nested schema](#nestedatt--ports)) +- `status` (String) +- `synced_at` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `ports` + +Read-Only: + +- `data` (List of Object) (see [below for nested schema](#nestedobjatt--ports--data)) +- `info` (List of Object) (see [below for nested schema](#nestedobjatt--ports--info)) + + +### Nested Schema for `ports.data` + +Read-Only: + +- `display_name` (String) +- `id` (String) +- `unique_identifier` (String) +- `up` (Boolean) + + + +### Nested Schema for `ports.info` + +Read-Only: + +- `active_ports` (Number) +- `total_ports` (Number) diff --git a/docs/data-sources/sdn_hypervisor_list.md b/docs/data-sources/sdn_hypervisor_list.md new file mode 100644 index 00000000..a40e0b43 --- /dev/null +++ b/docs/data-sources/sdn_hypervisor_list.md @@ -0,0 +1,87 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_hypervisor_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_hypervisor_list (Data Source) + + + + + + +## Schema + +### Optional + +- `created_from` (String) +- `created_to` (String) +- `display_name` (String) +- `hostname` (String) +- `ip` (String) +- `page` (Number) +- `per_page` (Number) +- `port_info` (String) +- `sort_by` (String) +- `sort_order` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `updated_from` (String) +- `updated_to` (String) + +### Read-Only + +- `id` (String) The ID of this resource. +- `items` (List of Object) List of hypervisors (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `created_at` (String) +- `display_name` (String) +- `hostname` (String) +- `ip` (String) +- `name` (String) +- `ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--ports)) +- `status` (String) +- `synced_at` (String) + + +### Nested Schema for `items.ports` + +Read-Only: + +- `data` (List of Object) (see [below for nested schema](#nestedobjatt--items--ports--data)) +- `info` (List of Object) (see [below for nested schema](#nestedobjatt--items--ports--info)) + + +### Nested Schema for `items.ports.data` + +Read-Only: + +- `display_name` (String) +- `id` (String) +- `unique_identifier` (String) +- `up` (Boolean) + + + +### Nested Schema for `items.ports.info` + +Read-Only: + +- `active_ports` (Number) +- `total_ports` (Number) diff --git a/docs/data-sources/sdn_logical_port.md b/docs/data-sources/sdn_logical_port.md index 9a1d4387..137e5434 100644 --- a/docs/data-sources/sdn_logical_port.md +++ b/docs/data-sources/sdn_logical_port.md @@ -34,9 +34,11 @@ description: |- - `description` (String) Description of the logical port - `display_name` (String) Display name of the logical port - `enabled` (Boolean) If the logical port is enabled +- `external_network_id` (String) - `hypervisor` (String) ID of the hypervisor - `hypervisor_display_name` (String) Display name of the hypervisor - `id` (String) The ID of this resource. +- `labels` (List of Object) Labels (see [below for nested schema](#nestedatt--labels)) - `live_migration_target_hv` (String) - `status` (List of Object) (see [below for nested schema](#nestedatt--status)) - `unique_identifier` (String) Unique identifier of the logical port @@ -60,21 +62,46 @@ Read-Only: - `address_detection` (Boolean) - `created_at` (String) - `id` (String) -- `is_excluded_from_firewall` (Boolean) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--bindings--logical_port_addresses)) - `port_security` (Boolean) - `segment_display_name` (String) - `segment_id` (String) - `updated_at` (String) - `version_id` (Number) + +### Nested Schema for `bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + ### Nested Schema for `status` Read-Only: -- `common` (String) +- `hypervisor_status` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `status.hypervisors` @@ -84,5 +111,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md b/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md index 0fbeb7cb..9911ecb8 100644 --- a/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md +++ b/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md @@ -34,9 +34,11 @@ description: |- - `description` (String) Description of the logical port - `display_name` (String) Display name of the logical port - `enabled` (Boolean) If the logical port is enabled +- `external_network_id` (String) - `hypervisor` (String) ID of the hypervisor - `hypervisor_display_name` (String) Display name of the hypervisor - `id` (String) The ID of this resource. +- `labels` (List of Object) Labels (see [below for nested schema](#nestedatt--labels)) - `live_migration_target_hv` (String) - `status` (List of Object) (see [below for nested schema](#nestedatt--status)) - `updated_at` (String) Update time the logical port @@ -59,21 +61,46 @@ Read-Only: - `address_detection` (Boolean) - `created_at` (String) - `id` (String) -- `is_excluded_from_firewall` (Boolean) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--bindings--logical_port_addresses)) - `port_security` (Boolean) - `segment_display_name` (String) - `segment_id` (String) - `updated_at` (String) - `version_id` (Number) + +### Nested Schema for `bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + ### Nested Schema for `status` Read-Only: -- `common` (String) +- `hypervisor_status` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `status.hypervisors` @@ -83,5 +110,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/data-sources/sdn_logical_port_list.md b/docs/data-sources/sdn_logical_port_list.md index 4540a130..948a9d0a 100644 --- a/docs/data-sources/sdn_logical_port_list.md +++ b/docs/data-sources/sdn_logical_port_list.md @@ -27,7 +27,9 @@ description: |- - `external_network_id` (String) External Network ID - `hypervisor` (String) Hypervisor - `hypervisor_display_name` (String) Hypervisor display name +- `hypervisor_status` (String) Filter by hypervisor status - `live_migration_target_hv` (String) Live migration target HV +- `operation_status` (String) Filter by operation status - `page` (Number) - `per_page` (Number) - `port_security` (Boolean) @@ -66,9 +68,11 @@ Read-Only: - `description` (String) - `display_name` (String) - `enabled` (Boolean) +- `external_network_id` (String) - `hypervisor` (String) - `hypervisor_display_name` (String) - `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--items--labels)) - `live_migration_target_hv` (String) - `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) - `unique_identifier` (String) @@ -83,21 +87,46 @@ Read-Only: - `address_detection` (Boolean) - `created_at` (String) - `id` (String) -- `is_excluded_from_firewall` (Boolean) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--items--bindings--logical_port_addresses)) - `port_security` (Boolean) - `segment_display_name` (String) - `segment_id` (String) - `updated_at` (String) - `version_id` (Number) + +### Nested Schema for `items.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `items.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + ### Nested Schema for `items.status` Read-Only: -- `common` (String) +- `hypervisor_status` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `items.status.hypervisors` @@ -107,5 +136,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/data-sources/sdn_network_object_group.md b/docs/data-sources/sdn_network_object_group.md new file mode 100644 index 00000000..6bb5a7b4 --- /dev/null +++ b/docs/data-sources/sdn_network_object_group.md @@ -0,0 +1,705 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_network_object_group Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_network_object_group (Data Source) + + + + + + +## Schema + +### Required + +- `net_object_group_id` (String) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_id` (String) +- `access_group_name` (String) +- `addresses` (List of Object) (see [below for nested schema](#nestedatt--addresses)) +- `counters` (List of Object) (see [below for nested schema](#nestedatt--counters)) +- `created_at` (String) +- `description` (String) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedatt--external_network_ports)) +- `id` (String) The ID of this resource. +- `l2_connection_ports` (List of Object) (see [below for nested schema](#nestedatt--l2_connection_ports)) +- `logical_ports` (List of Object) (see [below for nested schema](#nestedatt--logical_ports)) +- `name` (String) +- `purpose` (String) +- `security_policies` (List of Object) (see [below for nested schema](#nestedatt--security_policies)) +- `type` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `addresses` + +Read-Only: + +- `id` (String) +- `ip_addr` (String) +- `ip_addr_range_end` (String) +- `ip_prefix` (String) +- `mac_addr` (String) +- `net_address_type` (String) + + + +### Nested Schema for `counters` + +Read-Only: + +- `addresses_count` (Number) +- `l2_connection_ports_count` (Number) +- `logical_ports_count` (Number) +- `security_policies_count` (Number) +- `security_rules_count` (Number) + + + +### Nested Schema for `external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `bridge_network_name` (String) +- `comment` (String) +- `created_at` (String) +- `default_gateway_ipv4` (String) +- `default_gateway_ipv6` (String) +- `description` (String) +- `enabled` (Boolean) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports)) +- `hypervisors` (List of String) +- `id` (String) +- `ipv4` (String) +- `mac` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--status)) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `comment` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `floating_ip` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip)) +- `ipv4` (String) +- `ipv6` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--ipv6_config)) +- `mac` (String) +- `router_gateaway_port` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--router_gateaway_port)) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `logical_port` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port)) +- `router` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `gateaway_ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports)) +- `id` (String) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--policies)) +- `ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports)) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `external_l4_port_max` (Number) +- `external_l4_port_min` (Number) +- `id` (String) +- `snat_enabled` (Boolean) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.policies` + +Read-Only: + +- `action` (String) +- `created_at` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `match` (String) +- `next_ipv4_address` (List of String) +- `next_ipv6_address` (List of String) +- `priority` (Number) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `enabled` (Boolean) +- `id` (String) +- `ipv4_address` (String) +- `ipv6_address` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--ipv6_config)) +- `mac` (String) +- `segment` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--segment)) +- `segment_id` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.segment` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + + +### Nested Schema for `external_network_ports.external_network_ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.router_gateaway_port` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `id` (String) +- `router_display_name` (String) +- `router_id` (String) +- `snat_enabled` (Boolean) +- `updated_at` (String) + + + + +### Nested Schema for `external_network_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `l2_connection_ports` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--l2_connection_ports--l2_external_network)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `l2_connection_ports.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + + +### Nested Schema for `logical_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `logical_ports.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `logical_ports.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `logical_ports.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `logical_ports.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `logical_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `logical_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `security_policies` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `applied_net_object_groups` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--applied_net_object_groups)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `end_priority` (Number) +- `id` (String) +- `security_rules` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules)) +- `start_priority` (Number) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--status)) +- `type` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `security_policies.applied_net_object_groups` + +Read-Only: + +- `id` (String) +- `name` (String) +- `version_id` (Number) + + + +### Nested Schema for `security_policies.security_rules` + +Read-Only: + +- `access_group_id` (String) +- `action` (String) +- `description` (String) +- `destination_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--destination_net_object)) +- `direction` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `filter` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--filter)) +- `id` (String) +- `log_enabled` (Boolean) +- `log_name` (String) +- `log_severity` (String) +- `priority` (Number) +- `security_policy_id` (String) +- `source_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--source_net_object)) +- `statistics_enabled` (Boolean) +- `type` (String) +- `version_id` (Number) + + +### Nested Schema for `security_policies.security_rules.destination_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + +### Nested Schema for `security_policies.security_rules.filter` + +Read-Only: + +- `filters` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--filter--filters)) +- `name` (String) + + +### Nested Schema for `security_policies.security_rules.filter.filters` + +Read-Only: + +- `all` (Boolean) +- `arp` (Boolean) +- `dhcp` (Boolean) +- `expression` (String) +- `icmp` (Boolean) +- `ip` (Boolean) +- `ip_v4` (Boolean) +- `ip_v6` (Boolean) +- `keep_opened_sessions` (Boolean) +- `nd` (Boolean) +- `tcp` (Boolean) +- `tcp_dst_ports` (List of String) +- `udp` (Boolean) +- `udp_dst_ports` (List of String) + + + + +### Nested Schema for `security_policies.security_rules.source_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + + +### Nested Schema for `security_policies.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `security_policies.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_network_object_group_list.md b/docs/data-sources/sdn_network_object_group_list.md new file mode 100644 index 00000000..a0b0a83d --- /dev/null +++ b/docs/data-sources/sdn_network_object_group_list.md @@ -0,0 +1,720 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_network_object_group_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_network_object_group_list (Data Source) + + + + + + +## Schema + +### Optional + +- `access_group_id` (String) +- `created_from` (String) +- `created_to` (String) +- `name` (String) +- `page` (Number) +- `per_page` (Number) +- `sort_by` (String) +- `sort_order` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `updated_from` (String) +- `updated_to` (String) + +### Read-Only + +- `entry_count` (Number) +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `addresses` (List of Object) (see [below for nested schema](#nestedobjatt--items--addresses)) +- `counters` (List of Object) (see [below for nested schema](#nestedobjatt--items--counters)) +- `created_at` (String) +- `description` (String) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports)) +- `id` (String) +- `l2_connection_ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--l2_connection_ports)) +- `logical_ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports)) +- `name` (String) +- `purpose` (String) +- `security_policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies)) +- `type` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.addresses` + +Read-Only: + +- `id` (String) +- `ip_addr` (String) +- `ip_addr_range_end` (String) +- `ip_prefix` (String) +- `mac_addr` (String) +- `net_address_type` (String) + + + +### Nested Schema for `items.counters` + +Read-Only: + +- `addresses_count` (Number) +- `l2_connection_ports_count` (Number) +- `logical_ports_count` (Number) +- `security_policies_count` (Number) +- `security_rules_count` (Number) + + + +### Nested Schema for `items.external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `bridge_network_name` (String) +- `comment` (String) +- `created_at` (String) +- `default_gateway_ipv4` (String) +- `default_gateway_ipv6` (String) +- `description` (String) +- `enabled` (Boolean) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports)) +- `hypervisors` (List of String) +- `id` (String) +- `ipv4` (String) +- `mac` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--status)) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `comment` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `floating_ip` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip)) +- `ipv4` (String) +- `ipv6` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--ipv6_config)) +- `mac` (String) +- `router_gateaway_port` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--router_gateaway_port)) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `logical_port` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port)) +- `router` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--logical_port--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.logical_port.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `gateaway_ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports)) +- `id` (String) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--policies)) +- `ports` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--ports)) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.gateaway_ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `external_l4_port_max` (Number) +- `external_l4_port_min` (Number) +- `id` (String) +- `snat_enabled` (Boolean) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.policies` + +Read-Only: + +- `action` (String) +- `created_at` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `match` (String) +- `next_ipv4_address` (List of String) +- `next_ipv6_address` (List of String) +- `priority` (Number) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `enabled` (Boolean) +- `id` (String) +- `ipv4_address` (String) +- `ipv6_address` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--ports--ipv6_config)) +- `mac` (String) +- `segment` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--ports--segment)) +- `segment_id` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.ports.segment` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--external_network_ports--floating_ip--router--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.external_network_ports.external_network_ports.floating_ip.router.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + + +### Nested Schema for `items.external_network_ports.external_network_ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `items.external_network_ports.external_network_ports.router_gateaway_port` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `id` (String) +- `router_display_name` (String) +- `router_id` (String) +- `snat_enabled` (Boolean) +- `updated_at` (String) + + + + +### Nested Schema for `items.external_network_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--external_network_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.external_network_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `items.l2_connection_ports` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--items--l2_connection_ports--l2_external_network)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.l2_connection_ports.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + + +### Nested Schema for `items.logical_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.logical_ports.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.logical_ports.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `items.logical_ports.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `items.logical_ports.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `items.logical_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.logical_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `items.security_policies` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `applied_net_object_groups` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--applied_net_object_groups)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `end_priority` (Number) +- `id` (String) +- `security_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--security_rules)) +- `start_priority` (Number) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--status)) +- `type` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.security_policies.applied_net_object_groups` + +Read-Only: + +- `id` (String) +- `name` (String) +- `version_id` (Number) + + + +### Nested Schema for `items.security_policies.security_rules` + +Read-Only: + +- `access_group_id` (String) +- `action` (String) +- `description` (String) +- `destination_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--security_rules--destination_net_object)) +- `direction` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `filter` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--security_rules--filter)) +- `id` (String) +- `log_enabled` (Boolean) +- `log_name` (String) +- `log_severity` (String) +- `priority` (Number) +- `security_policy_id` (String) +- `source_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--security_rules--source_net_object)) +- `statistics_enabled` (Boolean) +- `type` (String) +- `version_id` (Number) + + +### Nested Schema for `items.security_policies.security_rules.destination_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + +### Nested Schema for `items.security_policies.security_rules.filter` + +Read-Only: + +- `filters` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--security_rules--filter--filters)) +- `name` (String) + + +### Nested Schema for `items.security_policies.security_rules.filter.filters` + +Read-Only: + +- `all` (Boolean) +- `arp` (Boolean) +- `dhcp` (Boolean) +- `expression` (String) +- `icmp` (Boolean) +- `ip` (Boolean) +- `ip_v4` (Boolean) +- `ip_v6` (Boolean) +- `keep_opened_sessions` (Boolean) +- `nd` (Boolean) +- `tcp` (Boolean) +- `tcp_dst_ports` (List of String) +- `udp` (Boolean) +- `udp_dst_ports` (List of String) + + + + +### Nested Schema for `items.security_policies.security_rules.source_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + + +### Nested Schema for `items.security_policies.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_policies--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `items.security_policies.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_segment.md b/docs/data-sources/sdn_segment.md index c86933ee..c96de7d2 100644 --- a/docs/data-sources/sdn_segment.md +++ b/docs/data-sources/sdn_segment.md @@ -34,11 +34,13 @@ description: |- - `display_name` (String) - `enabled` (Boolean) - `id` (String) The ID of this resource. +- `l2_connection_port` (List of Object) (see [below for nested schema](#nestedatt--l2_connection_port)) - `logical_ports_info` (List of Object) (see [below for nested schema](#nestedatt--logical_ports_info)) - `routers_info` (List of Object) (see [below for nested schema](#nestedatt--routers_info)) - `status` (List of Object) (see [below for nested schema](#nestedatt--status)) - `subnet_v4` (String) - `subnet_v6` (String) +- `type` (String) - `updated_at` (String) - `version_id` (Number) @@ -79,6 +81,39 @@ Read-Only: - `server_mac` (String) + +### Nested Schema for `l2_connection_port` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `created_by` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--l2_connection_port--l2_external_network)) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) + + +### Nested Schema for `l2_connection_port.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `created_by` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + ### Nested Schema for `logical_ports_info` @@ -102,8 +137,8 @@ Read-Only: Read-Only: -- `common` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `status.hypervisors` @@ -113,5 +148,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/data-sources/sdn_segment_get_status.md b/docs/data-sources/sdn_segment_get_status.md deleted file mode 100644 index b030c111..00000000 --- a/docs/data-sources/sdn_segment_get_status.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "decort_sdn_segment_get_status Data Source - terraform-provider-decort" -subcategory: "" -description: |- - ---- - -# decort_sdn_segment_get_status (Data Source) - - - - - - -## Schema - -### Required - -- `segment_id` (String) - -### Optional - -- `detailed` (Boolean) -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `version_id` (Number) - -### Read-Only - -- `id` (String) The ID of this resource. -- `status` (String) - - -### Nested Schema for `timeouts` - -Optional: - -- `default` (String) -- `read` (String) diff --git a/docs/data-sources/sdn_segment_list.md b/docs/data-sources/sdn_segment_list.md index 1f539985..aed9963a 100644 --- a/docs/data-sources/sdn_segment_list.md +++ b/docs/data-sources/sdn_segment_list.md @@ -23,6 +23,7 @@ description: |- - `display_name` (String) find by display name - `enabled` (Boolean) find by enabled status - `is_synced` (Boolean) does core currently believe that its data is synchronized with the data in the OVN? +- `operation_status` (String) filter by operation status - `page` (Number) Page number - `per_page` (Number) Items per page - `sort_by` (String) sort by one of supported fields @@ -61,11 +62,13 @@ Read-Only: - `display_name` (String) - `enabled` (Boolean) - `id` (String) +- `l2_connection_port` (List of Object) (see [below for nested schema](#nestedobjatt--items--l2_connection_port)) - `logical_ports_info` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports_info)) - `routers_info` (List of Object) (see [below for nested schema](#nestedobjatt--items--routers_info)) - `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) - `subnet_v4` (String) - `subnet_v6` (String) +- `type` (String) - `updated_at` (String) - `version_id` (Number) @@ -97,6 +100,39 @@ Read-Only: - `server_mac` (String) + +### Nested Schema for `items.l2_connection_port` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `created_by` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--items--l2_connection_port--l2_external_network)) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) + + +### Nested Schema for `items.l2_connection_port.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `created_by` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + ### Nested Schema for `items.logical_ports_info` @@ -120,8 +156,8 @@ Read-Only: Read-Only: -- `common` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `items.status.hypervisors` @@ -131,5 +167,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/data-sources/storage_policy.md b/docs/data-sources/storage_policy.md index ed447d9f..d2bd5104 100644 --- a/docs/data-sources/storage_policy.md +++ b/docs/data-sources/storage_policy.md @@ -51,6 +51,7 @@ Read-Only: - `pool_names` (List of String) - `sep_id` (Number) - `sep_name` (String) +- `sep_tech_status` (String) diff --git a/docs/data-sources/zone.md b/docs/data-sources/zone.md index 1b0bdba5..9413e542 100644 --- a/docs/data-sources/zone.md +++ b/docs/data-sources/zone.md @@ -26,20 +26,31 @@ description: |- ### Read-Only - `account_ids` (List of Number) +- `app_id` (String) - `auto_start` (Boolean) +- `broadcast_addr` (String) - `bservice_ids` (List of Number) - `compute_ids` (List of Number) - `created_time` (Number) +- `decort_url` (String) - `deletable` (Boolean) - `description` (String) +- `domain` (String) +- `drs` (Boolean) +- `drs_name` (String) +- `drs_uid` (String) - `extnet_ids` (List of Number) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. - `k8s_ids` (List of Number) -- `lb_ids` (List of Number) +- `lbs_ids` (List of Number) - `name` (String) - `node_ids` (List of Number) +- `ping_addr` (String) +- `ssl_skip_verify` (Boolean) +- `sso_type` (String) +- `sso_url` (String) - `status` (String) - `updated_time` (Number) - `vins_ids` (List of Number) diff --git a/docs/data-sources/zone_list.md b/docs/data-sources/zone_list.md index 7333e600..99f8d5ec 100644 --- a/docs/data-sources/zone_list.md +++ b/docs/data-sources/zone_list.md @@ -49,14 +49,25 @@ Optional: Read-Only: +- `app_id` (String) - `auto_start` (Boolean) +- `broadcast_addr` (String) - `created_time` (Number) +- `decort_url` (String) - `deletable` (Boolean) - `description` (String) +- `domain` (String) +- `drs` (Boolean) +- `drs_name` (String) +- `drs_uid` (String) - `gid` (Number) - `guid` (Number) - `name` (String) - `node_ids` (List of Number) +- `ping_addr` (String) +- `ssl_skip_verify` (Boolean) +- `sso_type` (String) +- `sso_url` (String) - `status` (String) - `updated_time` (Number) - `zone_id` (Number) diff --git a/docs/resources/account.md b/docs/resources/account.md index f2752bbd..c5da744b 100644 --- a/docs/resources/account.md +++ b/docs/resources/account.md @@ -54,6 +54,7 @@ description: |- - `machines` (List of Object) (see [below for nested schema](#nestedatt--machines)) - `status` (String) - `storage_policy_ids` (List of Number) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/resources/cb_account.md b/docs/resources/cb_account.md index 3eaaeb1c..33fecb24 100644 --- a/docs/resources/cb_account.md +++ b/docs/resources/cb_account.md @@ -57,6 +57,7 @@ description: |- - `id` (String) The ID of this resource. - `resource_types` (List of String) - `status` (String) +- `updated_by` (String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) diff --git a/docs/resources/cb_disk.md b/docs/resources/cb_disk.md index a250ad52..d557e3d1 100644 --- a/docs/resources/cb_disk.md +++ b/docs/resources/cb_disk.md @@ -25,6 +25,7 @@ description: |- ### Optional - `blk_discard` (Boolean) +- `block_size` (String) - `cache` (String) Cache mode for the disk - `desc` (String) - `detach` (Boolean) detach disk from machine first @@ -56,6 +57,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) - `images` (List of Number) +- `independent` (Boolean) - `iqn` (String) - `login` (String) - `machine_id` (Number) @@ -67,6 +69,7 @@ description: |- - `passwd` (String) - `pci_slot` (Number) - `present_to` (Map of Number) +- `provision` (String) - `purge_attempts` (Number) - `purge_time` (Number) - `reality_device_number` (Number) @@ -81,7 +84,6 @@ description: |- - `status` (String) - `tech_status` (String) - `to_clean` (Boolean) -- `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) diff --git a/docs/resources/cb_image.md b/docs/resources/cb_image.md index 9cd87c83..db5a07b8 100644 --- a/docs/resources/cb_image.md +++ b/docs/resources/cb_image.md @@ -54,8 +54,10 @@ description: |- - `history` (List of Object) (see [below for nested schema](#nestedatt--history)) - `id` (String) The ID of this resource. - `image_id` (Number) image id +- `independent` (Boolean) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `present_to` (Map of Number) - `provider_name` (String) diff --git a/docs/resources/cb_image_from_blank_compute.md b/docs/resources/cb_image_from_blank_compute.md index c4d49828..f28f3dfb 100644 --- a/docs/resources/cb_image_from_blank_compute.md +++ b/docs/resources/cb_image_from_blank_compute.md @@ -21,6 +21,7 @@ description: |- - `compute_id` (Number) Compute Id - `image_type` (String) Image type linux, windows or unknown - `name` (String) Name of the rescue disk +- `storage_policy_id` (Number) Storage policy ID ### Optional @@ -52,6 +53,7 @@ description: |- - `image_id` (Number) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `present_to` (Map of Number) - `provider_name` (String) diff --git a/docs/resources/cb_image_from_platform_disk.md b/docs/resources/cb_image_from_platform_disk.md index e91fb854..666de83d 100644 --- a/docs/resources/cb_image_from_platform_disk.md +++ b/docs/resources/cb_image_from_platform_disk.md @@ -52,6 +52,7 @@ description: |- - `image_id` (Number) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `present_to` (Map of Number) - `provider_name` (String) diff --git a/docs/resources/cb_kvmvm.md b/docs/resources/cb_kvmvm.md index a9fba414..0bcd2fe7 100644 --- a/docs/resources/cb_kvmvm.md +++ b/docs/resources/cb_kvmvm.md @@ -38,6 +38,7 @@ description: |- - `chipset` (String) Type of the emulated system. - `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases. - `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node. +- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case. - `custom_fields` (String) - `description` (String) Optional text description of this compute instance. - `detach_disks` (Boolean) @@ -50,8 +51,6 @@ description: |- - `hot_resize` (Boolean) Type of image vm. - `hp_backed` (Boolean) Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node. - `image_id` (Number) ID of the OS image to base this compute instance on. -- `ipa_type` (String) compute purpose -- `is` (String) system name - `libvirt_settings` (Block Set) Configure libvirt virtio interface parameters. You can only delete values locally. Data on the platform cannot be deleted. (see [below for nested schema](#nestedblock--libvirt_settings)) - `loader_type` (String) Type of image vm. - `network` (Block Set) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network)) @@ -77,6 +76,7 @@ description: |- - `tags` (Block Set) (see [below for nested schema](#nestedblock--tags)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `user_access` (Block Set) (see [below for nested schema](#nestedblock--user_access)) +- `weight` (Number) Priority weight of the compute. Higher value means higher priority and later migration. - `without_boot_disk` (Boolean) If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state. - `zone_id` (Number) @@ -184,9 +184,9 @@ Required: Optional: - `blk_discard` (Boolean) +- `block_size` (String) Disk block size - `cache` (String) Setting the disk caching mode - `desc` (String) Optional description -- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data' - `image_id` (Number) Specify image id for create disk from template - `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune)) - `node_ids` (Set of Number) @@ -196,13 +196,17 @@ Optional: Read-Only: +- `bus_number` (Number) Bus number of the disk on virtual bus (6 = boot disk) - `create_by` (String) - `create_time` (Number) - `delete_by` (String) - `delete_time` (Number) - `devicename` (String) - `disk_id` (Number) Disk ID +- `independent` (Boolean) +- `pci_slot` (Number) PCI slot number of the disk - `present_to` (Map of Number) +- `provision` (String) - `shareable` (Boolean) - `size_max` (Number) - `size_used` (Number) @@ -261,7 +265,7 @@ Optional: - `enabled` (Boolean) network enable flag - `ip_address` (String) Optional IP address to assign to this connection. This IP should belong to the selected network and free for use. - `mac` (String) MAC address associated with this connection. MAC address is assigned automatically. -- `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1-9216 +- `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1500-9216 - `net_mask` (Number) Subnet mask, used only for DPDK and VFNIC network types - `sdn_interface_id` (String) unique_identifier of LogicalPort on SDN side - `weight` (Number) weight the network if you need to sort network list, the smallest attach first. zero or null weight attach last diff --git a/docs/resources/cb_multi_image.md b/docs/resources/cb_multi_image.md new file mode 100644 index 00000000..78dded85 --- /dev/null +++ b/docs/resources/cb_multi_image.md @@ -0,0 +1,104 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_multi_image Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_multi_image (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) Name of the multi image +- `target_ids` (List of Number) IDs of real images to link this multi image to + +### Optional + +- `account_id` (Number) Account id to make the image exclusive +- `bootable` (Boolean) Does this image boot OS +- `computeci_id` (Number) +- `enabled` (Boolean) +- `hot_resize` (Boolean) Does this machine supports hot resize +- `password` (String) Optional password for the image +- `shared_with` (List of Number) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `username` (String) Optional username for the image + +### Read-Only + +- `acl` (List of Object) (see [below for nested schema](#nestedatt--acl)) +- `architecture` (String) +- `boot_type` (String) +- `deleted_time` (Number) +- `desc` (String) +- `drivers` (List of String) +- `gid` (Number) +- `guid` (Number) +- `history` (List of Object) (see [below for nested schema](#nestedatt--history)) +- `id` (String) The ID of this resource. +- `image_id` (Number) +- `image_type` (String) +- `independent` (Boolean) +- `last_modified` (Number) +- `link_to` (Number) +- `links_to` (List of Number) +- `milestones` (Number) +- `pool_name` (String) +- `present_to` (Map of Number) +- `provider_name` (String) +- `purge_attempts` (Number) +- `reference_id` (String) +- `res_id` (String) +- `res_name` (String) +- `rescuecd` (Boolean) +- `sep_id` (Number) +- `size` (Number) +- `snapshot_id` (String) +- `status` (String) +- `tech_status` (String) +- `to_clean` (Boolean) +- `unc_path` (String) unc path +- `url` (String) +- `version` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `acl` + +Read-Only: + +- `explicit` (Boolean) +- `guid` (String) +- `right` (String) +- `status` (String) +- `type` (String) +- `user_group_id` (String) + + + +### Nested Schema for `history` + +Read-Only: + +- `guid` (String) +- `id` (Number) +- `timestamp` (Number) diff --git a/docs/resources/cb_rg.md b/docs/resources/cb_rg.md index 7481534e..172b8a1a 100644 --- a/docs/resources/cb_rg.md +++ b/docs/resources/cb_rg.md @@ -143,6 +143,7 @@ Optional: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/resources/cb_storage_policy.md b/docs/resources/cb_storage_policy.md index e926a654..9a7e83d2 100644 --- a/docs/resources/cb_storage_policy.md +++ b/docs/resources/cb_storage_policy.md @@ -32,7 +32,6 @@ description: |- - `guid` (Number) - `id` (String) The ID of this resource. - `status` (String) -- `storage_policy_id` (Number) - `usage` (List of Object) (see [below for nested schema](#nestedatt--usage)) @@ -46,6 +45,7 @@ Required: Read-Only: - `sep_name` (String) +- `sep_tech_status` (String) diff --git a/docs/resources/cb_virtual_image.md b/docs/resources/cb_virtual_image.md index 27828af1..75f5e637 100644 --- a/docs/resources/cb_virtual_image.md +++ b/docs/resources/cb_virtual_image.md @@ -46,6 +46,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) Image id - `image_type` (String) Image type linux, windows or other +- `independent` (Boolean) - `last_modified` (Number) - `milestones` (Number) - `pool_name` (String) pool for image create diff --git a/docs/resources/cb_zone.md b/docs/resources/cb_zone.md index d51881b1..cbef45f7 100644 --- a/docs/resources/cb_zone.md +++ b/docs/resources/cb_zone.md @@ -23,16 +23,27 @@ description: |- - `auto_start` (Boolean) - `description` (String) +- `drs` (Boolean) - `node_ids` (List of Number) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only +- `app_id` (String) +- `broadcast_addr` (String) - `created_time` (Number) +- `decort_url` (String) - `deletable` (Boolean) +- `domain` (String) +- `drs_name` (String) +- `drs_uid` (String) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. +- `ping_addr` (String) +- `ssl_skip_verify` (Boolean) +- `sso_type` (String) +- `sso_url` (String) - `status` (String) - `updated_time` (Number) - `zone_id` (Number) diff --git a/docs/resources/disk.md b/docs/resources/disk.md index 9351097f..e270e66f 100644 --- a/docs/resources/disk.md +++ b/docs/resources/disk.md @@ -38,6 +38,7 @@ description: |- - `account_name` (String) The name of the subscriber '(account') to whom this disk belongs - `acl` (String) - `blk_discard` (Boolean) Flag indicating whether blk-discard is enabled for the disk +- `block_size` (String) - `cache` (String) - `computes` (List of Object) (see [below for nested schema](#nestedatt--computes)) - `created_by` (String) @@ -51,6 +52,7 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) Image ID - `images` (List of Number) IDs of images using the disk +- `independent` (Boolean) - `machine_id` (Number) - `machine_name` (String) - `order` (Number) Disk order @@ -58,6 +60,7 @@ description: |- - `parent_id` (Number) ID of the parent disk - `pci_slot` (Number) ID of the pci slot to which the disk is connected - `present_to` (Map of Number) +- `provision` (String) - `purge_time` (Number) Time of the last deletion attempt - `replication` (List of Object) Replication status (see [below for nested schema](#nestedatt--replication)) - `res_id` (String) Resource ID @@ -69,7 +72,6 @@ description: |- - `status` (String) Disk status - `tech_status` (String) Technical status of the disk - `to_clean` (Boolean) -- `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) - `vmid` (Number) Virtual Machine ID (Deprecated) diff --git a/docs/resources/image.md b/docs/resources/image.md index 6f95f59f..2e8ef282 100644 --- a/docs/resources/image.md +++ b/docs/resources/image.md @@ -54,8 +54,10 @@ description: |- - `history` (List of Object) (see [below for nested schema](#nestedatt--history)) - `id` (String) The ID of this resource. - `image_name` (String) +- `independent` (Boolean) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `present_to` (Map of Number) - `provider_name` (String) diff --git a/docs/resources/image_from_blank_compute.md b/docs/resources/image_from_blank_compute.md index 179de0dd..f6063b52 100644 --- a/docs/resources/image_from_blank_compute.md +++ b/docs/resources/image_from_blank_compute.md @@ -20,6 +20,7 @@ description: |- - `boot_type` (String) Boot type of image BIOS or UEFI - `compute_id` (Number) Compute Id - `name` (String) Name of the rescue disk +- `storage_policy_id` (Number) Storage policy ID - `type` (String) Image type linux, windows or unknown ### Optional @@ -52,6 +53,7 @@ description: |- - `image_name` (String) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `network_interface_naming` (String) - `present_to` (Map of Number) diff --git a/docs/resources/image_from_platform_disk.md b/docs/resources/image_from_platform_disk.md index ea4c816b..4b73410b 100644 --- a/docs/resources/image_from_platform_disk.md +++ b/docs/resources/image_from_platform_disk.md @@ -52,6 +52,7 @@ description: |- - `image_name` (String) - `last_modified` (Number) - `link_to` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `network_interface_naming` (String) - `present_to` (Map of Number) diff --git a/docs/resources/image_virtual.md b/docs/resources/image_virtual.md index 7237af0f..e29ce402 100644 --- a/docs/resources/image_virtual.md +++ b/docs/resources/image_virtual.md @@ -44,7 +44,9 @@ description: |- - `id` (String) The ID of this resource. - `image_id` (Number) Image id - `image_name` (String) +- `independent` (Boolean) - `last_modified` (Number) +- `links_to` (List of Number) - `milestones` (Number) - `network_interface_naming` (String) - `password` (String) diff --git a/docs/resources/kvmvm.md b/docs/resources/kvmvm.md index 27fc7bb4..e78187fa 100644 --- a/docs/resources/kvmvm.md +++ b/docs/resources/kvmvm.md @@ -27,6 +27,7 @@ description: |- - `affinity_label` (String) Set affinity label for compute - `affinity_rules` (Block List) (see [below for nested schema](#nestedblock--affinity_rules)) +- `alt_boot_id` (Number) ID of CD-ROM live image to boot - `anti_affinity_rules` (Block List) (see [below for nested schema](#nestedblock--anti_affinity_rules)) - `auto_start_w_node` (Boolean) Flag for start compute after node exits from MAINTENANCE state - `boot_disk_size` (Number) This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image. @@ -35,6 +36,7 @@ description: |- - `chipset` (String) Type of the emulated system. - `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases. - `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node. +- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case. - `custom_fields` (String) - `description` (String) Optional text description of this compute instance. - `detach_disks` (Boolean) @@ -46,8 +48,6 @@ description: |- - `hot_resize` (Boolean) Type of image vm. - `hp_backed` (Boolean) Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node. - `image_id` (Number) ID of the OS image to base this compute instance on. -- `ipa_type` (String) compute purpose -- `is` (String) system name - `loader_type` (String) Type of image vm. - `network` (Block Set) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network)) - `network_interface_naming` (String) Name of netfowrk interface. @@ -132,6 +132,7 @@ description: |- - `virtual_image_id` (Number) - `virtual_image_name` (String) - `vnc_password` (String) +- `weight` (Number) Priority weight of the compute. Higher value means higher priority and later migration. ### Nested Schema for `affinity_rules` @@ -177,7 +178,6 @@ Required: Optional: - `desc` (String) Optional description -- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data' - `image_id` (Number) Specify image id for create disk from template - `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune)) - `permanently` (Boolean) Disk deletion status @@ -187,6 +187,8 @@ Optional: Read-Only: - `blk_discard` (Boolean) +- `block_size` (String) +- `bus_number` (Number) Bus number of the disk on virtual bus (6 = boot disk) - `cache` (String) - `created_by` (String) - `created_time` (Number) @@ -194,7 +196,10 @@ Read-Only: - `deleted_time` (Number) - `devicename` (String) - `disk_id` (Number) Disk ID +- `independent` (Boolean) +- `pci_slot` (Number) PCI slot number of the disk - `present_to` (Map of Number) +- `provision` (String) - `shareable` (Boolean) - `size_max` (Number) - `size_used` (Number) @@ -235,7 +240,7 @@ Optional: - `enabled` (Boolean) network enable flag - `ip_address` (String) Optional IP address to assign to this connection. This IP should belong to the selected network and free for use. - `mac` (String) MAC address associated with this connection. MAC address is assigned automatically. -- `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1-9216 +- `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1500-9216 - `net_mask` (Number) Subnet mask, used only for DPDK and VFNIC network types - `sdn_interface_id` (String) unique_identifier of LogicalPort on SDN side - `weight` (Number) weight the network if you need to sort network list, the smallest attach first. zero or null weight attach last @@ -321,6 +326,8 @@ Required: Read-Only: - `blk_discard` (Boolean) +- `block_size` (String) +- `bus_number` (Number) - `cache` (String) - `created_by` (String) - `created_time` (Number) @@ -330,12 +337,14 @@ Read-Only: - `devicename` (String) - `disk_id` (Number) - `disk_name` (String) -- `disk_type` (String) - `image_id` (Number) +- `independent` (Boolean) - `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--boot_disk--iotune)) +- `pci_slot` (Number) - `permanently` (Boolean) - `pool` (String) - `present_to` (Map of Number) +- `provision` (String) - `sep_id` (Number) - `shareable` (Boolean) - `size` (Number) diff --git a/docs/resources/resgroup.md b/docs/resources/resgroup.md index 1c4769eb..57371bab 100644 --- a/docs/resources/resgroup.md +++ b/docs/resources/resgroup.md @@ -135,6 +135,7 @@ Optional: Read-Only: +- `email` (String) - `explicit` (Boolean) - `guid` (String) - `right` (String) diff --git a/docs/resources/sdn_hypervisor.md b/docs/resources/sdn_hypervisor.md new file mode 100644 index 00000000..4244781a --- /dev/null +++ b/docs/resources/sdn_hypervisor.md @@ -0,0 +1,74 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_hypervisor Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_hypervisor (Resource) + + + + + + +## Schema + +### Required + +- `display_name` (String) +- `name` (String) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `created_at` (String) +- `hostname` (String) +- `id` (String) The ID of this resource. +- `ip` (String) +- `ports` (List of Object) (see [below for nested schema](#nestedatt--ports)) +- `status` (String) +- `synced_at` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `ports` + +Read-Only: + +- `data` (List of Object) (see [below for nested schema](#nestedobjatt--ports--data)) +- `info` (List of Object) (see [below for nested schema](#nestedobjatt--ports--info)) + + +### Nested Schema for `ports.data` + +Read-Only: + +- `display_name` (String) +- `id` (String) +- `unique_identifier` (String) +- `up` (Boolean) + + + +### Nested Schema for `ports.info` + +Read-Only: + +- `active_ports` (Number) +- `total_ports` (Number) diff --git a/docs/resources/sdn_logical_port.md b/docs/resources/sdn_logical_port.md index 53a259ed..fd23d9b6 100644 --- a/docs/resources/sdn_logical_port.md +++ b/docs/resources/sdn_logical_port.md @@ -22,7 +22,6 @@ description: |- - `display_name` (String) Display Name - `enabled` (Boolean) Whether the logical port should be enabled - `hypervisor` (String) Hypervisor -- `is_excluded_from_firewall` (Boolean) - `port_security` (Boolean) Whether the port security is enabled - `segment_id` (String) Segment ID @@ -30,7 +29,9 @@ description: |- - `adapter_mac` (String) Adapter MAC address - `force` (Boolean) +- `labels` (Block List, Max: 1) Labels (see [below for nested schema](#nestedblock--labels)) - `logical_port_addresses` (Block List) (see [below for nested schema](#nestedblock--logical_port_addresses)) +- `migrate` (Boolean) If true, triggers live migration to the hypervisor specified in the 'hypervisor' field. If false, hypervisor changes are applied via the regular update endpoint. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `unique_identifier` (String) Unique identifier of the logical port @@ -47,6 +48,15 @@ description: |- - `status` (List of Object) (see [below for nested schema](#nestedatt--status)) - `version_id` (Number) Version ID of the logical port + +### Nested Schema for `labels` + +Optional: + +- `vm_id` (String) VM ID label +- `vm_name` (String) VM name label + + ### Nested Schema for `logical_port_addresses` @@ -82,21 +92,37 @@ Read-Only: - `address_detection` (Boolean) - `created_at` (String) - `id` (String) -- `is_excluded_from_firewall` (Boolean) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--bindings--logical_port_addresses)) - `port_security` (Boolean) - `segment_display_name` (String) - `segment_id` (String) - `updated_at` (String) - `version_id` (Number) + +### Nested Schema for `bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + ### Nested Schema for `status` Read-Only: -- `common` (String) +- `hypervisor_status` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `status.hypervisors` @@ -106,5 +132,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/resources/sdn_network_object_group.md b/docs/resources/sdn_network_object_group.md new file mode 100644 index 00000000..bfe89a00 --- /dev/null +++ b/docs/resources/sdn_network_object_group.md @@ -0,0 +1,721 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_network_object_group Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_network_object_group (Resource) + + + + + + +## Schema + +### Required + +- `access_group_id` (String) +- `description` (String) +- `name` (String) + +### Optional + +- `addresses` (Block List) (see [below for nested schema](#nestedblock--addresses)) +- `l2_connection_ports_bindings` (Block List) (see [below for nested schema](#nestedblock--l2_connection_ports_bindings)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_name` (String) +- `counters` (List of Object) (see [below for nested schema](#nestedatt--counters)) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedatt--external_network_ports)) +- `id` (String) The ID of this resource. +- `l2_connection_ports` (List of Object) (see [below for nested schema](#nestedatt--l2_connection_ports)) +- `logical_ports` (List of Object) (see [below for nested schema](#nestedatt--logical_ports)) +- `purpose` (String) +- `security_policies` (List of Object) (see [below for nested schema](#nestedatt--security_policies)) +- `type` (String) +- `version_id` (Number) + + +### Nested Schema for `addresses` + +Required: + +- `net_address_type` (String) + +Optional: + +- `ip_addr` (String) +- `ip_addr_range_end` (String) +- `ip_prefix` (String) +- `mac_addr` (String) + +Read-Only: + +- `id` (String) + + + +### Nested Schema for `l2_connection_ports_bindings` + +Required: + +- `port_id` (String) +- `port_version` (Number) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `counters` + +Read-Only: + +- `addresses_count` (Number) +- `l2_connection_ports_count` (Number) +- `logical_ports_count` (Number) +- `security_policies_count` (Number) +- `security_rules_count` (Number) + + + +### Nested Schema for `external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `bridge_network_name` (String) +- `comment` (String) +- `created_at` (String) +- `default_gateway_ipv4` (String) +- `default_gateway_ipv6` (String) +- `description` (String) +- `enabled` (Boolean) +- `external_network_ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports)) +- `hypervisors` (List of String) +- `id` (String) +- `ipv4` (String) +- `mac` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--status)) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `comment` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `floating_ip` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip)) +- `ipv4` (String) +- `ipv6` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--ipv6_config)) +- `mac` (String) +- `router_gateaway_port` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--router_gateaway_port)) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `logical_port` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port)) +- `router` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--logical_port--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.logical_port.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `gateaway_ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports)) +- `id` (String) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--policies)) +- `ports` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports)) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `external_l4_port_max` (Number) +- `external_l4_port_min` (Number) +- `id` (String) +- `snat_enabled` (Boolean) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--gateaway_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.gateaway_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.policies` + +Read-Only: + +- `action` (String) +- `created_at` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `match` (String) +- `next_ipv4_address` (List of String) +- `next_ipv6_address` (List of String) +- `priority` (Number) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `enabled` (Boolean) +- `id` (String) +- `ipv4_address` (String) +- `ipv6_address` (String) +- `ipv6_config` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--ipv6_config)) +- `mac` (String) +- `segment` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--segment)) +- `segment_id` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.segment` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--external_network_ports--floating_ip--router--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.external_network_ports.floating_ip.router.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + + +### Nested Schema for `external_network_ports.external_network_ports.ipv6_config` + +Read-Only: + +- `address_mode` (String) +- `enable_periodic_ra` (Boolean) +- `interval_ra` (Number) +- `router_preference` (String) + + + +### Nested Schema for `external_network_ports.external_network_ports.router_gateaway_port` + +Read-Only: + +- `created_at` (String) +- `description` (String) +- `id` (String) +- `router_display_name` (String) +- `router_id` (String) +- `snat_enabled` (Boolean) +- `updated_at` (String) + + + + +### Nested Schema for `external_network_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--external_network_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `external_network_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `l2_connection_ports` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--l2_connection_ports--l2_external_network)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `l2_connection_ports.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + + +### Nested Schema for `logical_ports` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `exclude_firewall` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--exclude_firewall)) +- `external_network_id` (String) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `labels` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--labels)) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `logical_ports.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `logical_port_addresses` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--bindings--logical_port_addresses)) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `logical_ports.bindings.logical_port_addresses` + +Read-Only: + +- `assigned_at` (String) +- `id` (String) +- `ip` (String) +- `ip_type` (String) +- `is_discovered` (Boolean) +- `is_primary` (Boolean) +- `logical_port_id` (String) +- `mac` (String) + + + + +### Nested Schema for `logical_ports.exclude_firewall` + +Read-Only: + +- `exclusion_reason` (String) +- `logical_port_addresses_excluded` (Boolean) +- `logical_port_excluded` (Boolean) + + + +### Nested Schema for `logical_ports.labels` + +Read-Only: + +- `vm_id` (String) +- `vm_name` (String) + + + +### Nested Schema for `logical_ports.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--logical_ports--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `logical_ports.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) + + + + + +### Nested Schema for `security_policies` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `applied_net_object_groups` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--applied_net_object_groups)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `end_priority` (Number) +- `id` (String) +- `security_rules` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules)) +- `start_priority` (Number) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--status)) +- `type` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `security_policies.applied_net_object_groups` + +Read-Only: + +- `id` (String) +- `name` (String) +- `version_id` (Number) + + + +### Nested Schema for `security_policies.security_rules` + +Read-Only: + +- `access_group_id` (String) +- `action` (String) +- `description` (String) +- `destination_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--destination_net_object)) +- `direction` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `filter` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--filter)) +- `id` (String) +- `log_enabled` (Boolean) +- `log_name` (String) +- `log_severity` (String) +- `priority` (Number) +- `security_policy_id` (String) +- `source_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--source_net_object)) +- `statistics_enabled` (Boolean) +- `type` (String) +- `version_id` (Number) + + +### Nested Schema for `security_policies.security_rules.destination_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + +### Nested Schema for `security_policies.security_rules.filter` + +Read-Only: + +- `filters` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--security_rules--filter--filters)) +- `name` (String) + + +### Nested Schema for `security_policies.security_rules.filter.filters` + +Read-Only: + +- `all` (Boolean) +- `arp` (Boolean) +- `dhcp` (Boolean) +- `expression` (String) +- `icmp` (Boolean) +- `ip` (Boolean) +- `ip_v4` (Boolean) +- `ip_v6` (Boolean) +- `keep_opened_sessions` (Boolean) +- `nd` (Boolean) +- `tcp` (Boolean) +- `tcp_dst_ports` (List of String) +- `udp` (Boolean) +- `udp_dst_ports` (List of String) + + + + +### Nested Schema for `security_policies.security_rules.source_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + + +### Nested Schema for `security_policies.status` + +Read-Only: + +- `hypervisor_status` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--security_policies--status--hypervisors)) +- `operation_status` (String) + + +### Nested Schema for `security_policies.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `operation_status` (String) +- `synced_at` (String) diff --git a/docs/resources/sdn_segment.md b/docs/resources/sdn_segment.md index 624f6b2f..f1a03b79 100644 --- a/docs/resources/sdn_segment.md +++ b/docs/resources/sdn_segment.md @@ -30,12 +30,14 @@ description: |- - `subnet_v4` (String) - `subnet_v6` (String) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `type` (String) ### Read-Only - `access_group_name` (String) - `created_at` (String) - `id` (String) The ID of this resource. +- `l2_connection_port` (List of Object) (see [below for nested schema](#nestedatt--l2_connection_port)) - `logical_ports_info` (List of Object) (see [below for nested schema](#nestedatt--logical_ports_info)) - `routers_info` (List of Object) (see [below for nested schema](#nestedatt--routers_info)) - `status` (List of Object) (see [below for nested schema](#nestedatt--status)) @@ -94,6 +96,39 @@ Optional: - `update` (String) + +### Nested Schema for `l2_connection_port` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `created_by` (String) +- `id` (String) +- `l2_external_network` (List of Object) (see [below for nested schema](#nestedobjatt--l2_connection_port--l2_external_network)) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) + + +### Nested Schema for `l2_connection_port.l2_external_network` + +Read-Only: + +- `bridge_network_name` (String) +- `created_at` (String) +- `created_by` (String) +- `description` (String) +- `display_name` (String) +- `hypervisors` (List of String) +- `id` (String) +- `updated_at` (String) +- `updated_by` (String) +- `version_id` (Number) +- `vlan_tag` (Number) + + + ### Nested Schema for `logical_ports_info` @@ -117,8 +152,8 @@ Read-Only: Read-Only: -- `common` (String) - `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) +- `operation_status` (String) ### Nested Schema for `status.hypervisors` @@ -128,5 +163,5 @@ Read-Only: - `display_name` (String) - `hypervisor_status` (String) - `name` (String) -- `status` (String) +- `operation_status` (String) - `synced_at` (String) diff --git a/docs/resources/vins.md b/docs/resources/vins.md index 7e7e2f54..bf6bf788 100644 --- a/docs/resources/vins.md +++ b/docs/resources/vins.md @@ -25,6 +25,7 @@ description: |- - `desc` (String) Optional user-defined text description of this ViNS. - `dns` (Set of String) - `enable` (Boolean) +- `enable_secgroups` (Boolean) enable security groups - `ext_ip_addr` (String) - `ext_net` (Block List, Max: 1) (see [below for nested schema](#nestedblock--ext_net)) - `ext_net_id` (Number) diff --git a/go.mod b/go.mod index 3e3cf695..4861ba76 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 github.com/sirupsen/logrus v1.9.0 golang.org/x/net v0.44.0 - repository.basistech.ru/BASIS/decort-golang-sdk v1.13.9 + repository.basistech.ru/BASIS/decort-golang-sdk v1.14.11 ) require ( diff --git a/go.sum b/go.sum index 0428eae1..06b88df1 100644 --- a/go.sum +++ b/go.sum @@ -318,5 +318,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -repository.basistech.ru/BASIS/decort-golang-sdk v1.13.9 h1:jrfwiJBuHbt3JlVwD6DWF3E/H9pyDOJOvb8F5sQ/mhM= -repository.basistech.ru/BASIS/decort-golang-sdk v1.13.9/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM= +repository.basistech.ru/BASIS/decort-golang-sdk v1.14.11 h1:lG35W5nKyEgaLMQp6B0Ur1n7bjXDCmB2FHQI/mM59U0= +repository.basistech.ru/BASIS/decort-golang-sdk v1.14.11/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM= diff --git a/internal/provider/data_sources_map.go b/internal/provider/data_sources_map.go index 8d1bcf28..8f8b144e 100644 --- a/internal/provider/data_sources_map.go +++ b/internal/provider/data_sources_map.go @@ -45,7 +45,9 @@ import ( "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/zone" accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group" defaultsecuritypolicy "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/default_security_policy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/hypervisors" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/netobjgroups" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments" cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account" @@ -71,7 +73,6 @@ import ( cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool" cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins" cb_zone "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/zone" - // cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu" ) func newDataSourcesMap() map[string]*schema.Resource { @@ -119,8 +120,6 @@ func newDataSourcesMap() map[string]*schema.Resource { "decort_rg_list_pfw": rg.DataSourceRgListPfw(), "decort_rg_list_vins": rg.DataSourceRgListVins(), "decort_rg_usage": rg.DataSourceRgUsage(), - "decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(), - "decort_disk_list_types": disks.DataSourceDiskListTypes(), "decort_disk_list_deleted": disks.DataSourceDiskListDeleted(), "decort_disk_list_unattached": disks.DataSourceDiskListUnattached(), "decort_disk_snapshot": disks.DataSourceDiskSnapshot(), @@ -235,8 +234,6 @@ func newDataSourcesMap() map[string]*schema.Resource { "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(), @@ -309,10 +306,15 @@ func newDataSourcesMap() map[string]*schema.Resource { "decort_sdn_default_security_policy_list": defaultsecuritypolicy.DataSourceDefaultSecurityPolicyList(), "decort_sdn_segment": segments.DataSourceSegment(), "decort_sdn_segment_list": segments.DataSourceSegmentList(), - "decort_sdn_segment_get_status": segments.DataSourceSegmentGetStatus(), + + "decort_sdn_hypervisor": hypervisors.DataSourceHypervisor(), + "decort_sdn_hypervisor_list": hypervisors.DataSourceHypervisorList(), "decort_sdn_logical_port": logicalports.DataSourceLogicalPort(), "decort_sdn_logical_port_get_by_unique_identifier": logicalports.DataSourceLogicalPortByUniqueID(), "decort_sdn_logical_port_list": logicalports.DataSourceLogicalPortList(), + + "decort_sdn_network_object_group": netobjgroups.DataSourceNetworkObjectGroup(), + "decort_sdn_network_object_group_list": netobjgroups.DataSourceNetworkObjectGroupList(), } } diff --git a/internal/provider/resource_map.go b/internal/provider/resource_map.go index ff3d60cf..631dc2eb 100644 --- a/internal/provider/resource_map.go +++ b/internal/provider/resource_map.go @@ -36,7 +36,9 @@ import ( "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins" accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/hypervisors" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/netobjgroups" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments" cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account" @@ -102,6 +104,7 @@ func newResourcesMap() map[string]*schema.Resource { "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_multi_image": cb_image.ResourceMultiImage(), "decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(), "decort_cb_sep": cb_sep.ResourceSep(), "decort_cb_sep_config": cb_sep.ResourceSepConfig(), @@ -125,8 +128,10 @@ func newResourcesMap() map[string]*schema.Resource { "decort_cb_vfpool": cb_vfpool.ResourceVFPool(), "decort_cb_zone": cb_zone.ResourceZone(), - "decort_sdn_segment": segments.ResourceSegment(), - "decort_sdn_access_group": accessgroup.ResourceAccessGroup(), - "decort_sdn_logical_port": logicalports.ResourceLogicalPort(), + "decort_sdn_segment": segments.ResourceSegment(), + "decort_sdn_access_group": accessgroup.ResourceAccessGroup(), + "decort_sdn_hypervisor": hypervisors.ResourceHypervisor(), + "decort_sdn_logical_port": logicalports.ResourceLogicalPort(), + "decort_sdn_network_object_group": netobjgroups.ResourceNetworkObjectGroup(), } } diff --git a/internal/service/cloudapi/account/data_source_account.go b/internal/service/cloudapi/account/data_source_account.go index 5c117f50..8543493f 100644 --- a/internal/service/cloudapi/account/data_source_account.go +++ b/internal/service/cloudapi/account/data_source_account.go @@ -307,6 +307,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/account/data_source_account_list.go b/internal/service/cloudapi/account/data_source_account_list.go index e2d7c265..a44d0c59 100644 --- a/internal/service/cloudapi/account/data_source_account_list.go +++ b/internal/service/cloudapi/account/data_source_account_list.go @@ -51,10 +51,12 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} { "created_time": acc.CreatedTime, "desc": acc.Description, "deleted_time": acc.DeletedTime, + "deleted_by": acc.DeletedBy, "account_id": acc.ID, "account_name": acc.Name, "status": acc.Status, "updated_time": acc.UpdatedTime, + "updated_by": acc.UpdatedBy, "zone_ids": acc.ZoneIDs, } res = append(res, temp) @@ -191,6 +193,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "deleted_by": { + Type: schema.TypeString, + Computed: true, + }, "account_id": { Type: schema.TypeInt, Computed: true, @@ -207,6 +213,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "zone_ids": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/account/flattens.go b/internal/service/cloudapi/account/flattens.go index 2ee43f1b..b64035be 100644 --- a/internal/service/cloudapi/account/flattens.go +++ b/internal/service/cloudapi/account/flattens.go @@ -26,6 +26,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error { d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits)) d.Set("send_access_emails", acc.SendAccessEmails) d.Set("status", acc.Status) + d.Set("updated_by", acc.UpdatedBy) d.Set("updated_time", acc.UpdatedTime) d.Set("version", acc.Version) d.Set("vins", acc.VINS) @@ -68,6 +69,7 @@ func flattenAccountResource(d *schema.ResourceData, acc account.RecordAccount) e d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits)) d.Set("send_access_emails", acc.SendAccessEmails) d.Set("status", acc.Status) + d.Set("updated_by", acc.UpdatedBy) d.Set("updated_time", acc.UpdatedTime) d.Set("version", acc.Version) d.Set("vins", acc.VINS) diff --git a/internal/service/cloudapi/account/resource_account.go b/internal/service/cloudapi/account/resource_account.go index 619248f0..48f5aa6b 100644 --- a/internal/service/cloudapi/account/resource_account.go +++ b/internal/service/cloudapi/account/resource_account.go @@ -625,6 +625,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/disks/data_source_disk.go b/internal/service/cloudapi/disks/data_source_disk.go index fa108163..68af2d17 100644 --- a/internal/service/cloudapi/disks/data_source_disk.go +++ b/internal/service/cloudapi/disks/data_source_disk.go @@ -84,6 +84,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, // "boot_partition": { // Type: schema.TypeInt, // Computed: true, @@ -166,6 +170,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { }, Description: "IDs of images using the disk", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -304,6 +312,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, // "purge_attempts": { // Type: schema.TypeInt, // Computed: true, @@ -457,11 +469,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { 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, diff --git a/internal/service/cloudapi/disks/data_source_disk_list.go b/internal/service/cloudapi/disks/data_source_disk_list.go index 63b3d2dc..ee80f0c8 100644 --- a/internal/service/cloudapi/disks/data_source_disk_list.go +++ b/internal/service/cloudapi/disks/data_source_disk_list.go @@ -93,11 +93,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "ID of the account the disks belong to", }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: "type of the disks", - }, "sep_id": { Type: schema.TypeInt, Optional: true, @@ -128,6 +123,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "storage policy ID ", }, + "compute_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Find by compute ID", + }, + "rg_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Find by rg ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -151,6 +156,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, // "boot_partition": { // Type: schema.TypeInt, // Computed: true, @@ -234,6 +243,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { }, Description: "IDs of images using the disk", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -378,6 +391,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, // "purge_attempts": { // Type: schema.TypeInt, // Computed: true, @@ -531,11 +548,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { 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, diff --git a/internal/service/cloudapi/disks/data_source_disk_list_types.go b/internal/service/cloudapi/disks/data_source_disk_list_types.go deleted file mode 100644 index a3cfde4a..00000000 --- a/internal/service/cloudapi/disks/data_source_disk_list_types.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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" - "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 dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m) - if err != nil { - d.SetId("") - return diag.FromErr(err) - } - - id := uuid.New() - d.SetId(id.String()) - d.Set("types", listTypes.Data) - d.Set("entry_count", listTypes.EntryCount) - return nil -} - -func dataSourceDiskListTypesSchemaMake() 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": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - 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 -} - -func DataSourceDiskListTypes() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 1, - ReadContext: dataSourceDiskListTypesRead, - - Timeouts: &schema.ResourceTimeout{ - Read: &constants.Timeout30s, - Default: &constants.Timeout60s, - }, - - Schema: dataSourceDiskListTypesSchemaMake(), - } -} diff --git a/internal/service/cloudapi/disks/data_source_disk_list_types_detailed.go b/internal/service/cloudapi/disks/data_source_disk_list_types_detailed.go deleted file mode 100644 index 9ea2b030..00000000 --- a/internal/service/cloudapi/disks/data_source_disk_list_types_detailed.go +++ /dev/null @@ -1,167 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "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" -) - -func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} { - res := make([]map[string]interface{}, 0) - for _, typeListDetailed := range tld.Data { - toMap := typeListDetailed.(map[string]interface{}) - temp := map[string]interface{}{ - "pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})), - "sep_id": toMap["sepId"].(float64), - "sep_name": toMap["sepName"].(string), - } - res = append(res, temp) - } - return res -} - -func flattenListTypesDetailedPools(pools []interface{}) []interface{} { - res := make([]interface{}, 0) - for _, pool := range pools { - toMap := pool.(map[string]interface{}) - temp := map[string]interface{}{ - "name": toMap["name"].(string), - "system": toMap["system"].(string), - "types": toMap["types"].([]interface{}), - } - res = append(res, temp) - } - - return res -} - -func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m) - if err != nil { - d.SetId("") - return diag.FromErr(err) - } - - id := uuid.New() - d.SetId(id.String()) - d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed)) - d.Set("entry_count", listTypesDetailed.EntryCount) - return nil -} - -func dataSourceDiskListTypesDetailedSchemaMake() 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": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pools": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Pool name", - }, - "system": { - Type: schema.TypeString, - Computed: true, - }, - "types": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", - }, - }, - }, - }, - "sep_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Storage endpoint provider ID to create disk", - }, - "sep_name": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "entry_count": { - Type: schema.TypeInt, - Computed: true, - }, - } - return res -} - -func DataSourceDiskListTypesDetailed() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 1, - ReadContext: dataSourceDiskListTypesDetailedRead, - - Timeouts: &schema.ResourceTimeout{ - Read: &constants.Timeout30s, - Default: &constants.Timeout60s, - }, - - Schema: dataSourceDiskListTypesDetailedSchemaMake(), - } -} diff --git a/internal/service/cloudapi/disks/data_source_disk_list_unattached.go b/internal/service/cloudapi/disks/data_source_disk_list_unattached.go index 589a9956..cdc65760 100644 --- a/internal/service/cloudapi/disks/data_source_disk_list_unattached.go +++ b/internal/service/cloudapi/disks/data_source_disk_list_unattached.go @@ -108,11 +108,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { 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, @@ -164,6 +159,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -330,6 +329,17 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Computed: true, Description: "ID of the parent disk", }, + "present_to": { + Type: schema.TypeMap, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "passwd": { Type: schema.TypeString, Computed: true, @@ -453,10 +463,9 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { 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'", + "to_clean": { + Type: schema.TypeBool, + Computed: true, }, "vmid": { Type: schema.TypeInt, diff --git a/internal/service/cloudapi/disks/data_source_disk_replication.go b/internal/service/cloudapi/disks/data_source_disk_replication.go index 7fcda844..e0bbd28f 100644 --- a/internal/service/cloudapi/disks/data_source_disk_replication.go +++ b/internal/service/cloudapi/disks/data_source_disk_replication.go @@ -449,11 +449,6 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema { 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, diff --git a/internal/service/cloudapi/disks/data_source_list_deleted.go b/internal/service/cloudapi/disks/data_source_list_deleted.go index f5df39b3..680edeb4 100644 --- a/internal/service/cloudapi/disks/data_source_list_deleted.go +++ b/internal/service/cloudapi/disks/data_source_list_deleted.go @@ -89,11 +89,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { 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, @@ -132,6 +127,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, // "boot_partition": { // Type: schema.TypeInt, // Computed: true, @@ -219,6 +218,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { }, Description: "IDs of images using the disk", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -359,6 +362,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, // "purge_attempts": { // Type: schema.TypeInt, // Computed: true, @@ -512,11 +519,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { 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, diff --git a/internal/service/cloudapi/disks/flattens.go b/internal/service/cloudapi/disks/flattens.go index 95841e0a..3e4a3ed5 100644 --- a/internal/service/cloudapi/disks/flattens.go +++ b/internal/service/cloudapi/disks/flattens.go @@ -26,6 +26,7 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter "account_name": unattachedDisk.AccountName, "acl": string(unattachedDiskAcl), "blk_discard": unattachedDisk.BLKDiscard, + "block_size": unattachedDisk.BlockSize, "boot_partition": unattachedDisk.BootPartition, "created_time": unattachedDisk.CreatedTime, "deleted_time": unattachedDisk.DeletedTime, @@ -48,6 +49,8 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter "passwd": unattachedDisk.Password, "pci_slot": unattachedDisk.PCISlot, "pool": unattachedDisk.Pool, + "present_to": unattachedDisk.PresentTo, + "provision": unattachedDisk.Provision, "purge_attempts": unattachedDisk.PurgeAttempts, "purge_time": unattachedDisk.PurgeTime, "reality_device_number": unattachedDisk.RealityDeviceNumber, @@ -62,8 +65,8 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter "size_used": unattachedDisk.SizeUsed, "snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots), "status": unattachedDisk.Status, + "to_clean": unattachedDisk.ToClean, "tech_status": unattachedDisk.TechStatus, - "type": unattachedDisk.Type, "vmid": unattachedDisk.VMID, } res = append(res, tmp) @@ -77,6 +80,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("account_name", disk.AccountName) d.Set("acl", string(diskAcl)) d.Set("blk_discard", disk.BLKDiscard) + d.Set("block_size", disk.BlockSize) // d.Set("boot_partition", disk.BootPartition) d.Set("computes", flattenDiskComputes(disk.Computes)) d.Set("created_by", disk.CreatedBy) @@ -95,6 +99,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("iotune", flattenIOTune(disk.IOTune)) // d.Set("iqn", disk.IQN) // d.Set("login", disk.Login) + d.Set("independent", disk.Independent) d.Set("machine_id", disk.MachineID) d.Set("machine_name", disk.MachineName) d.Set("disk_name", disk.Name) @@ -105,6 +110,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("pci_slot", disk.PCISlot) d.Set("pool", disk.Pool) d.Set("present_to", disk.PresentTo) + d.Set("provision", disk.Provision) // d.Set("purge_attempts", disk.PurgeAttempts) d.Set("purge_time", disk.PurgeTime) d.Set("replication", flattenDiskReplication(disk.Replication)) @@ -123,7 +129,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("status", disk.Status) d.Set("storage_policy_id", disk.StoragePolicyID) d.Set("tech_status", disk.TechStatus) - d.Set("type", disk.Type) d.Set("vmid", disk.VMID) d.Set("updated_by", disk.UpdatedBy) d.Set("updated_time", disk.UpdatedTime) @@ -192,7 +197,6 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe 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) } @@ -222,6 +226,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "account_name": disk.AccountName, "acl": string(diskAcl), "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, "computes": flattenDiskComputes(disk.Computes), "created_by": disk.CreatedBy, "created_time": disk.CreatedTime, @@ -234,6 +239,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "disk_id": disk.ID, "image_id": disk.ImageID, "images": disk.Images, + "independent": disk.Independent, "iotune": flattenIOTune(disk.IOTune), "machine_id": disk.MachineID, "machine_name": disk.MachineName, @@ -245,6 +251,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "pci_slot": disk.PCISlot, "pool": disk.Pool, "present_to": disk.PresentTo, + "provision": disk.Provision, "purge_time": disk.PurgeTime, "replication": flattenDiskReplication(disk.Replication), "res_id": disk.ResID, @@ -261,7 +268,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "status": disk.Status, "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, - "type": disk.Type, "vmid": disk.VMID, "updated_by": disk.UpdatedBy, "updated_time": disk.UpdatedTime, diff --git a/internal/service/cloudapi/disks/resource_disk.go b/internal/service/cloudapi/disks/resource_disk.go index f8de29ad..393dfcbd 100644 --- a/internal/service/cloudapi/disks/resource_disk.go +++ b/internal/service/cloudapi/disks/resource_disk.go @@ -606,6 +606,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { }, Description: "IDs of images using the disk", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, // "iqn": { // Type: schema.TypeString, // Computed: true, @@ -644,11 +648,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "ID of the parent 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'", - }, // "passwd": { // Type: schema.TypeString, // Computed: true, @@ -664,6 +663,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { // Computed: true, // Description: "Number of deletion attempts", // }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_time": { Type: schema.TypeInt, Computed: true, @@ -807,6 +810,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Flag indicating whether blk-discard is enabled for the disk", }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, } return rets diff --git a/internal/service/cloudapi/disks/resource_disk_replication.go b/internal/service/cloudapi/disks/resource_disk_replication.go index ac391d32..4bdb230a 100644 --- a/internal/service/cloudapi/disks/resource_disk_replication.go +++ b/internal/service/cloudapi/disks/resource_disk_replication.go @@ -595,11 +595,6 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema { 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, diff --git a/internal/service/cloudapi/disks/utility_disk_list.go b/internal/service/cloudapi/disks/utility_disk_list.go index 951cffd7..cb7ff343 100644 --- a/internal/service/cloudapi/disks/utility_disk_list.go +++ b/internal/service/cloudapi/disks/utility_disk_list.go @@ -34,7 +34,6 @@ package disks import ( "context" - "strings" log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks" @@ -68,9 +67,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if accountId, ok := d.GetOk("account_id"); ok { 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)) } @@ -89,6 +85,12 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { req.StoragePolicyID = uint64(storagePolicyID.(int)) } + if rgID, ok := d.GetOk("rg_id"); ok { + req.RGID = uint64(rgID.(int)) + } + if computeID, ok := d.GetOk("compute_id"); ok { + req.ComputeID = uint64(computeID.(int)) + } log.Debugf("utilityDiskListCheckPresence: load disk list") diskList, err := c.CloudAPI().Disks().List(ctx, req) diff --git a/internal/service/cloudapi/disks/utility_disk_list_deleted.go b/internal/service/cloudapi/disks/utility_disk_list_deleted.go index deee12cb..a3b9af9f 100644 --- a/internal/service/cloudapi/disks/utility_disk_list_deleted.go +++ b/internal/service/cloudapi/disks/utility_disk_list_deleted.go @@ -50,10 +50,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource 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) } diff --git a/internal/service/cloudapi/disks/utility_disk_list_unattached.go b/internal/service/cloudapi/disks/utility_disk_list_unattached.go index d640c41d..a5ca36f4 100644 --- a/internal/service/cloudapi/disks/utility_disk_list_unattached.go +++ b/internal/service/cloudapi/disks/utility_disk_list_unattached.go @@ -25,9 +25,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou 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)) } diff --git a/internal/service/cloudapi/image/flattens.go b/internal/service/cloudapi/image/flattens.go index 45b863fa..ce2694cd 100644 --- a/internal/service/cloudapi/image/flattens.go +++ b/internal/service/cloudapi/image/flattens.go @@ -42,8 +42,10 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) { d.Set("history", flattenHistory(img.History)) d.Set("hot_resize", img.HotResize) d.Set("image_id", img.ID) + d.Set("independent", img.Independent) d.Set("last_modified", img.LastModified) d.Set("link_to", img.LinkTo) + d.Set("links_to", img.LinksTo) d.Set("milestones", img.Milestones) d.Set("image_name", img.Name) d.Set("network_interface_naming", img.NetworkInterfaceNaming) diff --git a/internal/service/cloudapi/image/image_ds_subresource.go b/internal/service/cloudapi/image/image_ds_subresource.go index a55bfa01..fb242e2b 100644 --- a/internal/service/cloudapi/image/image_ds_subresource.go +++ b/internal/service/cloudapi/image/image_ds_subresource.go @@ -128,6 +128,10 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "last_modified": { Type: schema.TypeInt, Computed: true, @@ -136,6 +140,13 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/image/image_item_subresource.go b/internal/service/cloudapi/image/image_item_subresource.go index a6cdb2ab..45d322c3 100644 --- a/internal/service/cloudapi/image/image_item_subresource.go +++ b/internal/service/cloudapi/image/image_item_subresource.go @@ -89,6 +89,13 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "For virtual images, id image, which current image linked", }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "image_name": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/image/resource_check_input_values.go b/internal/service/cloudapi/image/resource_check_input_values.go index cc6d69a6..e2137586 100644 --- a/internal/service/cloudapi/image/resource_check_input_values.go +++ b/internal/service/cloudapi/image/resource_check_input_values.go @@ -52,9 +52,16 @@ func existComputeID(ctx context.Context, computeId uint64, m interface{}) error computeImageId := computeRecord.ImageID bootImageId := -1 for _, d := range computeRecord.Disks { - if d.Type == "B" { - bootImageId = int(d.ImageID) - break + if computeRecord.Chipset == "i440fx" { + if d.PCISlot == 6 { + bootImageId = int(d.ImageID) + break + } + } else { + if d.BusNumber == 6 { + bootImageId = int(d.ImageID) + break + } } } diff --git a/internal/service/cloudapi/image/resource_image_from_blank_compute.go b/internal/service/cloudapi/image/resource_image_from_blank_compute.go index f1bb1daf..1c313a80 100644 --- a/internal/service/cloudapi/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudapi/image/resource_image_from_blank_compute.go @@ -75,10 +75,11 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource c := m.(*controller.ControllerCfg) req := compute.CreateTemplateFromBlankRequest{ - ComputeID: computeId, - Name: name, - BootType: d.Get("boot_type").(string), - ImageType: d.Get("type").(string), + ComputeID: computeId, + Name: name, + BootType: d.Get("boot_type").(string), + ImageType: d.Get("type").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if username, ok := d.GetOk("username"); ok { @@ -297,6 +298,11 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Required: true, Description: "Name of the rescue disk", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy ID", + }, "boot_type": { Type: schema.TypeString, Required: true, @@ -439,6 +445,13 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/image/resource_image_from_platform_disk.go b/internal/service/cloudapi/image/resource_image_from_platform_disk.go index 756ebab6..8b45f8ad 100644 --- a/internal/service/cloudapi/image/resource_image_from_platform_disk.go +++ b/internal/service/cloudapi/image/resource_image_from_platform_disk.go @@ -423,6 +423,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/image/resource_image_virtual.go b/internal/service/cloudapi/image/resource_image_virtual.go index c9291868..1aae5628 100644 --- a/internal/service/cloudapi/image/resource_image_virtual.go +++ b/internal/service/cloudapi/image/resource_image_virtual.go @@ -1,139 +1,139 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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" - "strconv" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - log "github.com/sirupsen/logrus" - "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/controller" -) - -func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string)) - - c := m.(*controller.ControllerCfg) - req := image.CreateVirtualRequest{ - Name: d.Get("name").(string), - TargetID: uint64(d.Get("link_to").(int)), - AccountID: uint64(d.Get("account_id").(int)), - } - - imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(strconv.FormatUint(imageId, 10)) - d.Set("image_id", imageId) - - _, err = utilityImageCheckPresence(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - - return resourceImageRead(ctx, d, m) -} - -func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id()) - - if d.HasChange("name") { - err := resourceImageRename(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - - if d.HasChange("link_to") { - err := resourceImageVirtualLink(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - - return resourceImageRead(ctx, d, m) -} - -func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error { - log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id()) - c := m.(*controller.ControllerCfg) - req := image.LinkRequest{ - ImageID: uint64(d.Get("image_id").(int)), - TargetID: uint64(d.Get("link_to").(int)), - } - - _, err := c.CloudAPI().Image().Link(ctx, req) - if err != nil { - return err - } - - return nil -} - -func ResourceImageVirtual() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 2, - - CreateContext: resourceImageVirtualCreate, - ReadContext: resourceImageRead, - UpdateContext: resourceImageVirtualUpdate, - DeleteContext: resourceImageDelete, - - 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: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()), - StateUpgraders: []schema.StateUpgrader{ - { - Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(), - Upgrade: resourcePresentToUpgradeV1, - Version: 1, - }, - }, - } -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "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/controller" +) + +func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + req := image.CreateVirtualRequest{ + Name: d.Get("name").(string), + TargetID: uint64(d.Get("link_to").(int)), + AccountID: uint64(d.Get("account_id").(int)), + } + + imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(strconv.FormatUint(imageId, 10)) + d.Set("image_id", imageId) + + _, err = utilityImageCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + return resourceImageRead(ctx, d, m) +} + +func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id()) + + if d.HasChange("name") { + err := resourceImageRename(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("link_to") { + err := resourceImageVirtualLink(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + return resourceImageRead(ctx, d, m) +} + +func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error { + log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id()) + c := m.(*controller.ControllerCfg) + req := image.LinkRequest{ + ImageID: uint64(d.Get("image_id").(int)), + TargetID: uint64(d.Get("link_to").(int)), + } + + _, err := c.CloudAPI().Image().Link(ctx, req) + if err != nil { + return err + } + + return nil +} + +func ResourceImageVirtual() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 2, + + CreateContext: resourceImageVirtualCreate, + ReadContext: resourceImageRead, + UpdateContext: resourceImageVirtualUpdate, + DeleteContext: resourceImageDelete, + + 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: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentToUpgradeV1, + Version: 1, + }, + }, + } +} diff --git a/internal/service/cloudapi/k8s/resource_k8s.go b/internal/service/cloudapi/k8s/resource_k8s.go index 457bfacc..3582643f 100644 --- a/internal/service/cloudapi/k8s/resource_k8s.go +++ b/internal/service/cloudapi/k8s/resource_k8s.go @@ -805,13 +805,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema { Description: "insert ssl certificate in x509 pem format", }, - "chipset": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), - Default: "Q35", - Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", - }, + "chipset": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), + Default: "Q35", + Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", + }, "desc": { Type: schema.TypeString, diff --git a/internal/service/cloudapi/k8s/resource_k8s_cp.go b/internal/service/cloudapi/k8s/resource_k8s_cp.go index d2779369..8489fc16 100644 --- a/internal/service/cloudapi/k8s/resource_k8s_cp.go +++ b/internal/service/cloudapi/k8s/resource_k8s_cp.go @@ -715,13 +715,13 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema { ), Description: "Node RAM in MB.", }, - "chipset": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), - Default: "Q35", - Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", - }, + "chipset": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), + Default: "Q35", + Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", + }, "disk": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudapi/k8s/resource_k8s_wg.go b/internal/service/cloudapi/k8s/resource_k8s_wg.go index 0cde9f4b..e6d6c43d 100644 --- a/internal/service/cloudapi/k8s/resource_k8s_wg.go +++ b/internal/service/cloudapi/k8s/resource_k8s_wg.go @@ -290,13 +290,13 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema { Description: "Number of worker nodes to create.", }, - "chipset": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), - Default: "Q35", - Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", - }, + "chipset": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), + Default: "Q35", + Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", + }, "cpu": { Type: schema.TypeInt, diff --git a/internal/service/cloudapi/kvmvm/data_source_compute.go b/internal/service/cloudapi/kvmvm/data_source_compute.go index d428a219..327aeb36 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute.go @@ -260,6 +260,14 @@ func computeListDisksSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -319,6 +327,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -457,10 +469,6 @@ func computeListDisksSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - }, "to_clean": { Type: schema.TypeBool, Computed: true, @@ -1169,6 +1177,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, "loader_meta_iso": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/kvmvm/data_source_compute_list.go b/internal/service/cloudapi/kvmvm/data_source_compute_list.go index 83d22b04..3e47a901 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute_list.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute_list.go @@ -445,6 +445,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, } } diff --git a/internal/service/cloudapi/kvmvm/flattens.go b/internal/service/cloudapi/kvmvm/flattens.go index 939ea453..c0c4615e 100644 --- a/internal/service/cloudapi/kvmvm/flattens.go +++ b/internal/service/cloudapi/kvmvm/flattens.go @@ -252,6 +252,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} "hot_resize": compute.HotResize, "network_interface_naming": compute.NetworkInterfaceNaming, "zone_id": compute.ZoneID, + "weight": compute.Weight, } res = append(res, temp) } @@ -265,7 +266,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{} temp := map[string]interface{}{ "disk_name": bootDisk.Name, "disk_id": bootDisk.ID, - "disk_type": bootDisk.Type, "sep_id": bootDisk.SepID, "shareable": bootDisk.Shareable, "size_max": bootDisk.SizeMax, @@ -279,6 +279,16 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{} "to_clean": bootDisk.ToClean, "cache": bootDisk.Cache, "blk_discard": bootDisk.BLKDiscard, + "block_size": bootDisk.BlockSize, + "bus_number": bootDisk.BusNumber, + "provision": bootDisk.Provision, + "pci_slot": bootDisk.PCISlot, + "created_time": bootDisk.CreatedTime, + "created_by": bootDisk.CreatedBy, + "deleted_by": bootDisk.DeletedBy, + "deleted_time": bootDisk.DeletedTime, + "updated_time": bootDisk.UpdatedTime, + "devicename": bootDisk.DeviceName, } res = append(res, temp) @@ -315,7 +325,9 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex "devicename": disk.DeviceName, "disk_name": disk.Name, "disk_id": disk.ID, - "disk_type": disk.Type, + "independent": disk.Independent, + "pci_slot": disk.PCISlot, + "bus_number": disk.BusNumber, "sep_id": disk.SepID, "shareable": disk.Shareable, "size_max": disk.SizeMax, @@ -335,6 +347,8 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex "permanently": pernamentlyValue, "cache": disk.Cache, "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, + "provision": disk.Provision, "iotune": flattenIotune(disk.IOTune), } res = append(res, temp) @@ -375,10 +389,23 @@ func flattenNetworkWeight(networks []interface{}, netID uint64, netType string) return 0 } -func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk { +func isBootDisk(diskConv map[string]interface{}, chipset string) bool { + if chipset == "i440fx" { + return diskConv["pci_slot"].(int) == 6 + } + return diskConv["bus_number"].(int) == 6 +} + +func findBootDisk(disks compute.ListComputeDisks, chipset string) *compute.ItemComputeDisk { for _, disk := range disks { - if disk.Type == "B" { - return &disk + if chipset == "i440fx" { + if disk.PCISlot == 6 { + return &disk + } + } else { + if disk.BusNumber == 6 { + return &disk + } } } return &compute.ItemComputeDisk{} @@ -393,7 +420,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID) devices, _ := json.Marshal(computeRec.Devices) - bootDisk := findBootDisk(computeRec.Disks) + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) //check extraDisks, ipa_type, is, d.SetId(strconv.FormatUint(computeRec.ID, 10)) @@ -480,6 +507,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc d.Set("cpu_pin", computeRec.CPUPin) d.Set("numa_affinity", computeRec.NumaAffinity) d.Set("hp_backed", computeRec.HPBacked) + d.Set("weight", computeRec.Weight) d.Set("enabled", false) if computeRec.Status == status.Enabled { @@ -586,6 +614,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf "acl": string(acl), "account_id": disk.AccountID, "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, "boot_partition": disk.BootPartition, "bus_number": disk.BusNumber, "created_time": disk.CreatedTime, @@ -603,6 +632,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf "image_id": disk.ImageID, "images": disk.Images, "iotune": flattenIotune(disk.IOTune), + "independent": disk.Independent, "iqn": disk.IQN, "login": disk.Login, "milestones": disk.Milestones, @@ -627,8 +657,8 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf "status": disk.Status, "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, - "type": disk.Type, "to_clean": disk.ToClean, + "provision": disk.Provision, "updated_time": disk.UpdatedTime, } res = append(res, temp) @@ -755,6 +785,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute d.Set("zone_id", computeRec.ZoneID) d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso)) d.Set("os_version", computeRec.OSVersion) + d.Set("weight", computeRec.Weight) } func flattenPCI(pciList compute.ListPCIDevices) []uint64 { diff --git a/internal/service/cloudapi/kvmvm/network_subresource.go b/internal/service/cloudapi/kvmvm/network_subresource.go index 38ec9a0e..75d6d900 100644 --- a/internal/service/cloudapi/kvmvm/network_subresource.go +++ b/internal/service/cloudapi/kvmvm/network_subresource.go @@ -166,8 +166,8 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, //Default: 1500, - ValidateFunc: validation.IntBetween(1, 9216), - Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216", + ValidateFunc: validation.IntBetween(1500, 9216), + Description: "Maximum transmission unit, used only for DPDK type, must be 1500-9216", }, "sdn_interface_id": { diff --git a/internal/service/cloudapi/kvmvm/resource_check_input_values.go b/internal/service/cloudapi/kvmvm/resource_check_input_values.go index bf5e087d..a14aea2e 100644 --- a/internal/service/cloudapi/kvmvm/resource_check_input_values.go +++ b/internal/service/cloudapi/kvmvm/resource_check_input_values.go @@ -182,19 +182,3 @@ func existTRUNKId(ctx context.Context, m interface{}, id int) (int, bool) { return id, false } - -func isMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) bool { - count := 0 - - for _, elem := range disks.([]interface{}) { - diskVal := elem.(map[string]interface{}) - if diskVal["disk_type"].(string) == "B" { - count++ - } - if count > 1 { - return true - } - } - - return false -} diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index ad432c4d..3e139012 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -71,25 +71,21 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int)) } - hasImage, err := existImageId(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } + if !d.Get("create_blank").(bool) { + hasImage, err := existImageId(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } - if !hasImage { - return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int)) + if !hasImage { + return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int)) + } } if zoneID, ok := d.GetOk("zone_id"); ok { createReqX86.ZoneID = uint64(zoneID.(int)) } - if disks, ok := d.GetOk("disks"); ok { - if isMoreThanOneDisksTypeB(ctx, disks) { - return diag.Errorf("resourceComputeCreate: can't create Compute because block disks have more 1 disk type 'B'") - } - } - if network, ok := d.GetOk("network"); ok { networkList := network.(*schema.Set).List() for _, elem := range networkList { @@ -116,8 +112,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok { return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId) } - //TODO - //SDN check default: continue } @@ -137,18 +131,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf createReqX86.Pool = pool.(string) } - if ipaType, ok := d.GetOk("ipa_type"); ok { - createReqX86.IPAType = ipaType.(string) - } - if bootSize, ok := d.GetOk("boot_disk_size"); ok { createReqX86.BootDisk = uint64(bootSize.(int)) } - if IS, ok := d.GetOk("is"); ok { - createReqX86.IS = IS.(string) - } - createReqX86.Interfaces = make([]kvmx86.Interface, 0) if networks, ok := d.GetOk("network"); ok { @@ -178,7 +164,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf reqInterface.Enabled = netInterfaceVal["enabled"].(bool) } - if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" { + if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" { reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int)) } @@ -294,7 +280,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") - apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86) + var apiResp uint64 + if d.Get("create_blank").(bool) { + log.Debugf("resourceComputeCreate: using createBlank endpoint") + createBlankReq := kvmx86.CreateBlankRequest{ + RGID: createReqX86.RGID, + Name: createReqX86.Name, + CPU: createReqX86.CPU, + RAM: createReqX86.RAM, + StoragePolicyID: createReqX86.StoragePolicyID, + WithoutBootDisk: createReqX86.WithoutBootDisk, + BootDisk: createReqX86.BootDisk, + SEPID: createReqX86.SepID, + Pool: createReqX86.Pool, + DataDisks: createReqX86.DataDisks, + Interfaces: createReqX86.Interfaces, + Description: createReqX86.Description, + Chipset: createReqX86.Chipset, + PreferredCPU: createReqX86.PreferredCPU, + ZoneID: createReqX86.ZoneID, + OSVersion: createReqX86.OSVersion, + } + apiResp, err = c.CloudAPI().KVMX86().CreateBlank(ctx, createBlankReq) + } else { + apiResp, err = c.CloudAPI().KVMX86().Create(ctx, createReqX86) + } if err != nil { return diag.FromErr(err) } @@ -430,7 +440,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } if mac == "" { - warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + warnings.Add(fmt.Errorf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)) continue } secGroupsIDs := make([]uint64, 0) @@ -458,6 +468,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf if start, ok := d.GetOk("started"); ok { if start.(bool) { req := compute.StartRequest{ComputeID: computeId} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId) if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { warnings.Add(err) @@ -673,6 +686,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } + log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string)) // We may reuse dataSourceComputeRead here as we maintain similarity @@ -769,13 +783,15 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int)) } - hasImage, err := existImageId(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } + if !d.Get("create_blank").(bool) { + hasImage, err := existImageId(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } - if !hasImage { - return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int)) + if !hasImage { + return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int)) + } } if d.HasChange("zone_id") { @@ -784,12 +800,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } - if disks, ok := d.GetOk("disks"); ok { - if isMoreThanOneDisksTypeB(ctx, disks) { - return diag.Errorf("resourceComputeUpdate: can't update Compute because block disks have more 1 disk type 'B'") - } - } - if network, ok := d.GetOk("network"); ok { networkList := network.(*schema.Set).List() for _, elem := range networkList { @@ -816,8 +826,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok { return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId) } - //TODO - //SDNCheck default: continue } @@ -864,6 +872,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if start.(bool) { req := compute.StartRequest{ComputeID: computeRec.ID} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } + if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { return diag.FromErr(err) } @@ -1105,7 +1117,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf // If used to be STARTED, we need to start it after update if isStopRequired { - if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil { + + req := compute.StartRequest{ComputeID: computeRec.ID} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } + if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { return diag.FromErr(err) } } @@ -1176,10 +1193,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } + chipset := d.Get("chipset").(string) + if len(deletedDisks) > 0 { for _, disk := range deletedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } @@ -1201,7 +1220,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if len(addedDisks) > 0 { for _, disk := range addedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } req := compute.DiskAddRequest{ @@ -1214,9 +1233,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if diskConv["sep_id"].(int) != 0 { req.SepID = uint64(diskConv["sep_id"].(int)) } - if diskConv["disk_type"].(string) != "" { - req.DiskType = diskConv["disk_type"].(string) - } if diskConv["pool"].(string) != "" { req.Pool = diskConv["pool"].(string) } @@ -1230,6 +1246,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if err != nil { return diag.FromErr(err) } + if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 { iotuneMap := iotuneRaw[0].(map[string]interface{}) limitReq := disks.LimitIORequest{ @@ -1259,7 +1276,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if len(resizedDisks) > 0 { for _, disk := range resizedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } req := compute.DiskResizeRequest{ @@ -1310,7 +1327,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if len(iotuneUpdatedDisks) > 0 { for _, disk := range iotuneUpdatedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } diskID := uint64(diskConv["disk_id"].(int)) @@ -1847,6 +1864,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf req := compute.StartRequest{ ComputeID: computeRec.ID, } + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } if !isStopRequired { if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { return diag.FromErr(err) @@ -2042,12 +2062,15 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Storage endpoint provider ID; by default the same with boot disk", }, - "disk_type": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false), - Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'", + "pci_slot": { + Type: schema.TypeInt, + Computed: true, + Description: "PCI slot number of the disk", + }, + "bus_number": { + Type: schema.TypeInt, + Computed: true, + Description: "Bus number of the disk on virtual bus (6 = boot disk)", }, "pool": { Type: schema.TypeString, @@ -2152,6 +2175,10 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Disk ID", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "shareable": { Type: schema.TypeBool, Computed: true, @@ -2207,6 +2234,14 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, } return rets } @@ -2353,6 +2388,12 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Default: false, Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.", }, + "create_blank": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.", + }, "boot_disk_size": { Type: schema.TypeInt, Optional: true, @@ -2607,6 +2648,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Default: false, Description: "Flag for resize compute", }, + "alt_boot_id": { + Type: schema.TypeInt, + Optional: true, + Description: "ID of CD-ROM live image to boot", + }, "started": { Type: schema.TypeBool, Optional: true, @@ -2623,16 +2669,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Optional: true, Default: true, }, - "is": { - Type: schema.TypeString, - Optional: true, - Description: "system name", - }, - "ipa_type": { - Type: schema.TypeString, - Optional: true, - Description: "compute purpose", - }, "network_interface_naming": { Type: schema.TypeString, Optional: true, @@ -2687,7 +2723,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Required: true, StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating + ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "DPDK"}, false), // observe case while validating Description: "Type of the network", }, "net_id": { @@ -2733,6 +2769,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + Description: "Priority weight of the compute. Higher value means higher priority and later migration.", + }, "arch": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/kvmvm/utility_compute.go b/internal/service/cloudapi/kvmvm/utility_compute.go index 6440f28d..fd44dd56 100644 --- a/internal/service/cloudapi/kvmvm/utility_compute.go +++ b/internal/service/cloudapi/kvmvm/utility_compute.go @@ -299,7 +299,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData if needStart { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) - if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil { + var altBootID uint64 + if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok { + altBootID = uint64(altBootIDRaw) + } else { + altBootID = 0 + } + if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil { apiErrCount += numErr lastSavedError = err } @@ -462,10 +468,14 @@ func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) er return nil } -func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) { +func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) { c := m.(*controller.ControllerCfg) startReq := compute.StartRequest{ComputeID: computeID} + if altBootID > 0 { + startReq.AltBootID = altBootID + } + log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID) _, err := c.CloudAPI().Compute().Start(ctx, startReq) if err != nil { @@ -674,7 +684,7 @@ func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m i if err != nil { return err } - bootDisk := findBootDisk(computeRec.Disks) + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) computeDisksIDs := getComputeDiskIDsAPI(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID) for i, diskID := range computeDisksIDs { diff --git a/internal/service/cloudapi/lb/flattens.go b/internal/service/cloudapi/lb/flattens.go index db182770..fc064dd5 100644 --- a/internal/service/cloudapi/lb/flattens.go +++ b/internal/service/cloudapi/lb/flattens.go @@ -1,300 +1,300 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 lb - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb" -) - -func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) { - d.Set("lb_id", lbId) - d.Set("frontend_name", frontendName) - d.Set("name", b.Name) - d.Set("address", b.Address) - d.Set("guid", b.GUID) - d.Set("port", b.Port) -} - -func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) { - d.Set("lb_id", lbId) - d.Set("backend_name", f.Backend) - d.Set("name", f.Name) - d.Set("guid", f.GUID) - d.Set("bindings", flattendBindings(f.Bindings)) -} - -func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) { - d.Set("lb_id", lbId) - d.Set("backend_name", backendName) - d.Set("name", s.Name) - d.Set("port", s.Port) - d.Set("address", s.Address) - d.Set("check", s.Check) - d.Set("guid", s.GUID) - d.Set("downinter", s.ServerSettings.DownInter) - d.Set("fall", s.ServerSettings.Fall) - d.Set("inter", s.ServerSettings.Inter) - d.Set("maxconn", s.ServerSettings.MaxConn) - d.Set("maxqueue", s.ServerSettings.MaxQueue) - d.Set("rise", s.ServerSettings.Rise) - d.Set("slowstart", s.ServerSettings.SlowStart) - d.Set("weight", s.ServerSettings.Weight) - -} - -func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) { - d.Set("lb_id", lbId) - d.Set("name", b.Name) - d.Set("algorithm", b.Algorithm) - d.Set("guid", b.GUID) - d.Set("downinter", b.ServerDefaultSettings.DownInter) - d.Set("fall", b.ServerDefaultSettings.Fall) - d.Set("inter", b.ServerDefaultSettings.Inter) - d.Set("maxconn", b.ServerDefaultSettings.MaxConn) - d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue) - d.Set("rise", b.ServerDefaultSettings.Rise) - d.Set("slowstart", b.ServerDefaultSettings.SlowStart) - d.Set("weight", b.ServerDefaultSettings.Weight) - d.Set("servers", flattenServers(b.Servers)) -} - -func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) { - d.Set("ha_mode", lb.HAMode) - d.Set("backend_haip", lb.BackendHAIP) - d.Set("backends", flattenLBBackends(lb.Backends)) - d.Set("created_by", lb.CreatedBy) - d.Set("created_time", lb.CreatedTime) - d.Set("deleted_by", lb.DeletedBy) - d.Set("deleted_time", lb.DeletedTime) - d.Set("desc", lb.Description) - d.Set("dp_api_user", lb.DPAPIUser) - d.Set("extnet_id", lb.ExtNetID) - d.Set("frontend_haip", lb.FrontendHAIP) - d.Set("frontends", flattenFrontends(lb.Frontends)) - d.Set("gid", lb.GID) - d.Set("guid", lb.GUID) - d.Set("manager_id", lb.ManagerId) - d.Set("manager_type", lb.ManagerType) - d.Set("lb_id", lb.ID) - d.Set("image_id", lb.ImageID) - d.Set("milestones", lb.Milestones) - d.Set("name", lb.Name) - d.Set("part_k8s", lb.PartK8s) - d.Set("primary_node", flattenNode(lb.PrimaryNode)) - d.Set("rg_id", lb.RGID) - d.Set("rg_name", lb.RGName) - d.Set("secondary_node", flattenNode(lb.SecondaryNode)) - d.Set("status", lb.Status) - d.Set("tech_status", lb.TechStatus) - d.Set("updated_by", lb.UpdatedBy) - d.Set("updated_time", lb.UpdatedTime) - d.Set("user_managed", lb.UserManaged) - d.Set("vins_id", lb.VINSID) - d.Set("zone_id", lb.ZoneID) - -} - -func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) { - d.Set("account_id", lb.AccountID) - d.Set("ha_mode", lb.HAMode) - d.Set("backend_haip", lb.BackendHAIP) - d.Set("backends", flattenLBBackends(lb.Backends)) - d.Set("created_by", lb.CreatedBy) - d.Set("created_time", lb.CreatedTime) - d.Set("deleted_by", lb.DeletedBy) - d.Set("deleted_time", lb.DeletedTime) - d.Set("desc", lb.Description) - d.Set("dp_api_user", lb.DPAPIUser) - d.Set("extnet_id", lb.ExtNetID) - d.Set("frontend_haip", lb.FrontendHAIP) - d.Set("frontends", flattenFrontends(lb.Frontends)) - d.Set("gid", lb.GID) - d.Set("guid", lb.GUID) - d.Set("manager_id", lb.ManagerId) - d.Set("manager_type", lb.ManagerType) - d.Set("image_id", lb.ImageID) - d.Set("milestones", lb.Milestones) - d.Set("name", lb.Name) - d.Set("part_k8s", lb.PartK8s) - d.Set("primary_node", flattenNode(lb.PrimaryNode)) - d.Set("rg_id", lb.RGID) - d.Set("rg_name", lb.RGName) - d.Set("secondary_node", flattenNode(lb.SecondaryNode)) - d.Set("status", lb.Status) - d.Set("tech_status", lb.TechStatus) - d.Set("updated_by", lb.UpdatedBy) - d.Set("updated_time", lb.UpdatedTime) - d.Set("user_managed", lb.UserManaged) - d.Set("vins_id", lb.VINSID) - d.Set("zone_id", lb.ZoneID) -} - -func flattenNode(node lb.RecordNode) []map[string]interface{} { - temp := make([]map[string]interface{}, 0) - n := map[string]interface{}{ - "backend_ip": node.BackendIP, - "compute_id": node.ComputeID, - "frontend_ip": node.FrontendIP, - "guid": node.GUID, - "mgmt_ip": node.MGMTIP, - "network_id": node.NetworkID, - } - - temp = append(temp, n) - - return temp -} - -func flattendBindings(bs []lb.ItemBinding) []map[string]interface{} { - temp := make([]map[string]interface{}, 0, len(bs)) - for _, b := range bs { - t := map[string]interface{}{ - "address": b.Address, - "guid": b.GUID, - "name": b.Name, - "port": b.Port, - } - temp = append(temp, t) - } - return temp -} - -func flattenFrontends(fs []lb.ItemFrontend) []map[string]interface{} { - temp := make([]map[string]interface{}, 0, len(fs)) - for _, f := range fs { - t := map[string]interface{}{ - "backend": f.Backend, - "bindings": flattendBindings(f.Bindings), - "guid": f.GUID, - "name": f.Name, - } - temp = append(temp, t) - } - - return temp -} - -func flattenServers(servers []lb.ItemServer) []map[string]interface{} { - temp := make([]map[string]interface{}, 0, len(servers)) - for _, server := range servers { - t := map[string]interface{}{ - "address": server.Address, - "check": server.Check, - "guid": server.GUID, - "name": server.Name, - "port": server.Port, - "server_settings": flattenServerSettings(server.ServerSettings), - } - - temp = append(temp, t) - } - return temp -} - -func flattenServerSettings(defSet lb.RecordServerSettings) []map[string]interface{} { - temp := map[string]interface{}{ - "downinter": defSet.DownInter, - "fall": defSet.Fall, - "guid": defSet.GUID, - "inter": defSet.Inter, - "maxconn": defSet.MaxConn, - "maxqueue": defSet.MaxQueue, - "rise": defSet.Rise, - "slowstart": defSet.SlowStart, - "weight": defSet.Weight, - } - - res := make([]map[string]interface{}, 0) - res = append(res, temp) - return res -} - -func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} { - temp := make([]map[string]interface{}, 0, len(backends)) - for _, item := range backends { - t := map[string]interface{}{ - "algorithm": item.Algorithm, - "guid": item.GUID, - "name": item.Name, - "server_default_settings": flattenServerSettings(item.ServerDefaultSettings), - "servers": flattenServers(item.Servers), - } - - temp = append(temp, t) - } - return temp -} - -func flattenLBList(lbl *lb.ListLB) []map[string]interface{} { - res := make([]map[string]interface{}, 0, len(lbl.Data)) - for _, lb := range lbl.Data { - temp := map[string]interface{}{ - "ha_mode": lb.HAMode, - "backend_haip": lb.BackendHAIP, - "backends": flattenLBBackends(lb.Backends), - "created_by": lb.CreatedBy, - "created_time": lb.CreatedTime, - "deleted_by": lb.DeletedBy, - "deleted_time": lb.DeletedTime, - "desc": lb.Description, - "dp_api_user": lb.DPAPIUser, - "dp_api_password": lb.DPAPIPassword, - "extnet_id": lb.ExtNetID, - "frontend_haip": lb.FrontendHAIP, - "frontends": flattenFrontends(lb.Frontends), - "gid": lb.GID, - "guid": lb.GUID, - "manager_id": lb.ManagerId, - "manager_type": lb.ManagerType, - "image_id": lb.ImageID, - "milestones": lb.Milestones, - "name": lb.Name, - "part_k8s": lb.PartK8s, - "primary_node": flattenNode(lb.PrimaryNode), - "rg_id": lb.RGID, - "rg_name": lb.RGName, - "secondary_node": flattenNode(lb.SecondaryNode), - "status": lb.Status, - "tech_status": lb.TechStatus, - "updated_by": lb.UpdatedBy, - "updated_time": lb.UpdatedTime, - "user_managed": lb.UserManaged, - "vins_id": lb.VINSID, - "lb_id": lb.ID, - "zone_id": lb.ZoneID, - } - res = append(res, temp) - } - return res -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 lb + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb" +) + +func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) { + d.Set("lb_id", lbId) + d.Set("frontend_name", frontendName) + d.Set("name", b.Name) + d.Set("address", b.Address) + d.Set("guid", b.GUID) + d.Set("port", b.Port) +} + +func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) { + d.Set("lb_id", lbId) + d.Set("backend_name", f.Backend) + d.Set("name", f.Name) + d.Set("guid", f.GUID) + d.Set("bindings", flattendBindings(f.Bindings)) +} + +func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) { + d.Set("lb_id", lbId) + d.Set("backend_name", backendName) + d.Set("name", s.Name) + d.Set("port", s.Port) + d.Set("address", s.Address) + d.Set("check", s.Check) + d.Set("guid", s.GUID) + d.Set("downinter", s.ServerSettings.DownInter) + d.Set("fall", s.ServerSettings.Fall) + d.Set("inter", s.ServerSettings.Inter) + d.Set("maxconn", s.ServerSettings.MaxConn) + d.Set("maxqueue", s.ServerSettings.MaxQueue) + d.Set("rise", s.ServerSettings.Rise) + d.Set("slowstart", s.ServerSettings.SlowStart) + d.Set("weight", s.ServerSettings.Weight) + +} + +func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) { + d.Set("lb_id", lbId) + d.Set("name", b.Name) + d.Set("algorithm", b.Algorithm) + d.Set("guid", b.GUID) + d.Set("downinter", b.ServerDefaultSettings.DownInter) + d.Set("fall", b.ServerDefaultSettings.Fall) + d.Set("inter", b.ServerDefaultSettings.Inter) + d.Set("maxconn", b.ServerDefaultSettings.MaxConn) + d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue) + d.Set("rise", b.ServerDefaultSettings.Rise) + d.Set("slowstart", b.ServerDefaultSettings.SlowStart) + d.Set("weight", b.ServerDefaultSettings.Weight) + d.Set("servers", flattenServers(b.Servers)) +} + +func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) { + d.Set("ha_mode", lb.HAMode) + d.Set("backend_haip", lb.BackendHAIP) + d.Set("backends", flattenLBBackends(lb.Backends)) + d.Set("created_by", lb.CreatedBy) + d.Set("created_time", lb.CreatedTime) + d.Set("deleted_by", lb.DeletedBy) + d.Set("deleted_time", lb.DeletedTime) + d.Set("desc", lb.Description) + d.Set("dp_api_user", lb.DPAPIUser) + d.Set("extnet_id", lb.ExtNetID) + d.Set("frontend_haip", lb.FrontendHAIP) + d.Set("frontends", flattenFrontends(lb.Frontends)) + d.Set("gid", lb.GID) + d.Set("guid", lb.GUID) + d.Set("manager_id", lb.ManagerId) + d.Set("manager_type", lb.ManagerType) + d.Set("lb_id", lb.ID) + d.Set("image_id", lb.ImageID) + d.Set("milestones", lb.Milestones) + d.Set("name", lb.Name) + d.Set("part_k8s", lb.PartK8s) + d.Set("primary_node", flattenNode(lb.PrimaryNode)) + d.Set("rg_id", lb.RGID) + d.Set("rg_name", lb.RGName) + d.Set("secondary_node", flattenNode(lb.SecondaryNode)) + d.Set("status", lb.Status) + d.Set("tech_status", lb.TechStatus) + d.Set("updated_by", lb.UpdatedBy) + d.Set("updated_time", lb.UpdatedTime) + d.Set("user_managed", lb.UserManaged) + d.Set("vins_id", lb.VINSID) + d.Set("zone_id", lb.ZoneID) + +} + +func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) { + d.Set("account_id", lb.AccountID) + d.Set("ha_mode", lb.HAMode) + d.Set("backend_haip", lb.BackendHAIP) + d.Set("backends", flattenLBBackends(lb.Backends)) + d.Set("created_by", lb.CreatedBy) + d.Set("created_time", lb.CreatedTime) + d.Set("deleted_by", lb.DeletedBy) + d.Set("deleted_time", lb.DeletedTime) + d.Set("desc", lb.Description) + d.Set("dp_api_user", lb.DPAPIUser) + d.Set("extnet_id", lb.ExtNetID) + d.Set("frontend_haip", lb.FrontendHAIP) + d.Set("frontends", flattenFrontends(lb.Frontends)) + d.Set("gid", lb.GID) + d.Set("guid", lb.GUID) + d.Set("manager_id", lb.ManagerId) + d.Set("manager_type", lb.ManagerType) + d.Set("image_id", lb.ImageID) + d.Set("milestones", lb.Milestones) + d.Set("name", lb.Name) + d.Set("part_k8s", lb.PartK8s) + d.Set("primary_node", flattenNode(lb.PrimaryNode)) + d.Set("rg_id", lb.RGID) + d.Set("rg_name", lb.RGName) + d.Set("secondary_node", flattenNode(lb.SecondaryNode)) + d.Set("status", lb.Status) + d.Set("tech_status", lb.TechStatus) + d.Set("updated_by", lb.UpdatedBy) + d.Set("updated_time", lb.UpdatedTime) + d.Set("user_managed", lb.UserManaged) + d.Set("vins_id", lb.VINSID) + d.Set("zone_id", lb.ZoneID) +} + +func flattenNode(node lb.RecordNode) []map[string]interface{} { + temp := make([]map[string]interface{}, 0) + n := map[string]interface{}{ + "backend_ip": node.BackendIP, + "compute_id": node.ComputeID, + "frontend_ip": node.FrontendIP, + "guid": node.GUID, + "mgmt_ip": node.MGMTIP, + "network_id": node.NetworkID, + } + + temp = append(temp, n) + + return temp +} + +func flattendBindings(bs []lb.ItemBinding) []map[string]interface{} { + temp := make([]map[string]interface{}, 0, len(bs)) + for _, b := range bs { + t := map[string]interface{}{ + "address": b.Address, + "guid": b.GUID, + "name": b.Name, + "port": b.Port, + } + temp = append(temp, t) + } + return temp +} + +func flattenFrontends(fs []lb.ItemFrontend) []map[string]interface{} { + temp := make([]map[string]interface{}, 0, len(fs)) + for _, f := range fs { + t := map[string]interface{}{ + "backend": f.Backend, + "bindings": flattendBindings(f.Bindings), + "guid": f.GUID, + "name": f.Name, + } + temp = append(temp, t) + } + + return temp +} + +func flattenServers(servers []lb.ItemServer) []map[string]interface{} { + temp := make([]map[string]interface{}, 0, len(servers)) + for _, server := range servers { + t := map[string]interface{}{ + "address": server.Address, + "check": server.Check, + "guid": server.GUID, + "name": server.Name, + "port": server.Port, + "server_settings": flattenServerSettings(server.ServerSettings), + } + + temp = append(temp, t) + } + return temp +} + +func flattenServerSettings(defSet lb.RecordServerSettings) []map[string]interface{} { + temp := map[string]interface{}{ + "downinter": defSet.DownInter, + "fall": defSet.Fall, + "guid": defSet.GUID, + "inter": defSet.Inter, + "maxconn": defSet.MaxConn, + "maxqueue": defSet.MaxQueue, + "rise": defSet.Rise, + "slowstart": defSet.SlowStart, + "weight": defSet.Weight, + } + + res := make([]map[string]interface{}, 0) + res = append(res, temp) + return res +} + +func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} { + temp := make([]map[string]interface{}, 0, len(backends)) + for _, item := range backends { + t := map[string]interface{}{ + "algorithm": item.Algorithm, + "guid": item.GUID, + "name": item.Name, + "server_default_settings": flattenServerSettings(item.ServerDefaultSettings), + "servers": flattenServers(item.Servers), + } + + temp = append(temp, t) + } + return temp +} + +func flattenLBList(lbl *lb.ListLB) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(lbl.Data)) + for _, lb := range lbl.Data { + temp := map[string]interface{}{ + "ha_mode": lb.HAMode, + "backend_haip": lb.BackendHAIP, + "backends": flattenLBBackends(lb.Backends), + "created_by": lb.CreatedBy, + "created_time": lb.CreatedTime, + "deleted_by": lb.DeletedBy, + "deleted_time": lb.DeletedTime, + "desc": lb.Description, + "dp_api_user": lb.DPAPIUser, + "dp_api_password": lb.DPAPIPassword, + "extnet_id": lb.ExtNetID, + "frontend_haip": lb.FrontendHAIP, + "frontends": flattenFrontends(lb.Frontends), + "gid": lb.GID, + "guid": lb.GUID, + "manager_id": lb.ManagerId, + "manager_type": lb.ManagerType, + "image_id": lb.ImageID, + "milestones": lb.Milestones, + "name": lb.Name, + "part_k8s": lb.PartK8s, + "primary_node": flattenNode(lb.PrimaryNode), + "rg_id": lb.RGID, + "rg_name": lb.RGName, + "secondary_node": flattenNode(lb.SecondaryNode), + "status": lb.Status, + "tech_status": lb.TechStatus, + "updated_by": lb.UpdatedBy, + "updated_time": lb.UpdatedTime, + "user_managed": lb.UserManaged, + "vins_id": lb.VINSID, + "lb_id": lb.ID, + "zone_id": lb.ZoneID, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/cloudapi/lb/lb_resource_subresource.go b/internal/service/cloudapi/lb/lb_resource_subresource.go index 1d579cbf..ae3d42dc 100644 --- a/internal/service/cloudapi/lb/lb_resource_subresource.go +++ b/internal/service/cloudapi/lb/lb_resource_subresource.go @@ -1,119 +1,119 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 lb - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -func lbResourceSchemaMake() map[string]*schema.Schema { - sch := createLBSchema() - sch["rg_id"] = &schema.Schema{ - Type: schema.TypeInt, - Required: true, - } - sch["name"] = &schema.Schema{ - Type: schema.TypeString, - Required: true, - } - sch["zone_id"] = &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Computed: true, - } - sch["extnet_id"] = &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - } - - sch["vins_id"] = &schema.Schema{ - Type: schema.TypeInt, - Optional: true, - } - sch["start"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: true, - } - sch["desc"] = &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - } - - sch["enable"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - - sch["restart"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - - sch["restore"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - - sch["safe"] = &schema.Schema{ - Type: schema.TypeBool, - Default: true, - Optional: true, - } - - sch["config_reset"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - ///4.4.0 - sch["ha_mode"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - sch["sysctl_params"] = &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeMap, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - } - - /// - sch["permanently"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - return sch -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 lb + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func lbResourceSchemaMake() map[string]*schema.Schema { + sch := createLBSchema() + sch["rg_id"] = &schema.Schema{ + Type: schema.TypeInt, + Required: true, + } + sch["name"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + } + sch["zone_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + } + sch["extnet_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + } + + sch["vins_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + } + sch["start"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + } + sch["desc"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + } + + sch["enable"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + + sch["restart"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + + sch["restore"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + + sch["safe"] = &schema.Schema{ + Type: schema.TypeBool, + Default: true, + Optional: true, + } + + sch["config_reset"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + ///4.4.0 + sch["ha_mode"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + sch["sysctl_params"] = &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeMap, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + } + + /// + sch["permanently"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + return sch +} diff --git a/internal/service/cloudapi/lb/lb_schema.go b/internal/service/cloudapi/lb/lb_schema.go index 962202b7..841c5f72 100644 --- a/internal/service/cloudapi/lb/lb_schema.go +++ b/internal/service/cloudapi/lb/lb_schema.go @@ -1,396 +1,396 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 lb - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -func createLBSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "account_id": { - Type: schema.TypeInt, - Computed: true, - }, - "ha_mode": { - Type: schema.TypeBool, - Computed: true, - }, - "backend_haip": { - Type: schema.TypeString, - Computed: true, - }, - "backends": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "algorithm": { - Type: schema.TypeString, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "server_default_settings": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "downinter": { - Type: schema.TypeInt, - Computed: true, - }, - "fall": { - Type: schema.TypeInt, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "inter": { - Type: schema.TypeInt, - Computed: true, - }, - "maxconn": { - Type: schema.TypeInt, - Computed: true, - }, - "maxqueue": { - Type: schema.TypeInt, - Computed: true, - }, - "rise": { - Type: schema.TypeInt, - Computed: true, - }, - "slowstart": { - Type: schema.TypeInt, - Computed: true, - }, - "weight": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - "servers": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "address": { - Type: schema.TypeString, - Computed: true, - }, - "check": { - Type: schema.TypeString, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "port": { - Type: schema.TypeInt, - Computed: true, - }, - "server_settings": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "downinter": { - Type: schema.TypeInt, - Computed: true, - }, - "fall": { - Type: schema.TypeInt, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "inter": { - Type: schema.TypeInt, - Computed: true, - }, - "maxconn": { - Type: schema.TypeInt, - Computed: true, - }, - "maxqueue": { - Type: schema.TypeInt, - Computed: true, - }, - "rise": { - Type: schema.TypeInt, - Computed: true, - }, - "slowstart": { - Type: schema.TypeInt, - Computed: true, - }, - "weight": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - }, - "created_time": { - Type: schema.TypeInt, - Computed: true, - }, - "deleted_by": { - Type: schema.TypeString, - Computed: true, - }, - "deleted_time": { - Type: schema.TypeInt, - Computed: true, - }, - "desc": { - Type: schema.TypeString, - Computed: true, - }, - "dp_api_user": { - Type: schema.TypeString, - Computed: true, - }, - "extnet_id": { - Type: schema.TypeInt, - Computed: true, - }, - "frontend_haip": { - Type: schema.TypeString, - Computed: true, - }, - "frontends": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "backend": { - Type: schema.TypeString, - Computed: true, - }, - "bindings": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "address": { - Type: schema.TypeString, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "port": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "gid": { - Type: schema.TypeInt, - Computed: true, - }, - "guid": { - Type: schema.TypeInt, - Computed: true, - }, - "lb_id": { - Type: schema.TypeInt, - Computed: true, - }, - "manager_id": { - Type: schema.TypeInt, - Computed: true, - }, - "manager_type": { - Type: schema.TypeString, - Computed: true, - }, - "image_id": { - Type: schema.TypeInt, - Computed: true, - }, - "milestones": { - Type: schema.TypeInt, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "part_k8s": { - Type: schema.TypeBool, - Computed: true, - }, - "primary_node": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "backend_ip": { - Type: schema.TypeString, - Computed: true, - }, - "compute_id": { - Type: schema.TypeInt, - Computed: true, - }, - "frontend_ip": { - Type: schema.TypeString, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "mgmt_ip": { - Type: schema.TypeString, - Computed: true, - }, - "network_id": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - "rg_id": { - Type: schema.TypeInt, - Computed: true, - }, - "rg_name": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_node": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "backend_ip": { - Type: schema.TypeString, - Computed: true, - }, - "compute_id": { - Type: schema.TypeInt, - Computed: true, - }, - "frontend_ip": { - Type: schema.TypeString, - Computed: true, - }, - "guid": { - Type: schema.TypeString, - Computed: true, - }, - "mgmt_ip": { - Type: schema.TypeString, - Computed: true, - }, - "network_id": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - "tech_status": { - Type: schema.TypeString, - Computed: true, - }, - "updated_by": { - Type: schema.TypeString, - Computed: true, - }, - "updated_time": { - Type: schema.TypeInt, - Computed: true, - }, - "user_managed": { - Type: schema.TypeBool, - Computed: true, - }, - "vins_id": { - Type: schema.TypeInt, - Computed: true, - }, - } -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 lb + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func createLBSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "ha_mode": { + Type: schema.TypeBool, + Computed: true, + }, + "backend_haip": { + Type: schema.TypeString, + Computed: true, + }, + "backends": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "algorithm": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "server_default_settings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "downinter": { + Type: schema.TypeInt, + Computed: true, + }, + "fall": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "inter": { + Type: schema.TypeInt, + Computed: true, + }, + "maxconn": { + Type: schema.TypeInt, + Computed: true, + }, + "maxqueue": { + Type: schema.TypeInt, + Computed: true, + }, + "rise": { + Type: schema.TypeInt, + Computed: true, + }, + "slowstart": { + Type: schema.TypeInt, + Computed: true, + }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "servers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address": { + Type: schema.TypeString, + Computed: true, + }, + "check": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "port": { + Type: schema.TypeInt, + Computed: true, + }, + "server_settings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "downinter": { + Type: schema.TypeInt, + Computed: true, + }, + "fall": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "inter": { + Type: schema.TypeInt, + Computed: true, + }, + "maxconn": { + Type: schema.TypeInt, + Computed: true, + }, + "maxqueue": { + Type: schema.TypeInt, + Computed: true, + }, + "rise": { + Type: schema.TypeInt, + Computed: true, + }, + "slowstart": { + Type: schema.TypeInt, + Computed: true, + }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "created_time": { + Type: schema.TypeInt, + Computed: true, + }, + "deleted_by": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "dp_api_user": { + Type: schema.TypeString, + Computed: true, + }, + "extnet_id": { + Type: schema.TypeInt, + Computed: true, + }, + "frontend_haip": { + Type: schema.TypeString, + Computed: true, + }, + "frontends": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "backend": { + Type: schema.TypeString, + Computed: true, + }, + "bindings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "port": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "lb_id": { + Type: schema.TypeInt, + Computed: true, + }, + "manager_id": { + Type: schema.TypeInt, + Computed: true, + }, + "manager_type": { + Type: schema.TypeString, + Computed: true, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "part_k8s": { + Type: schema.TypeBool, + Computed: true, + }, + "primary_node": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "backend_ip": { + Type: schema.TypeString, + Computed: true, + }, + "compute_id": { + Type: schema.TypeInt, + Computed: true, + }, + "frontend_ip": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "mgmt_ip": { + Type: schema.TypeString, + Computed: true, + }, + "network_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "rg_id": { + Type: schema.TypeInt, + Computed: true, + }, + "rg_name": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_node": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "backend_ip": { + Type: schema.TypeString, + Computed: true, + }, + "compute_id": { + Type: schema.TypeInt, + Computed: true, + }, + "frontend_ip": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "mgmt_ip": { + Type: schema.TypeString, + Computed: true, + }, + "network_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_time": { + Type: schema.TypeInt, + Computed: true, + }, + "user_managed": { + Type: schema.TypeBool, + Computed: true, + }, + "vins_id": { + Type: schema.TypeInt, + Computed: true, + }, + } +} diff --git a/internal/service/cloudapi/locations/data_source_locations_list.go b/internal/service/cloudapi/locations/data_source_locations_list.go index acfd2814..30f0b711 100644 --- a/internal/service/cloudapi/locations/data_source_locations_list.go +++ b/internal/service/cloudapi/locations/data_source_locations_list.go @@ -47,17 +47,19 @@ func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} res := make([]map[string]interface{}, 0, len(ll.Data)) for _, l := range ll.Data { temp := map[string]interface{}{ - "ckey": l.CKey, - "meta": flattens.FlattenMeta(l.Meta), - "auth_broker": l.AuthBroker, - "flag": l.Flag, - "gid": l.GID, - "guid": l.GUID, - "id": l.ID, - "location_code": l.LocationCode, - "name": l.Name, - "network_modes": l.NetworkModes, - "sdn_support": l.SDNSupport, + "ckey": l.CKey, + "meta": flattens.FlattenMeta(l.Meta), + "auth_broker": l.AuthBroker, + "flag": l.Flag, + "gid": l.GID, + "guid": l.GUID, + "id": l.ID, + "location_code": l.LocationCode, + "name": l.Name, + "network_modes": l.NetworkModes, + "sdn_support": l.SDNSupport, + "zero_access_enabled": l.ZeroAccessEnabled, + "bro_enabled": l.BROEnabled, } res = append(res, temp) } @@ -183,6 +185,14 @@ func dataSourceLocationsListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "support of SDN", }, + "zero_access_enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "bro_enabled": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudapi/locations/models.go b/internal/service/cloudapi/locations/models.go index 543613cc..7c4d76ad 100644 --- a/internal/service/cloudapi/locations/models.go +++ b/internal/service/cloudapi/locations/models.go @@ -1,36 +1,36 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 locations - -type Location struct { - GridID int `json:"gid"` - Id int `json:"id"` - Guid int `json:"guid"` - LocationCode string `json:"locationCode"` - Name string `json:"name"` - NetworkModes []string `json:"network_modes"` - SDNSupport bool `json:"sdn_support"` - Flag string `json:"flag"` - Meta []interface{} `json:"_meta"` - CKey string `json:"_ckey"` -} - -type LocationsList []Location +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 locations + +type Location struct { + GridID int `json:"gid"` + Id int `json:"id"` + Guid int `json:"guid"` + LocationCode string `json:"locationCode"` + Name string `json:"name"` + NetworkModes []string `json:"network_modes"` + SDNSupport bool `json:"sdn_support"` + Flag string `json:"flag"` + Meta []interface{} `json:"_meta"` + CKey string `json:"_ckey"` +} + +type LocationsList []Location diff --git a/internal/service/cloudapi/rg/data_source_rg.go b/internal/service/cloudapi/rg/data_source_rg.go index 09f928a2..56f132fc 100644 --- a/internal/service/cloudapi/rg/data_source_rg.go +++ b/internal/service/cloudapi/rg/data_source_rg.go @@ -202,6 +202,10 @@ func DataSourceResgroup() *schema.Resource { func aclSchemaMake() map[string]*schema.Schema { res := map[string]*schema.Schema{ + "email": { + Type: schema.TypeString, + Computed: true, + }, "explicit": { Type: schema.TypeBool, Computed: true, diff --git a/internal/service/cloudapi/rg/flattens.go b/internal/service/cloudapi/rg/flattens.go index 363f556b..c07cf6db 100644 --- a/internal/service/cloudapi/rg/flattens.go +++ b/internal/service/cloudapi/rg/flattens.go @@ -269,6 +269,7 @@ func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(rgAcls)) for _, rgAcl := range rgAcls { temp := map[string]interface{}{ + "email": rgAcl.Email, "explicit": rgAcl.Explicit, "guid": rgAcl.GUID, "right": rgAcl.Right, diff --git a/internal/service/cloudapi/rg/resource_rg.go b/internal/service/cloudapi/rg/resource_rg.go index f9bfc203..2d3f1cfb 100644 --- a/internal/service/cloudapi/rg/resource_rg.go +++ b/internal/service/cloudapi/rg/resource_rg.go @@ -130,6 +130,9 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter } if _, ok := d.GetOk("def_net"); !ok { if defNetType, ok := d.GetOk("def_net_type"); ok { + if defNetType.(string) == "PRIVATE" { + return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use def_net_type=\"PRIVATE\" only when updating an existing RG that already contains a ViNS") + } req.DefNet = defNetType.(string) // NOTE: in API default network type is set by "def_net" parameter } } else { @@ -220,6 +223,10 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter netType := defNetItem["net_type"].(string) + if netType == "PRIVATE" { + return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use net_type=\"PRIVATE\" in def_net block only when updating an existing RG that already contains a ViNS") + } + req := rg.SetDefNetRequest{ RGID: apiResp, NetType: netType, @@ -504,14 +511,31 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter for _, changedDefNetInterface := range changedDefNet { defNetItem := changedDefNetInterface.(map[string]interface{}) netType := defNetItem["net_type"].(string) + netID := uint64(defNetItem["net_id"].(int)) + + if netType == "PRIVATE" { + if netID == 0 { + if len(rgData.VINS) == 0 { + return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: no ViNSes exist in this RG.", rgData.ID) + } + } else { + found := false + for _, vinsID := range rgData.VINS { + if vinsID == netID { + found = true + break + } + } + if !found { + return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: ViNS ID %d is not found in this RG.", rgData.ID, netID) + } + } + } req := rg.SetDefNetRequest{ RGID: rgData.ID, NetType: netType, - } - - if netID, ok := defNetItem["net_id"]; ok { - req.NetID = uint64(netID.(int)) + NetID: netID, } _, err := c.CloudAPI().RG().SetDefNet(ctx, req) diff --git a/internal/service/cloudapi/stpolicy/flattens.go b/internal/service/cloudapi/stpolicy/flattens.go index 51b7e9ad..6d5cda74 100644 --- a/internal/service/cloudapi/stpolicy/flattens.go +++ b/internal/service/cloudapi/stpolicy/flattens.go @@ -6,7 +6,6 @@ import ( ) func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { - d.Set("storage_policy_id", storagePolicy.ID) d.Set("description", storagePolicy.Description) d.Set("guid", storagePolicy.GUID) d.Set("limit_iops", storagePolicy.LimitIOPS) diff --git a/internal/service/cloudapi/stpolicy/schema.go b/internal/service/cloudapi/stpolicy/schema.go index bf153999..db938f7c 100644 --- a/internal/service/cloudapi/stpolicy/schema.go +++ b/internal/service/cloudapi/stpolicy/schema.go @@ -51,6 +51,10 @@ func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "sep_tech_status": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudapi/vins/flattens.go b/internal/service/cloudapi/vins/flattens.go index ac82940e..e9d675a5 100644 --- a/internal/service/cloudapi/vins/flattens.go +++ b/internal/service/cloudapi/vins/flattens.go @@ -399,6 +399,7 @@ func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) { d.Set("deleted_by", vins.DeletedBy) d.Set("deleted_time", vins.DeletedTime) d.Set("desc", vins.Description) + d.Set("enable_secgroups", vins.EnableSecGroups) d.Set("gid", vins.GID) d.Set("guid", vins.GUID) d.Set("lock_status", vins.LockStatus) diff --git a/internal/service/cloudapi/vins/resource_vins.go b/internal/service/cloudapi/vins/resource_vins.go index 0efcf1c7..f8cc2fc8 100644 --- a/internal/service/cloudapi/vins/resource_vins.go +++ b/internal/service/cloudapi/vins/resource_vins.go @@ -144,6 +144,8 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface req.ZoneID = uint64(zoneID.(int)) } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + id, err := c.CloudAPI().VINS().CreateInRG(ctx, req) if err != nil { d.SetId("") @@ -181,6 +183,8 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface req.ZoneID = uint64(zoneID.(int)) } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req) if err != nil { d.SetId("") @@ -908,6 +912,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "ID of the Zone to put ViNS into", } + rets["enable_secgroups"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "enable security groups", + } return rets } diff --git a/internal/service/cloudapi/zone/data_source_zone.go b/internal/service/cloudapi/zone/data_source_zone.go index cf5ac633..978784fb 100644 --- a/internal/service/cloudapi/zone/data_source_zone.go +++ b/internal/service/cloudapi/zone/data_source_zone.go @@ -129,7 +129,7 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, - "lb_ids": { + "lbs_ids": { Type: schema.TypeList, Computed: true, Elem: &schema.Schema{ @@ -150,6 +150,50 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "drs": { + Type: schema.TypeBool, + Computed: true, + }, + "drs_uid": { + Type: schema.TypeString, + Computed: true, + }, + "drs_name": { + Type: schema.TypeString, + Computed: true, + }, + "sso_url": { + Type: schema.TypeString, + Computed: true, + }, + "app_id": { + Type: schema.TypeString, + Computed: true, + }, + "decort_url": { + Type: schema.TypeString, + Computed: true, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, + "ping_addr": { + Type: schema.TypeString, + Computed: true, + }, + "broadcast_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ssl_skip_verify": { + Type: schema.TypeBool, + Computed: true, + }, + "sso_type": { + Type: schema.TypeString, + Computed: true, + }, } } diff --git a/internal/service/cloudapi/zone/data_source_zone_list.go b/internal/service/cloudapi/zone/data_source_zone_list.go index 6b5c75df..cfc00b54 100644 --- a/internal/service/cloudapi/zone/data_source_zone_list.go +++ b/internal/service/cloudapi/zone/data_source_zone_list.go @@ -158,6 +158,50 @@ func dataSourceZoneListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "drs": { + Type: schema.TypeBool, + Computed: true, + }, + "drs_uid": { + Type: schema.TypeString, + Computed: true, + }, + "drs_name": { + Type: schema.TypeString, + Computed: true, + }, + "sso_url": { + Type: schema.TypeString, + Computed: true, + }, + "app_id": { + Type: schema.TypeString, + Computed: true, + }, + "decort_url": { + Type: schema.TypeString, + Computed: true, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, + "ping_addr": { + Type: schema.TypeString, + Computed: true, + }, + "broadcast_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ssl_skip_verify": { + Type: schema.TypeBool, + Computed: true, + }, + "sso_type": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudapi/zone/flattens.go b/internal/service/cloudapi/zone/flattens.go index ec267ead..8f49584c 100644 --- a/internal/service/cloudapi/zone/flattens.go +++ b/internal/service/cloudapi/zone/flattens.go @@ -56,10 +56,21 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error { d.Set("compute_ids", item.ComputeIDs) d.Set("extnet_ids", item.ExtnetIDs) d.Set("vins_ids", item.VinsIDs) - d.Set("lb_ids", item.LBIDs) + d.Set("lbs_ids", item.LBIDs) d.Set("bservice_ids", item.BserviceIDs) d.Set("k8s_ids", item.K8SIDs) d.Set("auto_start", item.AutoStart) + d.Set("drs", item.DRS) + d.Set("drs_uid", item.DRSUID) + d.Set("drs_name", item.DRSName) + d.Set("sso_url", item.SSOURL) + d.Set("app_id", item.AppID) + d.Set("decort_url", item.DecortURL) + d.Set("ping_addr", item.PingAddr) + d.Set("broadcast_addr", item.BroadcastAddr) + d.Set("ssl_skip_verify", item.SSLSkipVerify) + d.Set("domain", item.Domain) + d.Set("sso_type", item.SSOType) log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete", item.Name, item.ID) @@ -71,17 +82,28 @@ func flattenZoneList(zone *zone.ListZones) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(zone.Data)) for _, zone := range zone.Data { temp := map[string]interface{}{ - "zone_id": int(zone.ID), - "guid": int(zone.GUID), - "gid": int(zone.GID), - "name": zone.Name, - "description": zone.Description, - "deletable": zone.Deletable, - "status": zone.Status, - "created_time": zone.CreatedTime, - "updated_time": zone.UpdatedTime, - "node_ids": zone.NodeIDs, - "auto_start": zone.AutoStart, + "zone_id": int(zone.ID), + "guid": int(zone.GUID), + "gid": int(zone.GID), + "name": zone.Name, + "description": zone.Description, + "deletable": zone.Deletable, + "status": zone.Status, + "created_time": zone.CreatedTime, + "updated_time": zone.UpdatedTime, + "node_ids": zone.NodeIDs, + "auto_start": zone.AutoStart, + "drs": zone.DRS, + "drs_uid": zone.DRSUID, + "drs_name": zone.DRSName, + "sso_url": zone.SSOURL, + "app_id": zone.AppID, + "decort_url": zone.DecortURL, + "ping_addr": zone.PingAddr, + "broadcast_addr": zone.BroadcastAddr, + "ssl_skip_verify": zone.SSLSkipVerify, + "domain": zone.Domain, + "sso_type": zone.SSOType, } res = append(res, temp) } diff --git a/internal/service/cloudapi/zone/utility_zone.go b/internal/service/cloudapi/zone/utility_zone.go index 32fd92f9..c1ac64bd 100644 --- a/internal/service/cloudapi/zone/utility_zone.go +++ b/internal/service/cloudapi/zone/utility_zone.go @@ -1,62 +1,62 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 zone - -import ( - "context" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) { - c := m.(*controller.ControllerCfg) - req := zone.GetRequest{} - - if d.Id() != "" { - zoneId, _ := strconv.ParseUint(d.Id(), 10, 64) - req.ID = zoneId - } else { - req.ID = uint64(d.Get("zone_id").(int)) - } - - zoneData, err := c.CloudAPI().Zone().Get(ctx, req) - if err != nil { - return nil, err - } - - return zoneData, nil -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 zone + +import ( + "context" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) { + c := m.(*controller.ControllerCfg) + req := zone.GetRequest{} + + if d.Id() != "" { + zoneId, _ := strconv.ParseUint(d.Id(), 10, 64) + req.ID = zoneId + } else { + req.ID = uint64(d.Get("zone_id").(int)) + } + + zoneData, err := c.CloudAPI().Zone().Get(ctx, req) + if err != nil { + return nil, err + } + + return zoneData, nil +} diff --git a/internal/service/cloudapi/zone/utility_zone_list.go b/internal/service/cloudapi/zone/utility_zone_list.go index d1bfa97a..65eb3e5f 100644 --- a/internal/service/cloudapi/zone/utility_zone_list.go +++ b/internal/service/cloudapi/zone/utility_zone_list.go @@ -1,85 +1,85 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 zone - -import ( - "context" - - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) { - c := m.(*controller.ControllerCfg) - req := zone.ListRequest{} - - if byId, ok := d.GetOk("by_id"); ok { - req.ByID = uint64(byId.(int)) - } - if gid, ok := d.GetOk("gid"); ok { - req.GID = uint64(gid.(int)) - } - if name, ok := d.GetOk("name"); ok { - req.Name = name.(string) - } - if description, ok := d.GetOk("description"); ok { - req.Description = description.(string) - } - if status, ok := d.GetOk("status"); ok { - req.Status = status.(string) - } - if deletable, ok := d.GetOk("deletable"); ok { - req.Deletable = deletable.(bool) - } - if nodeID, ok := d.GetOk("nodeId"); ok { - req.NodeID = uint64(nodeID.(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)) - } - - zoneList, err := c.CloudAPI().Zone().List(ctx, req) - if err != nil { - return nil, err - } - - return zoneList, nil -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 zone + +import ( + "context" + + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) { + c := m.(*controller.ControllerCfg) + req := zone.ListRequest{} + + if byId, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byId.(int)) + } + if gid, ok := d.GetOk("gid"); ok { + req.GID = uint64(gid.(int)) + } + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + if description, ok := d.GetOk("description"); ok { + req.Description = description.(string) + } + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } + if deletable, ok := d.GetOk("deletable"); ok { + req.Deletable = deletable.(bool) + } + if nodeID, ok := d.GetOk("nodeId"); ok { + req.NodeID = uint64(nodeID.(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)) + } + + zoneList, err := c.CloudAPI().Zone().List(ctx, req) + if err != nil { + return nil, err + } + + return zoneList, nil +} diff --git a/internal/service/cloudbroker/account/flattens.go b/internal/service/cloudbroker/account/flattens.go index 628c8b99..f0eb0128 100644 --- a/internal/service/cloudbroker/account/flattens.go +++ b/internal/service/cloudbroker/account/flattens.go @@ -29,6 +29,7 @@ func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount) d.Set("send_access_emails", acc.SendAccessEmails) d.Set("status", acc.Status) d.Set("uniq_pools", acc.UniqPools) + d.Set("updated_by", acc.UpdatedBy) d.Set("updated_time", acc.UpdatedTime) d.Set("version", acc.Version) d.Set("vins", acc.VINS) @@ -61,6 +62,7 @@ func flattenDataAccount(d *schema.ResourceData, acc *account.RecordAccount) { d.Set("storage_policy_ids", acc.StoragePolicyIDs) d.Set("uniq_pools", acc.UniqPools) d.Set("zone_ids", flattenZones(acc.ZoneIDs)) + d.Set("updated_by", acc.UpdatedBy) d.Set("updated_time", acc.UpdatedTime) d.Set("version", acc.Version) d.Set("vins", acc.VINS) @@ -253,6 +255,7 @@ func flattenListDeleted(al *account.ListAccounts) []map[string]interface{} { "uniq_pools": acc.UniqPools, "default_zone_id": acc.DefaultZoneID, "zone_ids": acc.ZoneIDs, + "updated_by": acc.UpdatedBy, "updated_time": acc.UpdatedTime, "version": acc.Version, "vins": acc.VINS, @@ -291,6 +294,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} { "uniq_pools": acc.UniqPools, "default_zone_id": acc.DefaultZoneID, "zone_ids": acc.ZoneIDs, + "updated_by": acc.UpdatedBy, "updated_time": acc.UpdatedTime, "version": acc.Version, "vins": acc.VINS, diff --git a/internal/service/cloudbroker/account/schema.go b/internal/service/cloudbroker/account/schema.go index c12cb670..52b52d97 100644 --- a/internal/service/cloudbroker/account/schema.go +++ b/internal/service/cloudbroker/account/schema.go @@ -282,6 +282,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, @@ -723,6 +727,10 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, @@ -1465,6 +1473,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, @@ -2331,6 +2343,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, }, }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, "updated_time": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/disks/data_source_disk_list_types_detailed.go b/internal/service/cloudbroker/disks/data_source_disk_list_types_detailed.go deleted file mode 100644 index 49adfe2d..00000000 --- a/internal/service/cloudbroker/disks/data_source_disk_list_types_detailed.go +++ /dev/null @@ -1,38 +0,0 @@ -package disks - -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 dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m) - if err != nil { - d.SetId("") - return diag.FromErr(err) - } - - id := uuid.New() - d.SetId(id.String()) - d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed)) - d.Set("entry_count", listTypesDetailed.EntryCount) - return nil -} - -func DataSourceDiskListTypesDetailed() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 1, - ReadContext: dataSourceDiskListTypesDetailedRead, - - Timeouts: &schema.ResourceTimeout{ - Read: &constants.Timeout30s, - Default: &constants.Timeout60s, - }, - - Schema: dataSourceDiskListTypesDetailedSchemaMake(), - } -} diff --git a/internal/service/cloudbroker/disks/flattens.go b/internal/service/cloudbroker/disks/flattens.go index 9798a4dc..05883686 100644 --- a/internal/service/cloudbroker/disks/flattens.go +++ b/internal/service/cloudbroker/disks/flattens.go @@ -14,6 +14,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("account_name", disk.AccountName) d.Set("acl", string(diskAcl)) d.Set("blk_discard", disk.BLKDiscard) + d.Set("block_size", disk.BlockSize) d.Set("boot_partition", disk.BootPartition) d.Set("computes", flattenDiskComputes(disk.Computes)) d.Set("created_by", disk.CreatedBy) @@ -29,6 +30,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("disk_id", disk.ID) d.Set("image_id", disk.ImageID) d.Set("images", disk.Images) + d.Set("independent", disk.Independent) d.Set("iotune", flattenIOTune(disk.IOTune)) d.Set("iqn", disk.IQN) d.Set("login", disk.Login) @@ -44,6 +46,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("pool", disk.Pool) d.Set("purge_attempts", disk.PurgeAttempts) d.Set("present_to", disk.PresentTo) + d.Set("provision", disk.Provision) d.Set("purge_time", disk.PurgeTime) d.Set("replication", flattenDiskReplication(disk.Replication)) d.Set("reality_device_number", disk.RealityDeviceNumber) @@ -62,7 +65,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("status", disk.Status) d.Set("storage_policy_id", disk.StoragePolicyID) d.Set("tech_status", disk.TechStatus) - d.Set("type", disk.Type) d.Set("vmid", disk.VMID) d.Set("updated_by", disk.UpdatedBy) d.Set("updated_time", disk.UpdatedTime) @@ -117,7 +119,6 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe 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) } @@ -187,6 +188,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "account_name": disk.AccountName, "acl": string(diskAcl), "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, "boot_partition": disk.BootPartition, "computes": flattenDiskComputes(disk.Computes), "created_by": disk.CreatedBy, @@ -202,6 +204,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "disk_id": disk.ID, "image_id": disk.ImageID, "images": disk.Images, + "independent": disk.Independent, "iotune": flattenIOTune(disk.IOTune), "iqn": disk.IQN, "login": disk.Login, @@ -217,6 +220,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "pool": disk.Pool, "purge_attempts": disk.PurgeAttempts, "purge_time": disk.PurgeTime, + "present_to": disk.PresentTo, + "provision": disk.Provision, "replication": flattenDiskReplication(disk.Replication), "reality_device_number": disk.RealityDeviceNumber, "reference_id": disk.ReferenceID, @@ -234,7 +239,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "status": disk.Status, "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, - "type": disk.Type, "vmid": disk.VMID, "updated_by": disk.UpdatedBy, "updated_time": disk.UpdatedTime, @@ -243,7 +247,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { res = append(res, temp) } return res - } func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} { @@ -261,36 +264,6 @@ func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} { res = append(res, temp) } - return res - -} - -func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} { - res := make([]map[string]interface{}, 0) - for _, typeListDetailed := range tld.Data { - toMap := typeListDetailed.(map[string]interface{}) - temp := map[string]interface{}{ - "pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})), - "sep_id": toMap["sepId"].(float64), - "sep_name": toMap["sepName"].(string), - } - res = append(res, temp) - } - return res -} - -func flattenListTypesDetailedPools(pools []interface{}) []interface{} { - res := make([]interface{}, 0) - for _, pool := range pools { - toMap := pool.(map[string]interface{}) - temp := map[string]interface{}{ - "name": toMap["name"].(string), - "system": toMap["system"].(string), - "types": toMap["types"].([]interface{}), - } - res = append(res, temp) - } - return res } @@ -304,6 +277,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter "account_name": unattachedDisk.AccountName, "acl": string(unattachedDiskAcl), "blk_discard": unattachedDisk.BLKDiscard, + "block_size": unattachedDisk.BlockSize, "boot_partition": unattachedDisk.BootPartition, "created_time": unattachedDisk.CreatedTime, "deleted_time": unattachedDisk.DeletedTime, @@ -327,6 +301,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter "pci_slot": unattachedDisk.PCISlot, "pool": unattachedDisk.Pool, "present_to": unattachedDisk.PresentTo, + "provision": unattachedDisk.Provision, "purge_attempts": unattachedDisk.PurgeAttempts, "purge_time": unattachedDisk.PurgeTime, "reality_device_number": unattachedDisk.RealityDeviceNumber, @@ -342,7 +317,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter "snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots), "status": unattachedDisk.Status, "tech_status": unattachedDisk.TechStatus, - "type": unattachedDisk.Type, + "to_clean": unattachedDisk.ToClean, "vmid": unattachedDisk.VMID, } res = append(res, tmp) diff --git a/internal/service/cloudbroker/disks/resource_disk.go b/internal/service/cloudbroker/disks/resource_disk.go index 8d90dd11..a24cc279 100644 --- a/internal/service/cloudbroker/disks/resource_disk.go +++ b/internal/service/cloudbroker/disks/resource_disk.go @@ -102,6 +102,12 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface log.Debugf("resourceDiskCreate: finished present for disk %d", d.Get("disk_id")) } + if _, ok := d.GetOk("block_size"); ok { + if err := resourceDiskChangeBlockSize(ctx, d, m); err != nil { + w.Add(err) + } + } + if _, ok := d.GetOk("iotune"); ok { if err := resourceDiskChangeIotune(ctx, d, m); err != nil { w.Add(err) @@ -244,14 +250,20 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface } } - if d.HasChange("cache") { - if err := resourceDiskChangeCache(ctx, d, m); err != nil { - return diag.FromErr(err) + if d.HasChanges("cache", "blk_discard", "block_size") { + updateReq := disks.UpdateRequest{ + DiskID: uint64(d.Get("disk_id").(int)), } - } - - if d.HasChange("blk_discard") { - if err := resourceDiskChangeBLKDiscard(ctx, d, m); err != nil { + if d.HasChange("cache") { + updateReq.Cache = d.Get("cache").(string) + } + if d.HasChange("blk_discard") { + updateReq.BLKDiscard = d.Get("blk_discard").(bool) + } + if d.HasChange("block_size") { + updateReq.BlockSize = d.Get("block_size").(string) + } + if _, err := c.CloudBroker().Disks().Update(ctx, updateReq); err != nil { return diag.FromErr(err) } } @@ -382,22 +394,12 @@ func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceDa return err } -func resourceDiskChangeCache(ctx context.Context, d *schema.ResourceData, m interface{}) error { +func resourceDiskChangeBlockSize(ctx context.Context, d *schema.ResourceData, m interface{}) error { c := m.(*controller.ControllerCfg) _, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{ - DiskID: uint64(d.Get("disk_id").(int)), - Cache: d.Get("cache").(string), - }) - return err -} - -func resourceDiskChangeBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error { - c := m.(*controller.ControllerCfg) - - _, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{ - DiskID: uint64(d.Get("disk_id").(int)), - BLKDiscard: d.Get("blk_discard").(bool), + DiskID: uint64(d.Get("disk_id").(int)), + BlockSize: d.Get("block_size").(string), }) return err } diff --git a/internal/service/cloudbroker/disks/schema.go b/internal/service/cloudbroker/disks/schema.go index d90b6091..3b7f0497 100644 --- a/internal/service/cloudbroker/disks/schema.go +++ b/internal/service/cloudbroker/disks/schema.go @@ -2,6 +2,7 @@ package disks import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func dataSourceDiskSchemaMake() map[string]*schema.Schema { @@ -26,6 +27,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -97,6 +102,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -212,6 +221,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_attempts": { Type: schema.TypeInt, Computed: true, @@ -350,10 +363,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - }, "vmid": { Type: schema.TypeInt, Computed: true, @@ -412,11 +421,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "ID of the account the disks belong to", }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: "type of the disks", - }, "sep_id": { Type: schema.TypeInt, Optional: true, @@ -447,6 +451,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "storage policy ID ", }, + "rg_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Find by rg id", + }, + "compute_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Find by compute id", + }, "items": { Type: schema.TypeList, Computed: true, @@ -468,6 +482,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -543,6 +561,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -658,6 +680,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_attempts": { Type: schema.TypeInt, Computed: true, @@ -796,10 +822,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - }, "vmid": { Type: schema.TypeInt, Computed: true, @@ -859,11 +881,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { 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, @@ -900,6 +917,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -975,6 +996,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Computed: true, @@ -1090,6 +1115,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_attempts": { Type: schema.TypeInt, Computed: true, @@ -1228,10 +1257,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - }, "vmid": { Type: schema.TypeInt, Computed: true, @@ -1259,105 +1284,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { return res } -func dataSourceDiskListTypesSchemaMake() 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": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - 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 -} - -func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema { - return 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": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pools": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Pool name", - }, - "system": { - Type: schema.TypeString, - Computed: true, - }, - "types": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", - }, - }, - }, - }, - "sep_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Storage endpoint provider ID to create disk", - }, - "sep_name": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "entry_count": { - Type: schema.TypeInt, - Computed: true, - }, - } -} - func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { res := map[string]*schema.Schema{ "by_id": { @@ -1380,11 +1306,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Find by status", }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: "type of the disks", - }, "account_id": { Type: schema.TypeInt, Optional: true, @@ -1450,6 +1371,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -1638,6 +1563,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_attempts": { Type: schema.TypeInt, Computed: true, @@ -1748,10 +1677,9 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { 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'", + "to_clean": { + Type: schema.TypeBool, + Computed: true, }, "vmid": { Type: schema.TypeInt, @@ -1952,11 +1880,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", - }, "sep_id": { Type: schema.TypeInt, Optional: true, @@ -2008,6 +1931,12 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Optional: true, Default: false, }, + "block_size": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"512", "512e", "4k"}, false), + }, "account_name": { Type: schema.TypeString, Computed: true, @@ -2079,6 +2008,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Optional: true, @@ -2201,6 +2134,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "purge_attempts": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/disks/utility_disk_list.go b/internal/service/cloudbroker/disks/utility_disk_list.go index 64028a9b..280b8e20 100644 --- a/internal/service/cloudbroker/disks/utility_disk_list.go +++ b/internal/service/cloudbroker/disks/utility_disk_list.go @@ -33,7 +33,6 @@ package disks import ( "context" - "strings" log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks" @@ -67,9 +66,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if accountId, ok := d.GetOk("account_id"); ok { req.AccountID = uint64(accountId.(int)) } - if diskType, ok := d.GetOk("type"); ok { - req.Type = strings.ToUpper(diskType.(string)) - } if pool, ok := d.GetOk("pool"); ok { req.Pool = pool.(string) } @@ -88,6 +84,12 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { req.StoragePolicyID = uint64(storagePolicyID.(int)) } + if rgID, ok := d.GetOk("rg_id"); ok { + req.RGID = uint64(rgID.(int)) + } + if computeID, ok := d.GetOk("compute_id"); ok { + req.ComputeID = uint64(computeID.(int)) + } log.Debugf("utilityDiskListCheckPresence: load disk list") diskList, err := c.CloudBroker().Disks().List(ctx, req) diff --git a/internal/service/cloudbroker/disks/utility_disk_list_deleted.go b/internal/service/cloudbroker/disks/utility_disk_list_deleted.go index 5b21553f..c7d11695 100644 --- a/internal/service/cloudbroker/disks/utility_disk_list_deleted.go +++ b/internal/service/cloudbroker/disks/utility_disk_list_deleted.go @@ -65,9 +65,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource 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) } diff --git a/internal/service/cloudbroker/disks/utility_disk_list_types.go b/internal/service/cloudbroker/disks/utility_disk_list_types.go deleted file mode 100644 index 059ff056..00000000 --- a/internal/service/cloudbroker/disks/utility_disk_list_types.go +++ /dev/null @@ -1,35 +0,0 @@ -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/cloudbroker/disks" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" -) - -func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) { - c := m.(*controller.ControllerCfg) - req := disks.ListTypesRequest{ - 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") - typesList, err := c.CloudBroker().Disks().ListTypes(ctx, req) - if err != nil { - return nil, err - } - - return typesList, nil -} diff --git a/internal/service/cloudbroker/disks/utility_disk_list_types_detailed.go b/internal/service/cloudbroker/disks/utility_disk_list_types_detailed.go deleted file mode 100644 index d8616cd7..00000000 --- a/internal/service/cloudbroker/disks/utility_disk_list_types_detailed.go +++ /dev/null @@ -1,38 +0,0 @@ -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/cloudbroker/disks" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" -) - -func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) { - c := m.(*controller.ControllerCfg) - - req := disks.ListTypesRequest{ - 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") - listTypesDetailed, err := c.CloudBroker().Disks().ListTypes(ctx, req) - - log.Debugf("%+v", listTypesDetailed.Data[0].(map[string]interface{})) - - if err != nil { - return nil, err - } - - return listTypesDetailed, nil -} diff --git a/internal/service/cloudbroker/disks/utility_disk_list_unattached.go b/internal/service/cloudbroker/disks/utility_disk_list_unattached.go index 91a0bdb5..e1e76274 100644 --- a/internal/service/cloudbroker/disks/utility_disk_list_unattached.go +++ b/internal/service/cloudbroker/disks/utility_disk_list_unattached.go @@ -25,9 +25,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou 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)) } diff --git a/internal/service/cloudbroker/dpdknet/resource_dpdk.go b/internal/service/cloudbroker/dpdknet/resource_dpdk.go index 17f5353e..07f9a0d5 100644 --- a/internal/service/cloudbroker/dpdknet/resource_dpdk.go +++ b/internal/service/cloudbroker/dpdknet/resource_dpdk.go @@ -78,6 +78,8 @@ func resourceDPDKNetCreate(ctx context.Context, d *schema.ResourceData, m interf } } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + dpdkID, err := c.CloudBroker().DPDKNet().Create(ctx, req) if err != nil { d.SetId("") @@ -93,17 +95,6 @@ func resourceDPDKNetCreate(ctx context.Context, d *schema.ResourceData, m interf warnings.Add(err) } - if d.Get("enable_secgroups").(bool) { - req := dpdk.UpdateRequest{ - DPDKID: dpdkID, - EnableSecGroups: true, - } - _, err := c.CloudBroker().DPDKNet().Update(ctx, req) - if err != nil { - warnings.Add(err) - } - } - return append(warnings.Get(), resourceDPDKNetRead(ctx, d, m)...) } diff --git a/internal/service/cloudbroker/extnet/resource_extnet.go b/internal/service/cloudbroker/extnet/resource_extnet.go index 1c0126a6..f68d9935 100644 --- a/internal/service/cloudbroker/extnet/resource_extnet.go +++ b/internal/service/cloudbroker/extnet/resource_extnet.go @@ -136,6 +136,8 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa req.MTU = uint(mtu.(int)) } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + log.Debugf("cloudbroker: Sent create request") netID, err := c.CloudBroker().ExtNet().Create(ctx, req) if err != nil { @@ -234,18 +236,6 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa } } - if d.Get("enable_secgroups").(bool) { - log.Debugf("resourceExtnetCreate: trying to enable secgroups for extnet with ID %d", netID) - req := extnet.UpdateRequest{ - NetID: netID, - EnableSecGroups: true, - } - _, err := c.CloudBroker().ExtNet().Update(ctx, req) - if err != nil { - w.Add(err) - } - } - return resourceExtnetRead(ctx, d, m) } diff --git a/internal/service/cloudbroker/flipgroup/flattens.go b/internal/service/cloudbroker/flipgroup/flattens.go index b4f78774..b211a510 100644 --- a/internal/service/cloudbroker/flipgroup/flattens.go +++ b/internal/service/cloudbroker/flipgroup/flattens.go @@ -68,6 +68,34 @@ func flattenFlipgroup(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) { d.Set("updated_time", flip.UpdatedTime) } +func flattenFlipgroupResource(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) { + d.Set("flipgroup_id", flip.ID) + d.Set("account_id", flip.AccountID) + d.Set("account_name", flip.AccountName) + d.Set("client_ids", flip.ClientIDs) + d.Set("client_names", flip.ClientNames) + d.Set("client_type", flip.ClientType) + d.Set("conn_id", flip.ConnID) + d.Set("conn_type", flip.ConnType) + d.Set("created_by", flip.CreatedBy) + d.Set("created_time", flip.CreatedTime) + d.Set("default_gw", flip.DefaultGW) + d.Set("deleted_by", flip.DeletedBy) + d.Set("deleted_time", flip.DeletedTime) + d.Set("desc", flip.Description) + d.Set("gid", flip.GID) + d.Set("guid", flip.GUID) + d.Set("ip", flip.IP) + d.Set("milestones", flip.Milestones) + d.Set("name", flip.Name) + d.Set("net_id", flip.NetID) + d.Set("net_type", flip.NetType) + d.Set("network", flip.Network) + d.Set("status", flip.Status) + d.Set("updated_by", flip.UpdatedBy) + d.Set("updated_time", flip.UpdatedTime) +} + func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(fg.Data)) for _, flip := range fg.Data { diff --git a/internal/service/cloudbroker/flipgroup/resource_flipgroup.go b/internal/service/cloudbroker/flipgroup/resource_flipgroup.go index 5e5a5ac0..29af234b 100644 --- a/internal/service/cloudbroker/flipgroup/resource_flipgroup.go +++ b/internal/service/cloudbroker/flipgroup/resource_flipgroup.go @@ -110,9 +110,9 @@ func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("The flipgroup status is destroyed and cannot be read.") } - flattenFlipgroup(d, fg) + flattenFlipgroupResource(d, fg) - log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s", + log.Debugf("resourceFlipgroupRead: after flattenFlipgroupResource: flipgroup_id %s, name %s", d.Id(), d.Get("name").(string)) return nil diff --git a/internal/service/cloudbroker/grid/flattens.go b/internal/service/cloudbroker/grid/flattens.go index 11fa14a9..76246feb 100644 --- a/internal/service/cloudbroker/grid/flattens.go +++ b/internal/service/cloudbroker/grid/flattens.go @@ -27,16 +27,17 @@ func flattenGridList(gl *grid.ListGrids) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(gl.Data)) for _, item := range gl.Data { temp := map[string]interface{}{ - "resources": flattenGridResources(item.Resources), - "name": item.Name, - "auth_broker": flattens.FlattenMeta(item.AuthBroker), - "flag": item.Flag, - "gid": item.GID, - "guid": item.GUID, - "location_code": item.LocationCode, - "id": item.ID, - "network_modes": item.NetworkModes, - "sdn_support": item.SDNSupport, + "resources": flattenGridResources(item.Resources), + "name": item.Name, + "auth_broker": flattens.FlattenMeta(item.AuthBroker), + "flag": item.Flag, + "gid": item.GID, + "guid": item.GUID, + "location_code": item.LocationCode, + "id": item.ID, + "network_modes": item.NetworkModes, + "sdn_support": item.SDNSupport, + "zero_access_enabled": item.ZeroAccessEnabled, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/grid/schema.go b/internal/service/cloudbroker/grid/schema.go index 18ac1616..2dbac5cc 100644 --- a/internal/service/cloudbroker/grid/schema.go +++ b/internal/service/cloudbroker/grid/schema.go @@ -260,6 +260,10 @@ func dataSourceGridListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "zero_access_enabled": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudbroker/ic/input_checks.go b/internal/service/cloudbroker/ic/input_checks.go index 0a1d2610..8ea8271c 100644 --- a/internal/service/cloudbroker/ic/input_checks.go +++ b/internal/service/cloudbroker/ic/input_checks.go @@ -20,6 +20,7 @@ import ( cb_trunk "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk" cb_vfpool "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vfpool" cb_vins "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" ) @@ -595,14 +596,21 @@ func ExistK8s(ctx context.Context, k8sId uint64, c *controller.ControllerCfg) er return nil } -func IsMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) error { +func IsMoreThanOneDisksTypeB(ctx context.Context, disks interface{}, chipset string) error { count := 0 + key := "bus_number" + if chipset == "i440fx" { + key = "pci_slot" + } + for _, elem := range disks.([]interface{}) { diskVal := elem.(map[string]interface{}) - if diskVal["disk_type"].(string) == "B" { + + if val, ok := diskVal[key].(int); ok && val == 6 { count++ } + if count > 1 { return fmt.Errorf("block disks have more 1 disk type 'B'") } @@ -648,9 +656,16 @@ func ExistBlankCompute(ctx context.Context, computeId uint64, m interface{}) err computeImageId := computeRecord.ImageID bootImageId := -1 for _, d := range computeRecord.Disks { - if d.Type == "B" { - bootImageId = int(d.ImageID) - break + if computeRecord.Chipset == "i440fx" { + if d.PCISlot == 6 { + bootImageId = int(d.ImageID) + break + } + } else { + if d.BusNumber == 6 { + bootImageId = int(d.ImageID) + break + } } } @@ -679,3 +694,20 @@ func ExistPlatformDisk(ctx context.Context, diskId uint64, m interface{}) error return nil } + +func ExistSDNNet(ctx context.Context, sdnIds []string, c *controller.ControllerCfg) []error { + var errs []error + + for _, uniqueIdentifier := range sdnIds { + if uniqueIdentifier == "" { + continue + } + req := logicalports.GetByUniqueIdentifierRequest{ID: uniqueIdentifier} + _, err := c.SDN().LogicalPorts().GetByUniqueIdentifier(ctx, req) + if err != nil { + errs = append(errs, fmt.Errorf("SDN logical port with unique identifier %q not found", uniqueIdentifier)) + } + } + + return errs +} diff --git a/internal/service/cloudbroker/image/flattens.go b/internal/service/cloudbroker/image/flattens.go index 9dcabf7c..156a0537 100644 --- a/internal/service/cloudbroker/image/flattens.go +++ b/internal/service/cloudbroker/image/flattens.go @@ -30,8 +30,10 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) { d.Set("guid", img.GUID) d.Set("history", flattenHistory(img.History)) d.Set("hot_resize", img.HotResize) + d.Set("independent", img.Independent) d.Set("last_modified", img.LastModified) d.Set("link_to", img.LinkTo) + d.Set("links_to", img.LinksTo) d.Set("milestones", img.Milestones) d.Set("name", img.Name) d.Set("network_interface_naming", img.NetworkInterfaceNaming) @@ -52,6 +54,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) { d.Set("storage_policy_id", img.StoragePolicyID) d.Set("tech_status", img.TechStatus) d.Set("to_clean", img.ToClean) + d.Set("target_ids", img.LinksTo) d.Set("image_type", img.Type) d.Set("url", img.URL) d.Set("username", img.Username) @@ -111,8 +114,10 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} { "guid": item.GUID, "history": flattenHistory(item.History), "hot_resize": item.HotResize, + "independent": item.Independent, "last_modified": item.LastModified, "link_to": item.LinkTo, + "links_to": item.LinksTo, "milestones": item.Milestones, "name": item.Name, "network_interface_naming": item.NetworkInterfaceNaming, diff --git a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go index f2983994..82a5281d 100644 --- a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go @@ -59,10 +59,11 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource } req := compute.CreateTemplateFromBlankRequest{ - ComputeID: uint64(d.Get("compute_id").(int)), - Name: d.Get("name").(string), - BootType: d.Get("boot_type").(string), - ImageType: d.Get("image_type").(string), + ComputeID: uint64(d.Get("compute_id").(int)), + Name: d.Get("name").(string), + BootType: d.Get("boot_type").(string), + ImageType: d.Get("image_type").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if username, ok := d.GetOk("username"); ok { diff --git a/internal/service/cloudbroker/image/resource_multi_image.go b/internal/service/cloudbroker/image/resource_multi_image.go new file mode 100644 index 00000000..fd2996fd --- /dev/null +++ b/internal/service/cloudbroker/image/resource_multi_image.go @@ -0,0 +1,274 @@ +package image + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/status" +) + +func resourceMultiImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceMultiImageCreate: called for image %s", d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + + targetIDsRaw := d.Get("target_ids").([]interface{}) + targetIDs := make([]uint64, 0, len(targetIDsRaw)) + for _, id := range targetIDsRaw { + targetIDs = append(targetIDs, uint64(id.(int))) + } + + req := image.CreateMultiImageRequest{ + Name: d.Get("name").(string), + TargetIDs: targetIDs, + AccountID: uint64(d.Get("account_id").(int)), + } + + imageId, err := c.CloudBroker().Image().CreateMultiImage(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(strconv.FormatUint(imageId, 10)) + d.Set("image_id", imageId) + + var w dc.Warnings + + if !d.Get("enabled").(bool) { + if err := resourceImageChangeEnabled(ctx, d, m); err != nil { + w.Add(err) + } + } + + if _, ok := d.GetOk("shared_with"); ok { + if err := resourceImageShare(ctx, d, m); err != nil { + w.Add(err) + } + } + + if _, ok := d.GetOk("computeci_id"); ok { + if err := resourceImageChangeComputeci(ctx, d, m); err != nil { + w.Add(err) + } + } + + updReq := image.EditRequest{} + updReq.ImageID = uint64(d.Get("image_id").(int)) + + if _, ok := d.GetOk("username"); ok { + updReq.Username = d.Get("username").(string) + } + if _, ok := d.GetOk("password"); ok { + updReq.Password = d.Get("password").(string) + } + if _, ok := d.GetOk("account_id"); ok { + updReq.AccountID = uint64(d.Get("account_id").(int)) + } + if _, ok := d.GetOkExists("bootable"); ok { + updReq.Bootable = d.Get("bootable").(bool) + } + if _, ok := d.GetOkExists("hot_resize"); ok { + updReq.HotResize = d.Get("hot_resize").(bool) + } + if _, ok := d.GetOk("network_interface_naming"); ok { + updReq.NetworkInterfaceNaming = d.Get("network_interface_naming").(string) + } + _, err = c.CloudBroker().Image().Edit(ctx, updReq) + if err != nil { + w.Add(err) + } + + return append(resourceMultiImageRead(ctx, d, m), w.Get()...) +} + +func resourceMultiImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceMultiImageRead: called for %s id: %s", d.Get("name").(string), d.Id()) + + img, err := utilityImageCheckPresence(ctx, d, m) + if err != 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.Destroyed, status.Purged: + d.SetId("") + return diag.Errorf("The resource cannot be updated because it has been destroyed") + } + + flattenImage(d, img) + + return nil +} + +func resourceMultiImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceMultiImageDelete: 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)), + } + + _, err = c.CloudBroker().Image().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func resourceMultiImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceMultiImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id()) + + img, err := utilityImageCheckPresence(ctx, d, m) + if err != 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.Destroyed, status.Purged: + d.SetId("") + return diag.Errorf("The resource cannot be updated because it has been destroyed") + } + + if d.HasChange("enabled") { + err := resourceImageChangeEnabled(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("shared_with") { + err := resourceImageShare(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("computeci_id") { + err := resourceImageChangeComputeci(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize") { + err := resourceImageEdit(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("target_ids") { + err := resourceMultiImageUpdateLinks(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + + return resourceMultiImageRead(ctx, d, m) +} + +func resourceMultiImageUpdateLinks(ctx context.Context, d *schema.ResourceData, m interface{}) error { + log.Debugf("resourceMultiImageUpdateLinks: called for %s, id: %s", d.Get("name").(string), d.Id()) + c := m.(*controller.ControllerCfg) + + imageID := uint64(d.Get("image_id").(int)) + + oldRaw, newRaw := d.GetChange("target_ids") + oldIDs := oldRaw.([]interface{}) + newIDs := newRaw.([]interface{}) + + oldSet := make(map[uint64]bool) + for _, id := range oldIDs { + oldSet[uint64(id.(int))] = true + } + + newSet := make(map[uint64]bool) + for _, id := range newIDs { + newSet[uint64(id.(int))] = true + } + + toAdd := make([]uint64, 0) + for id := range newSet { + if !oldSet[id] { + toAdd = append(toAdd, id) + } + } + + toRemove := make([]uint64, 0) + for id := range oldSet { + if !newSet[id] { + toRemove = append(toRemove, id) + } + } + + if len(toAdd) > 0 { + req := image.MultiImageAddLinksRequest{ + ImageID: imageID, + TargetIDs: toAdd, + } + _, err := c.CloudBroker().Image().MultiImageAddLinks(ctx, req) + if err != nil { + return err + } + } + + if len(toRemove) > 0 { + req := image.MultiImageDelLinksRequest{ + ImageID: imageID, + TargetIDs: toRemove, + } + _, err := c.CloudBroker().Image().MultiImageDelLinks(ctx, req) + if err != nil { + return err + } + } + + return nil +} + +func ResourceMultiImage() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 2, + + CreateContext: resourceMultiImageCreate, + ReadContext: resourceMultiImageRead, + UpdateContext: resourceMultiImageUpdate, + DeleteContext: resourceMultiImageDelete, + + 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: resourceMultiImageSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/image/schema.go b/internal/service/cloudbroker/image/schema.go index 37f02150..c42117d3 100644 --- a/internal/service/cloudbroker/image/schema.go +++ b/internal/service/cloudbroker/image/schema.go @@ -252,6 +252,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "image id", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "last_modified": { Type: schema.TypeInt, Computed: true, @@ -260,6 +264,13 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, @@ -518,6 +529,10 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Does this machine supports hot resize", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "last_modified": { Type: schema.TypeInt, Computed: true, @@ -526,6 +541,13 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, @@ -751,10 +773,12 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema { }, "status": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "type": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "user_group_id": { Type: schema.TypeString, Computed: true, @@ -1037,10 +1061,12 @@ func resourceImageSchemaMake() map[string]*schema.Schema { }, "status": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "type": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "user_group_id": { Type: schema.TypeString, Computed: true, @@ -1072,11 +1098,22 @@ func resourceImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "image id", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "link_to": { Type: schema.TypeInt, Computed: true, Description: "", }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, @@ -1334,6 +1371,10 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Image id", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "last_modified": { Type: schema.TypeInt, Computed: true, @@ -1425,6 +1466,259 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema { } } +func resourceMultiImageSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "target_ids": { + Type: schema.TypeList, + Required: true, + Description: "IDs of real images to link this multi image to", + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the multi image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Account id to make the image exclusive", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "username": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Optional username for the image", + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + + "unc_path": { + Type: schema.TypeString, + Computed: true, + Description: "unc path", + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + }, + "boot_type": { + 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, + }, + }, + "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, + }, + }, + }, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "pool_name": { + Type: schema.TypeString, + Computed: true, + }, + "present_to": { + Type: schema.TypeMap, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, + "image_type": { + Type: schema.TypeString, + Computed: true, + }, + "url": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + } +} + func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { return map[string]*schema.Schema{ "compute_id": { @@ -1437,6 +1731,11 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Required: true, Description: "Name of the rescue disk", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy ID", + }, "boot_type": { Type: schema.TypeString, Required: true, @@ -1550,10 +1849,12 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { }, "status": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "type": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "user_group_id": { Type: schema.TypeString, Computed: true, @@ -1620,6 +1921,13 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, @@ -1815,10 +2123,12 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { }, "status": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "type": { Type: schema.TypeString, - Computed: true}, + Computed: true, + }, "user_group_id": { Type: schema.TypeString, Computed: true, @@ -1881,6 +2191,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "links_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "milestones": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/k8s/schema.go b/internal/service/cloudbroker/k8s/schema.go index 219158eb..d6d879cb 100644 --- a/internal/service/cloudbroker/k8s/schema.go +++ b/internal/service/cloudbroker/k8s/schema.go @@ -1466,14 +1466,14 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema { Optional: true, Description: "insert ssl certificate in x509 pem format", }, - "chipset": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), - Default: "Q35", - Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", - }, - "lb_sysctl_params": { + "chipset": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), + Default: "Q35", + Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", + }, + "lb_sysctl_params": { Type: schema.TypeList, Optional: true, Description: "Custom sysctl values for Load Balancer instance. Applied on boot.", @@ -1810,19 +1810,19 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema { ), Description: "Node RAM in MB.", }, - "chipset": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), - Default: "Q35", - Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", - }, - "disk": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.", - }, + "chipset": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), + Default: "Q35", + Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35", + }, + "disk": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.", + }, "labels": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudbroker/kvmvm/flattens.go b/internal/service/cloudbroker/kvmvm/flattens.go index 6b1ea546..a5366857 100644 --- a/internal/service/cloudbroker/kvmvm/flattens.go +++ b/internal/service/cloudbroker/kvmvm/flattens.go @@ -18,7 +18,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p customFields, _ := json.Marshal(computeRec.CustomFields) devices, _ := json.Marshal(computeRec.Devices) userData, _ := json.Marshal(computeRec.Userdata) - bootDisk := findBootDisk(computeRec.Disks) + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) if len(computeRec.Interfaces) > 0 { log.Debugf("flattenCompute: calling parseComputeInterfacesToNetworks for %d interfaces", len(computeRec.Interfaces)) @@ -113,6 +113,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p d.Set("cpu_pin", computeRec.CPUPin) d.Set("numa_affinity", computeRec.NumaAffinity) d.Set("hp_backed", computeRec.HPBacked) + d.Set("weight", computeRec.Weight) return nil } @@ -269,10 +270,12 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks [] "node_ids": nodeIds, "size": disk.SizeMax, "sep_id": disk.SEPID, - "disk_type": disk.Type, + "pci_slot": disk.PCISlot, + "bus_number": disk.BusNumber, "pool": disk.Pool, "desc": disk.Description, "image_id": disk.ImageID, + "independent": disk.Independent, "disk_id": disk.ID, "shareable": disk.Shareable, "size_used": disk.SizeUsed, @@ -289,6 +292,8 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks [] "update_time": disk.UpdatedTime, "cache": disk.Cache, "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, + "provision": disk.Provision, "iotune": flattenIOTune(disk.IOTune), } res = append(res, temp) @@ -408,6 +413,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} "hot_resize": computeItem.HotResize, "network_interface_naming": computeItem.NetworkInterfaceNaming, "zone_id": computeItem.ZoneID, + "weight": computeItem.Weight, } res = append(res, temp) } @@ -495,6 +501,7 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri "hot_resize": computeItem.HotResize, "network_interface_naming": computeItem.NetworkInterfaceNaming, "zone_id": computeItem.ZoneID, + "weight": computeItem.Weight, } res = append(res, temp) } @@ -842,8 +849,9 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute d.Set("zone_id", compFacts.ZoneID) d.Set("loader_meta_iso", flattenLoaderMetaIso(compFacts.LoaderMetaIso)) d.Set("os_version", compFacts.OSVersion) + d.Set("weight", compFacts.Weight) //extra fields setting - bootDisk := findBootDisk(compFacts.Disks) + bootDisk := findBootDisk(compFacts.Disks, compFacts.Chipset) if bootDisk != nil { d.Set("boot_disk_size", bootDisk.SizeMax) d.Set("boot_disk_id", bootDisk.ID) // we may need boot disk ID in resize operations @@ -900,6 +908,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} { "meta": flattens.FlattenMeta(disk.Meta), "account_id": disk.AccountID, "blk_discard": disk.BLKDiscard, + "block_size": disk.BlockSize, "boot_partition": disk.BootPartition, "bus_number": disk.BusNumber, "created_time": disk.CreatedTime, @@ -915,6 +924,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} { "disk_id": disk.ID, "image_id": disk.ImageID, "images": disk.Images, + "independent": disk.Independent, "iotune": flattenIOTune(disk.IOTune), "iqn": disk.IQN, "login": disk.Login, @@ -945,6 +955,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} { "tech_status": disk.TechStatus, "type": disk.Type, "to_clean": disk.ToClean, + "provision": disk.Provision, "updated_time": disk.UpdatedTime, } res = append(res, temp) diff --git a/internal/service/cloudbroker/kvmvm/resource_check_input_values.go b/internal/service/cloudbroker/kvmvm/resource_check_input_values.go index c0969933..afdfc065 100644 --- a/internal/service/cloudbroker/kvmvm/resource_check_input_values.go +++ b/internal/service/cloudbroker/kvmvm/resource_check_input_values.go @@ -17,8 +17,10 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro errs = append(errs, err) } - if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil { - errs = append(errs, err) + if !d.Get("create_blank").(bool) { + if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil { + errs = append(errs, err) + } } if netErrs := existNetworks(ctx, d, c); errs != nil { @@ -26,7 +28,7 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro } if disks, ok := d.GetOk("disks"); ok { - if err := ic.IsMoreThanOneDisksTypeB(ctx, disks); err != nil { + if err := ic.IsMoreThanOneDisksTypeB(ctx, disks, d.Get("chipset").(string)); err != nil { errs = append(errs, err) } } @@ -37,8 +39,7 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg) []error { var errs []error var vinsIds, extNetIds, vfpoolIds, dpdkIds, trunkIds []uint64 - //TODO - //var sdnIds []string + var sdnIds []string networksIface, ok := d.GetOk("network") if !ok { @@ -60,10 +61,8 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co dpdkIds = append(dpdkIds, uint64(network["net_id"].(int))) case "TRUNK": trunkIds = append(trunkIds, uint64(network["net_id"].(int))) - - //TODO - //case "SDN": sdnIds = append(sdnIds, network["sdn_interface_id"].(string)) - + case "SDN": + sdnIds = append(sdnIds, network["sdn_interface_id"].(string)) default: continue } @@ -89,10 +88,9 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co errs = append(errs, trunkErrs...) } - //TODO - //if sdnErrs := ic.ExistSDNNet(ctx, sdnIds, c); sdnErrs != nil { - // errs = append(errs, sdnErrs...) - //} + if sdnErrs := ic.ExistSDNNet(ctx, sdnIds, c); sdnErrs != nil { + errs = append(errs, sdnErrs...) + } return errs } diff --git a/internal/service/cloudbroker/kvmvm/resource_compute.go b/internal/service/cloudbroker/kvmvm/resource_compute.go index 8c5f6d16..ea74cd2d 100644 --- a/internal/service/cloudbroker/kvmvm/resource_compute.go +++ b/internal/service/cloudbroker/kvmvm/resource_compute.go @@ -77,10 +77,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf createReqX86.NodeID = uint64(nodeID.(int)) } - if ipaType, ok := d.GetOk("ipa_type"); ok { - createReqX86.IPAType = ipaType.(string) - } - if bootSize, ok := d.GetOk("boot_disk_size"); ok { createReqX86.BootDisk = uint64(bootSize.(int)) } @@ -89,10 +85,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf createReqX86.BootDiskCache = bootDiskCache.(string) } - if IS, ok := d.GetOk("is"); ok { - createReqX86.IS = IS.(string) - } - if zoneID, ok := d.GetOk("zone_id"); ok { createReqX86.ZoneID = uint64(zoneID.(int)) } @@ -130,7 +122,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf reqInterface.Enabled = netInterfaceVal["enabled"].(bool) } - if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" { + if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" { reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int)) } @@ -251,7 +243,33 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") - apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86) + var apiResp uint64 + var err error + if d.Get("create_blank").(bool) { + log.Debugf("resourceComputeCreate: using createBlank endpoint") + createBlankReq := kvmx86.CreateBlankRequest{ + RGID: createReqX86.RGID, + Name: createReqX86.Name, + CPU: createReqX86.CPU, + RAM: createReqX86.RAM, + StoragePolicyID: createReqX86.StoragePolicyID, + WithoutBootDisk: createReqX86.WithoutBootDisk, + BootDisk: createReqX86.BootDisk, + SEPID: createReqX86.SEPID, + Pool: createReqX86.Pool, + DataDisks: createReqX86.DataDisks, + Interfaces: createReqX86.Interfaces, + Description: createReqX86.Description, + Chipset: createReqX86.Chipset, + PreferredCPU: createReqX86.PreferredCPU, + ZoneID: createReqX86.ZoneID, + OSVersion: createReqX86.OSVersion, + } + apiResp, err = c.CloudBroker().KVMX86().CreateBlank(ctx, createBlankReq) + } else { + apiResp, err = c.CloudBroker().KVMX86().Create(ctx, createReqX86) + } + if err != nil { return diag.FromErr(err) } @@ -291,6 +309,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf bootType, bootTypeOk := d.GetOk("boot_type") hotResize, hotResizeOk := d.GetOkExists("hot_resize") networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming") + weight, weightOk := d.GetOk("weight") if loaderTypeOk { updateReq.LoaderType = loaderType.(string) @@ -308,8 +327,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf updateReq.NetworkInterfaceNaming = networkInterfaceNaming.(string) } - if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk { - log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming on ComputeID: %d", computeId) + if weightOk { + updateReq.Weight = uint64(weight.(int)) + } + + if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk || weightOk { + log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming or weight on ComputeID: %d", computeId) updateReq.ComputeID = computeId _, err := c.CloudBroker().Compute().Update(ctx, updateReq) if err != nil { @@ -381,7 +404,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } if mac == "" { - warnings.Add(errors.New(fmt.Sprintf("add libvirt virtio: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + warnings.Add(fmt.Errorf("add libvirt virtio: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)) continue } log.Debugf("resourceComputeCreate: Configure libvirt virtio interface parameters on Network with type %s and id %d", netType, netId) @@ -420,7 +443,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } if mac == "" { - warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + warnings.Add(fmt.Errorf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)) continue } secGroupsIDs := make([]uint64, 0) @@ -448,6 +471,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf if nodeID, ok := d.GetOk("node_id"); ok { req.NodeID = uint64(nodeID.(int)) } + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId) if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil { warnings.Add(err) @@ -677,6 +703,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf if err != nil { warnings.Add(err) } + if err := utilityComputeCreateBlockSize(ctx, d, m); err != nil { + warnings.Add(err) + } if err := utilityComputeCreateIOTune(ctx, d, m); err != nil { warnings.Add(err) } @@ -874,7 +903,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf "boot_type", "hot_resize", "network_interface_naming", - "os_version") { + "os_version", + "weight") { if err := utilityComputeUpdate(ctx, d, m); err != nil { return diag.FromErr(err) } diff --git a/internal/service/cloudbroker/kvmvm/schema.go b/internal/service/cloudbroker/kvmvm/schema.go index 372d7f24..4053f525 100644 --- a/internal/service/cloudbroker/kvmvm/schema.go +++ b/internal/service/cloudbroker/kvmvm/schema.go @@ -232,6 +232,14 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "block_size": { + Type: schema.TypeString, + Computed: true, + }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "boot_partition": { Type: schema.TypeInt, Computed: true, @@ -287,6 +295,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "iotune": { Type: schema.TypeList, Optional: true, @@ -588,6 +600,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "interfaces": { Type: schema.TypeList, Computed: true, @@ -1150,6 +1166,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, } return res } @@ -1931,6 +1951,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -2221,6 +2245,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -2639,6 +2667,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "weight": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -3409,6 +3441,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Optional: true, Default: false, }, + "create_blank": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.", + }, "boot_disk_size": { Type: schema.TypeInt, Optional: true, @@ -3463,16 +3501,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Computed: true, Description: "ID of node to start compute", }, - "is": { - Type: schema.TypeString, - Optional: true, - Description: "system name", - }, - "ipa_type": { - Type: schema.TypeString, - Optional: true, - Description: "compute purpose", - }, "custom_fields": { Type: schema.TypeString, Optional: true, @@ -3521,8 +3549,8 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, //Default: 1500, - ValidateFunc: validation.IntBetween(1, 9216), - Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216", + ValidateFunc: validation.IntBetween(1500, 9216), + Description: "Maximum transmission unit, used only for DPDK type, must be 1500-9216", }, "sdn_interface_id": { Type: schema.TypeString, @@ -3531,22 +3559,22 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { DiffSuppressFunc: networkSubresIPAddreDiffSupperss, Description: "unique_identifier of LogicalPort on SDN side", }, - "enabled": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "network enable flag", - }, - "net_mask": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Subnet mask, used only for DPDK and VFNIC network types", + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "network enable flag", + }, + "net_mask": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Subnet mask, used only for DPDK and VFNIC network types", + }, }, }, + Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.", }, - Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.", - }, "libvirt_settings": { Type: schema.TypeSet, @@ -3609,7 +3637,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Required: true, StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating + ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "DPDK"}, false), // observe case while validating Description: "Type of the network", }, "net_id": { @@ -3750,18 +3778,31 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Optional: true, Default: false, }, + "block_size": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Disk block size", + }, + "provision": { + Type: schema.TypeString, + Computed: true, + }, "sep_id": { Type: schema.TypeInt, Computed: true, Optional: true, Description: "Storage endpoint provider ID; by default the same with boot disk", }, - "disk_type": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false), - Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'", + "pci_slot": { + Type: schema.TypeInt, + Computed: true, + Description: "PCI slot number of the disk", + }, + "bus_number": { + Type: schema.TypeInt, + Computed: true, + Description: "Bus number of the disk on virtual bus (6 = boot disk)", }, "pool": { Type: schema.TypeString, @@ -3788,11 +3829,67 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Specify image id for create disk from template", }, + "independent": { + Type: schema.TypeBool, + Computed: true, + }, "permanently": { Type: schema.TypeBool, Optional: true, Description: "Disk deletion status", }, + "disk_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Disk ID", + }, + "present_to": { + Type: schema.TypeMap, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "shareable": { + Type: schema.TypeBool, + Computed: true, + }, + "size_max": { + Type: schema.TypeInt, + Computed: true, + }, + "size_used": { + Type: schema.TypeInt, + Computed: true, + }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, + "devicename": { + Type: schema.TypeString, + Computed: true, + }, + "create_by": { + Type: schema.TypeString, + Computed: true, + }, + "create_time": { + Type: schema.TypeInt, + Computed: true, + }, + "delete_by": { + Type: schema.TypeString, + Computed: true, + }, + "delete_time": { + Type: schema.TypeInt, + Computed: true, + }, + "update_time": { + Type: schema.TypeInt, + Computed: true, + }, "iotune": { Type: schema.TypeList, Optional: true, @@ -3868,58 +3965,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { }, }, }, - "disk_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Disk ID", - }, - "present_to": { - Type: schema.TypeMap, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, - "shareable": { - Type: schema.TypeBool, - Computed: true, - }, - "size_max": { - Type: schema.TypeInt, - Computed: true, - }, - "size_used": { - Type: schema.TypeInt, - Computed: true, - }, - "to_clean": { - Type: schema.TypeBool, - Computed: true, - }, - "devicename": { - Type: schema.TypeString, - Computed: true, - }, - "create_by": { - Type: schema.TypeString, - Computed: true, - }, - "create_time": { - Type: schema.TypeInt, - Computed: true, - }, - "delete_by": { - Type: schema.TypeString, - Computed: true, - }, - "delete_time": { - Type: schema.TypeInt, - Computed: true, - }, - "update_time": { - Type: schema.TypeInt, - Computed: true, - }, }, }, }, @@ -4159,6 +4204,13 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Computed: true, Description: "the OS version installed on the VM", }, + "weight": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntAtLeast(1), + Description: "Priority weight of the compute. Higher value means higher priority and later migration.", + }, // Computed properties "account_id": { Type: schema.TypeInt, diff --git a/internal/service/cloudbroker/kvmvm/utility_compute.go b/internal/service/cloudbroker/kvmvm/utility_compute.go index 7db0dccb..ccf2136d 100644 --- a/internal/service/cloudbroker/kvmvm/utility_compute.go +++ b/internal/service/cloudbroker/kvmvm/utility_compute.go @@ -209,7 +209,11 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa } if isStopRequired { - if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { + req := compute.StartRequest{ComputeID: computeId} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } + if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil { return err } } @@ -262,11 +266,14 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in changeStoragePolicyDisks := make([]interface{}, 0) cacheUpdatedDisks := make([]interface{}, 0) blkDiscardUpdatedDisks := make([]interface{}, 0) + blockSizeUpdatedDisks := make([]interface{}, 0) iotuneUpdatedDisks := make([]interface{}, 0) migratedDisks := make([]interface{}, 0) presentNewDisks := make([]interface{}, 0) presentOldDisks := make([]interface{}, 0) + chipset := d.Get("chipset").(string) + oldDisks, newDisks := d.GetChange("disks") oldConv := oldDisks.([]interface{}) newConv := newDisks.([]interface{}) @@ -322,6 +329,10 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in blkDiscardUpdatedDisks = append(blkDiscardUpdatedDisks, el) } + if isChangeBlockSizeDisk(oldConv, el) { + blockSizeUpdatedDisks = append(blockSizeUpdatedDisks, el) + } + if isChangeIOTuneDisk(oldConv, el) { iotuneUpdatedDisks = append(iotuneUpdatedDisks, el) } @@ -330,7 +341,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if len(deletedDisks) > 0 { for _, disk := range deletedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } @@ -350,9 +361,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if len(addedDisks) > 0 { for _, disk := range addedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { - continue - } req := compute.DiskAddRequest{ ComputeID: computeId, DiskName: diskConv["disk_name"].(string), @@ -362,9 +370,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if diskConv["sep_id"].(int) != 0 { req.SepID = uint64(diskConv["sep_id"].(int)) } - if diskConv["disk_type"].(string) != "" { - req.DiskType = diskConv["disk_type"].(string) - } if diskConv["pool"].(string) != "" { req.Pool = diskConv["pool"].(string) } @@ -381,6 +386,16 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if err != nil { return err } + if blockSize, ok := diskConv["block_size"].(string); ok && blockSize != "" { + updateReq := disks.UpdateRequest{ + DiskID: diskID, + BlockSize: blockSize, + } + _, err := c.CloudBroker().Disks().Update(ctx, updateReq) + if err != nil { + return err + } + } if nodeIDs, ok := diskConv["node_ids"]; ok { presentIDs := nodeIDs.(*schema.Set).List() if len(presentIDs) > 0 { @@ -421,14 +436,16 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in return err } } - + if err != nil { + return err + } } } if len(resizedDisks) > 0 { for _, disk := range resizedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } req := compute.DiskResizeRequest{ @@ -478,7 +495,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if len(cacheUpdatedDisks) > 0 { for _, disk := range cacheUpdatedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } @@ -501,7 +518,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if len(blkDiscardUpdatedDisks) > 0 { for _, disk := range blkDiscardUpdatedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } @@ -521,18 +538,43 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in } } - if len(iotuneUpdatedDisks) > 0 { - for _, disk := range iotuneUpdatedDisks { + if len(blockSizeUpdatedDisks) > 0 { + for _, disk := range blockSizeUpdatedDisks { diskConv := disk.(map[string]interface{}) - if diskConv["disk_type"].(string) == "B" { + if isBootDisk(diskConv, chipset) { continue } + diskID := uint64(diskConv["disk_id"].(int)) if diskID == 0 { continue } - iotuneRaw, ok := diskConv["iotune"].([]interface{}) - if !ok || len(iotuneRaw) == 0 { + + req := disks.UpdateRequest{ + DiskID: diskID, + BlockSize: diskConv["block_size"].(string), + } + _, err := c.CloudBroker().Disks().Update(ctx, req) + if err != nil { + return err + } + } + } + + if len(iotuneUpdatedDisks) > 0 { + for _, disk := range iotuneUpdatedDisks { + diskConv := disk.(map[string]interface{}) + if isBootDisk(diskConv, chipset) { + continue + } + + diskID := uint64(diskConv["disk_id"].(int)) + if diskID == 0 { + continue + } + + iotuneRaw := diskConv["iotune"].([]interface{}) + if len(iotuneRaw) == 0 { continue } iotuneMap := iotuneRaw[0].(map[string]interface{}) @@ -778,10 +820,23 @@ func utilityComputePCIDevicesList(ctx context.Context, d *schema.ResourceData, m return res, nil } -func findBootDisk(disks compute.ListDisks) *compute.ItemDisk { +func isBootDisk(diskConv map[string]interface{}, chipset string) bool { + if chipset == "i440fx" { + return diskConv["pci_slot"].(int) == 6 + } + return diskConv["bus_number"].(int) == 6 +} + +func findBootDisk(disks compute.ListDisks, chipset string) *compute.ItemDisk { for _, disk := range disks { - if disk.Type == "B" { - return &disk + if chipset == "i440fx" { + if disk.PCISlot == 6 { + return &disk + } + } else { + if disk.BusNumber == 6 { + return &disk + } } } return &compute.ItemDisk{} @@ -981,7 +1036,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData if needStart { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) - if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil { + var altBootID uint64 + if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok { + altBootID = uint64(altBootIDRaw) + } else { + altBootID = 0 + } + if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil { apiErrCount += numErr lastSavedError = err } @@ -1264,6 +1325,10 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa req.OSVersion = d.Get("os_version").(string) } + if d.HasChange("weight") { + req.Weight = uint64(d.Get("weight").(int)) + } + req.CPUPin = d.Get("cpu_pin").(bool) req.HPBacked = d.Get("hp_backed").(bool) req.AutoStart = d.Get("auto_start_w_node").(bool) @@ -1308,7 +1373,11 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa // If used to be STARTED, we need to start it after update if isStopRequired { - if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { + req := compute.StartRequest{ComputeID: computeId} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + req.AltBootID = uint64(altBootID) + } + if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil { return err } } @@ -1779,6 +1848,9 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter } startReq := compute.StartRequest{ComputeID: computeId} + if altBootID, ok := d.Get("alt_boot_id").(int); ok { + startReq.AltBootID = uint64(altBootID) + } log.Debugf("utilityComputeRollback: starting compute %d", computeId) @@ -2036,10 +2108,14 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface return nil } -func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) { +func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) { c := m.(*controller.ControllerCfg) startReq := compute.StartRequest{ComputeID: computeID} + if altBootID != 0 { + startReq.AltBootID = altBootID + } + log.Debugf("utilityComputeStart: starting compute %d", computeID) _, err := c.CloudBroker().Compute().Start(ctx, startReq) if err != nil { @@ -2048,6 +2124,109 @@ func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) ( return 0, nil } +func utilityComputeCreateBlockSize(ctx context.Context, d *schema.ResourceData, m interface{}) error { + c := m.(*controller.ControllerCfg) + diskList := d.Get("disks").([]interface{}) + + blockSizeArr := make([]string, 0, len(diskList)) + hasAny := false + for _, elem := range diskList { + diskVal := elem.(map[string]interface{}) + bs := diskVal["block_size"].(string) + blockSizeArr = append(blockSizeArr, bs) + if bs != "" { + hasAny = true + } + } + + if !hasAny { + return nil + } + + computeRec, err := utilityComputeCheckPresence(ctx, d, m) + if err != nil { + return err + } + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) + computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID) + + for i, diskID := range computeDisksIDs { + if i >= len(blockSizeArr) || blockSizeArr[i] == "" { + continue + } + req := disks.UpdateRequest{ + DiskID: diskID.(uint64), + BlockSize: blockSizeArr[i], + } + _, err := c.CloudBroker().Disks().Update(ctx, req) + if err != nil { + return err + } + } + + return nil +} + +func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error { + c := m.(*controller.ControllerCfg) + diskList := d.Get("disks").([]interface{}) + + iotuneArr := make([]interface{}, 0, len(diskList)) + hasAny := false + for _, elem := range diskList { + diskVal := elem.(map[string]interface{}) + iotune := diskVal["iotune"].([]interface{}) + iotuneArr = append(iotuneArr, iotune) + if len(iotune) > 0 { + hasAny = true + } + } + + if !hasAny { + return nil + } + + computeRec, err := utilityComputeCheckPresence(ctx, d, m) + if err != nil { + return err + } + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) + computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID) + + for i, diskID := range computeDisksIDs { + if i >= len(iotuneArr) { + continue + } + iotune, ok := iotuneArr[i].([]interface{}) + if !ok || len(iotune) == 0 { + continue + } + iotuneMap := iotune[0].(map[string]interface{}) + req := disks.LimitIORequest{ + DiskID: diskID.(uint64), + ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)), + ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)), + ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)), + ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)), + SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)), + TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)), + TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)), + TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)), + TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)), + WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)), + WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)), + WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)), + WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)), + } + _, err := c.CloudBroker().Disks().LimitIO(ctx, req) + if err != nil { + return err + } + } + + return nil +} + func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData, m interface{}) error { c := m.(*controller.ControllerCfg) var errs error @@ -2059,7 +2238,7 @@ func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData } computeRec, err := utilityComputeCheckPresence(ctx, d, m) - bootDisk := findBootDisk(computeRec.Disks) + bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset) if err != nil { errs = errors.Join(err) } @@ -2141,6 +2320,18 @@ func isChangeBLKDiscardDisk(els []interface{}, el interface{}) bool { return false } +func isChangeBlockSizeDisk(els []interface{}, el interface{}) bool { + for _, elOld := range els { + elOldConv := elOld.(map[string]interface{}) + elConv := el.(map[string]interface{}) + if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) && + elOldConv["block_size"].(string) != elConv["block_size"].(string) { + return true + } + } + return false +} + func isChangeIOTuneDisk(els []interface{}, el interface{}) bool { for _, elOld := range els { elOldConv := elOld.(map[string]interface{}) @@ -2175,66 +2366,6 @@ func isChangeIOTuneDisk(els []interface{}, el interface{}) bool { return false } -func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error { - c := m.(*controller.ControllerCfg) - diskList := d.Get("disks").([]interface{}) - - iotuneArr := make([]interface{}, 0, len(diskList)) - hasAny := false - for _, elem := range diskList { - diskVal := elem.(map[string]interface{}) - iotune := diskVal["iotune"].([]interface{}) - iotuneArr = append(iotuneArr, iotune) - if len(iotune) > 0 { - hasAny = true - } - } - - if !hasAny { - return nil - } - - computeRec, err := utilityComputeCheckPresence(ctx, d, m) - if err != nil { - return err - } - bootDisk := findBootDisk(computeRec.Disks) - computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID) - - for i, diskID := range computeDisksIDs { - if i >= len(iotuneArr) { - continue - } - iotune, ok := iotuneArr[i].([]interface{}) - if !ok || len(iotune) == 0 { - continue - } - iotuneMap := iotune[0].(map[string]interface{}) - req := disks.LimitIORequest{ - DiskID: diskID.(uint64), - ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)), - ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)), - ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)), - ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)), - SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)), - TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)), - TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)), - TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)), - TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)), - WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)), - WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)), - WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)), - WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)), - } - _, err := c.CloudBroker().Disks().LimitIO(ctx, req) - if err != nil { - return err - } - } - - return nil -} - func isChangeStoragePolicy(els []interface{}, el interface{}) bool { for _, elOld := range els { elOldConv := elOld.(map[string]interface{}) diff --git a/internal/service/cloudbroker/node/flattens.go b/internal/service/cloudbroker/node/flattens.go index 224f5520..ff722cbd 100644 --- a/internal/service/cloudbroker/node/flattens.go +++ b/internal/service/cloudbroker/node/flattens.go @@ -263,11 +263,12 @@ func flattenGetNetAddr(address node.NetAddr) []map[string]interface{} { func flattenCpuInfo(info node.CpuInfo) []map[string]interface{} { res := make([]map[string]interface{}, 1) temp := map[string]interface{}{ - "clock_speed": info.ClockSpeed, - "core_count": info.CoreCount, - "phys_count": info.PhysCount, - "flags": info.Flags, - "model_name": info.ModelName, + "clock_speed": info.ClockSpeed, + "core_count": info.CoreCount, + "phys_count": info.PhysCount, + "flags": info.Flags, + "model_name": info.ModelName, + "thread_count": info.ThreadCount, } res[0] = temp return res diff --git a/internal/service/cloudbroker/node/schema.go b/internal/service/cloudbroker/node/schema.go index c5611529..403b2254 100644 --- a/internal/service/cloudbroker/node/schema.go +++ b/internal/service/cloudbroker/node/schema.go @@ -52,7 +52,7 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "vcpu": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "ram": { @@ -121,6 +121,10 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "thread_count": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -498,6 +502,11 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "find node by status", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "find node by zone id", + }, "sort_by": { Type: schema.TypeString, Optional: true, @@ -570,6 +579,10 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "thread_count": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudbroker/node/utility_node_list.go b/internal/service/cloudbroker/node/utility_node_list.go index a3f5855b..bac49b25 100644 --- a/internal/service/cloudbroker/node/utility_node_list.go +++ b/internal/service/cloudbroker/node/utility_node_list.go @@ -76,6 +76,9 @@ func utilityNodeListCheckPresence(ctx context.Context, d *schema.ResourceData, m if Size, ok := d.GetOk("size"); ok { req.Size = uint64(Size.(int)) } + if zoneId, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneId.(int)) + } log.Debugf("utilityNodeListCheckPresence: load node list") nodeList, err := c.CloudBroker().Node().List(ctx, req) diff --git a/internal/service/cloudbroker/rg/flattens.go b/internal/service/cloudbroker/rg/flattens.go index cdc97aea..af5a91f3 100644 --- a/internal/service/cloudbroker/rg/flattens.go +++ b/internal/service/cloudbroker/rg/flattens.go @@ -48,6 +48,7 @@ func flattenRgAcl(rgACLs rg.ListACL) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(rgACLs)) for _, acl := range rgACLs { temp := map[string]interface{}{ + "email": acl.Email, "explicit": acl.Explicit, "guid": acl.GUID, "right": acl.Right, diff --git a/internal/service/cloudbroker/rg/resource_rg.go b/internal/service/cloudbroker/rg/resource_rg.go index 6dadaf51..3b7a7853 100644 --- a/internal/service/cloudbroker/rg/resource_rg.go +++ b/internal/service/cloudbroker/rg/resource_rg.go @@ -107,6 +107,9 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter if _, ok := d.GetOk("def_net"); !ok { if defNetType, ok := d.GetOk("def_net_type"); ok { + if defNetType.(string) == "PRIVATE" { + return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use def_net_type=\"PRIVATE\" only when updating an existing RG that already contains a ViNS") + } req.DefNet = defNetType.(string) } } else { @@ -186,7 +189,14 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter } } - if _, ok := d.GetOk("def_net"); ok { + if defNet, ok := d.GetOk("def_net"); ok { + if defNet.(*schema.Set).Len() > 0 { + defNetList := defNet.(*schema.Set).List() + defNetItem := defNetList[0].(map[string]interface{}) + if defNetItem["net_type"].(string) == "PRIVATE" { + return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use net_type=\"PRIVATE\" in def_net block only when updating an existing RG that already contains a ViNS") + } + } if err := resourceRGSetDefNet(ctx, d, m); err != nil { w.Add(err) } @@ -483,7 +493,32 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter } if d.HasChange("def_net") { - oldDefNet, _ := d.GetChange("def_net") + oldDefNet, newDefNet := d.GetChange("def_net") + if newDefNet.(*schema.Set).Len() > 0 { + defNetList := newDefNet.(*schema.Set).List() + defNetItem := defNetList[0].(map[string]interface{}) + netType := defNetItem["net_type"].(string) + netID := uint64(defNetItem["net_id"].(int)) + + if netType == "PRIVATE" { + if netID == 0 { + if len(rgData.VINS) == 0 { + return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: no ViNSes exist in this RG", rgData.ID) + } + } else { + found := false + for _, vinsID := range rgData.VINS { + if vinsID == netID { + found = true + break + } + } + if !found { + return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: ViNS ID %d is not found in this RG", rgData.ID, netID) + } + } + } + } if oldDefNet.(*schema.Set).Len() > 0 { _, err := c.CloudBroker().RG().RemoveDefNet(ctx, rg.RemoveDefNetRequest{RGID: rgData.ID}) if err != nil { diff --git a/internal/service/cloudbroker/rg/schema.go b/internal/service/cloudbroker/rg/schema.go index b3deaa77..a9a1b27c 100644 --- a/internal/service/cloudbroker/rg/schema.go +++ b/internal/service/cloudbroker/rg/schema.go @@ -25,6 +25,10 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "email": { + Type: schema.TypeString, + Computed: true, + }, "explicit": { Type: schema.TypeBool, Computed: true, @@ -2461,6 +2465,10 @@ func resourceRgSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "email": { + Type: schema.TypeString, + Computed: true, + }, "explicit": { Type: schema.TypeBool, Computed: true, diff --git a/internal/service/cloudbroker/sep/resource_sep.go b/internal/service/cloudbroker/sep/resource_sep.go index b4dd1967..9cf40276 100644 --- a/internal/service/cloudbroker/sep/resource_sep.go +++ b/internal/service/cloudbroker/sep/resource_sep.go @@ -338,7 +338,6 @@ func resourceSepChangePools(ctx context.Context, d *schema.ResourceData, m inter log.Debugf(string(marshalPool)) addPoolReq := sep.AddPoolRequest{ SEPID: uint64(d.Get("sep_id").(int)), - Sync: true, Pool: string(marshalPool), } diff --git a/internal/service/cloudbroker/stpolicy/flattens.go b/internal/service/cloudbroker/stpolicy/flattens.go index 78bfc471..e11a9733 100644 --- a/internal/service/cloudbroker/stpolicy/flattens.go +++ b/internal/service/cloudbroker/stpolicy/flattens.go @@ -6,7 +6,6 @@ import ( ) func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { - d.Set("storage_policy_id", storagePolicy.ID) d.Set("description", storagePolicy.Description) d.Set("guid", storagePolicy.GUID) d.Set("limit_iops", storagePolicy.LimitIOPS) @@ -62,13 +61,28 @@ func flattenStoragePolicyList(storagePolicyList *stpolicy.ListStoragePolicies) [ return res } +func flattenAccessSEPPoolsResource(accessSEPPools stpolicy.ListAccessSEPPools) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + for _, asp := range accessSEPPools { + for _, poolName := range asp.PoolNames { + temp := map[string]interface{}{ + "sep_id": asp.SEPID, + "sep_name": asp.Name, + "pool_name": poolName, + "sep_tech_status": asp.SepTechStatus, + } + res = append(res, temp) + } + } + return res +} + func flattenStoragePolicyResource(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { - d.Set("storage_policy_id", storagePolicy.ID) d.Set("description", storagePolicy.Description) d.Set("guid", storagePolicy.GUID) d.Set("limit_iops", storagePolicy.LimitIOPS) d.Set("name", storagePolicy.Name) d.Set("status", storagePolicy.Status) - d.Set("access_seps_pools", flattenAccessSEPPools(storagePolicy.AccessSEPPools)) + d.Set("access_seps_pools", flattenAccessSEPPoolsResource(storagePolicy.AccessSEPPools)) d.Set("usage", flattenUsage(storagePolicy.Usage)) } diff --git a/internal/service/cloudbroker/stpolicy/resource_storage_policy.go b/internal/service/cloudbroker/stpolicy/resource_storage_policy.go index 2957fef1..2751d1a4 100644 --- a/internal/service/cloudbroker/stpolicy/resource_storage_policy.go +++ b/internal/service/cloudbroker/stpolicy/resource_storage_policy.go @@ -61,7 +61,6 @@ func resourceStoragePolicyCreate(ctx context.Context, d *schema.ResourceData, m } d.SetId(strconv.FormatUint(storagePolicyID, 10)) - d.Set("storage_policy_id", storagePolicyID) if enabled, ok := d.GetOk("enabled"); ok { isToEnable := enabled.(bool) diff --git a/internal/service/cloudbroker/stpolicy/schema.go b/internal/service/cloudbroker/stpolicy/schema.go index 9b232063..4b1d802c 100644 --- a/internal/service/cloudbroker/stpolicy/schema.go +++ b/internal/service/cloudbroker/stpolicy/schema.go @@ -7,10 +7,6 @@ import ( func resourceStoragePolicySchemaMake() map[string]*schema.Schema { res := map[string]*schema.Schema{ - "storage_policy_id": { - Type: schema.TypeInt, - Computed: true, - }, "name": { Type: schema.TypeString, Required: true, @@ -32,6 +28,10 @@ func resourceStoragePolicySchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, }, + "sep_tech_status": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, @@ -129,6 +129,10 @@ func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "sep_tech_status": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudbroker/trunk/flattens.go b/internal/service/cloudbroker/trunk/flattens.go index 49510cf9..a8c467e7 100644 --- a/internal/service/cloudbroker/trunk/flattens.go +++ b/internal/service/cloudbroker/trunk/flattens.go @@ -15,11 +15,11 @@ func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) { d.Set("name", details.Name) d.Set("mac", details.MAC) d.Set("description", details.Description) - d.Set("accountIds", details.AccountIDs) - d.Set("ovsBridge", details.OVSBridge) - d.Set("nativeVlanId", details.NativeVLANID) + d.Set("account_ids", details.AccountIDs) + d.Set("ovs_bridge", details.OVSBridge) + d.Set("native_vlan_id", details.NativeVLANID) d.Set("status", details.Status) - d.Set("trunkTags", details.TrunkTags) + d.Set("trunk_tags", details.TrunkTags) d.Set("created_at", details.CreatedAt) d.Set("created_by", details.CreatedBy) d.Set("updated_at", details.UpdatedAt) diff --git a/internal/service/cloudbroker/vfpool/resource_vfpool.go b/internal/service/cloudbroker/vfpool/resource_vfpool.go index 5ea466b5..1e10ce3b 100644 --- a/internal/service/cloudbroker/vfpool/resource_vfpool.go +++ b/internal/service/cloudbroker/vfpool/resource_vfpool.go @@ -33,6 +33,7 @@ package vfpool import ( "context" + "fmt" "strconv" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -85,6 +86,12 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa } config, configOk := d.GetOk("config") + + enableVal := d.Get("enable").(bool) + if enableVal && !configOk { + return diag.FromErr(fmt.Errorf("enable requires config to be set")) + } + if configOk { configArray := config.(*schema.Set).List() req.Config = make([]vfpool.Config, 0, len(configArray)) @@ -117,10 +124,8 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa warnings := dc.Warnings{} - if enable, ok := d.GetOk("enable"); ok { - if err := utilityVFPoolEnabled(ctx, m, enable.(bool), vfPoolID, configOk); err != nil { - warnings.Add(err) - } + if err := utilityVFPoolEnabled(ctx, m, enableVal, vfPoolID); err != nil { + warnings.Add(err) } log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID) @@ -147,20 +152,12 @@ func resourceVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID) - _, ok := d.GetOk("config") - - if d.HasChanges("name,", "description", "account_access", "rg_access,", "config") { + if d.HasChanges("name", "description", "account_access", "rg_access", "config", "enable") { if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil { return diag.FromErr(err) } } - if d.HasChange("enable") { - if err := utilityVFPoolEnabled(ctx, m, d.Get("enable").(bool), vfPoolID, ok); err != nil { - return diag.FromErr(err) - } - } - log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID) return resourceVFPoolRead(ctx, d, m) diff --git a/internal/service/cloudbroker/vfpool/utility_vfpool.go b/internal/service/cloudbroker/vfpool/utility_vfpool.go index 7fd0c985..8b3e4d55 100644 --- a/internal/service/cloudbroker/vfpool/utility_vfpool.go +++ b/internal/service/cloudbroker/vfpool/utility_vfpool.go @@ -64,37 +64,26 @@ func utilityVFpoolCheckPresence(ctx context.Context, d *schema.ResourceData, m i return vfpoolData, nil } -func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64, configOk bool) error { +func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64) error { c := m.(*controller.ControllerCfg) - if enable && configOk { - req := vfpool.EnableRequest{ - VFPoolID: vfPoolID, - } - _, err := c.CloudBroker().VFPool().Enable(ctx, req) - if err != nil { - return err - } - } - if enable && !configOk { - return fmt.Errorf("you must provide configuration for this resource, after enabling it") - } - if !enable { - req := vfpool.DisableRequest{ - VFPoolID: vfPoolID, - } - _, err := c.CloudBroker().VFPool().Disable(ctx, req) - if err != nil { - return err - } + var err error + + if enable { + _, err = c.CloudBroker().VFPool().Enable(ctx, vfpool.EnableRequest{VFPoolID: vfPoolID}) + } else { + _, err = c.CloudBroker().VFPool().Disable(ctx, vfpool.DisableRequest{VFPoolID: vfPoolID}) } - log.Debugf("utilityVFPoolEnabled: enable=%v vfPool ID %d after completing its resource configuration", enable, vfPoolID) - - return nil + return err } func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error { + hasConfig := len(d.Get("config").(*schema.Set).List()) > 0 + if d.Get("enable").(bool) && !hasConfig { + return fmt.Errorf("enable requires config to be set") + } + c := m.(*controller.ControllerCfg) vfPool, err := utilityVFpoolCheckPresence(ctx, d, m) @@ -190,7 +179,7 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac } log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req) - if len(d.Get("config").(*schema.Set).List()) > 0 && d.Get("enable").(bool) { + if hasConfig && d.Get("enable").(bool) { reqEnable := vfpool.EnableRequest{ VFPoolID: vfPoolID, } @@ -201,8 +190,6 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac return err } log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID) - } else { - return (fmt.Errorf("the vfPool is not enabled after update, you must provide configuration for this resource, after enabling it")) } return nil diff --git a/internal/service/cloudbroker/vgpu/api.go b/internal/service/cloudbroker/vgpu/api.go deleted file mode 100644 index a0b096fa..00000000 --- a/internal/service/cloudbroker/vgpu/api.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, - -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 vgpu - -const VGPU_LIST_API = "/restmachine/cloudbroker/vgpu/list" diff --git a/internal/service/cloudbroker/vgpu/data_source_vgpu.go b/internal/service/cloudbroker/vgpu/data_source_vgpu.go deleted file mode 100644 index bce04307..00000000 --- a/internal/service/cloudbroker/vgpu/data_source_vgpu.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, - -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 vgpu - -import ( - "context" - "strconv" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceVGPURead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - vgpu, err := utilityVGPUCheckPresence(ctx, d, m) - if vgpu == nil { - d.SetId("") - return diag.FromErr(err) - } - - d.SetId(strconv.FormatUint(vgpu.ID, 10)) - d.Set("vgpu_id", vgpu.ID) - d.Set("account_id", vgpu.AccountID) - d.Set("mode", vgpu.Mode) - d.Set("pgpu", vgpu.PGPUID) - d.Set("profile_id", vgpu.ProfileID) - d.Set("ram", vgpu.RAM) - d.Set("status", vgpu.Status) - d.Set("type", vgpu.Type) - d.Set("vm_id", vgpu.VMID) - - return nil -} - -func dataSourceVGPUSchemaMake() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "vgpu_id": { - Type: schema.TypeInt, - Required: true, - }, - - "account_id": { - Type: schema.TypeInt, - Computed: true, - }, - - "mode": { - Type: schema.TypeString, - Computed: true, - }, - - "pgpu": { - Type: schema.TypeInt, - Computed: true, - }, - - "profile_id": { - Type: schema.TypeInt, - Computed: true, - }, - - "ram": { - Type: schema.TypeInt, - Computed: true, - }, - - "status": { - Type: schema.TypeString, - Computed: true, - }, - - "type": { - Type: schema.TypeString, - Computed: true, - }, - - "vm_id": { - Type: schema.TypeInt, - Computed: true, - }, - } -} - -func DataSourceVGPU() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 1, - - ReadContext: dataSourceVGPURead, - - Schema: dataSourceVGPUSchemaMake(), - } -} diff --git a/internal/service/cloudbroker/vgpu/utility_vgpu.go b/internal/service/cloudbroker/vgpu/utility_vgpu.go deleted file mode 100644 index 516306f1..00000000 --- a/internal/service/cloudbroker/vgpu/utility_vgpu.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, - -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 vgpu - -import ( - "context" - "strconv" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vgpu" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" -) - -func utilityVGPUCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vgpu.ItemVGPU, error) { - c := m.(*controller.ControllerCfg) - req := vgpu.ListRequest{ - Size: 50, - } - - var vgpuId uint64 - var err error - - if vId, ok := d.GetOk("vgpu_id"); ok { - vgpuId = uint64(vId.(int)) - } else { - vgpuId, err = strconv.ParseUint(d.Id(), 10, 64) - if err != nil { - return nil, err - } - } - - for page := 1; ; page++ { - req.Page = uint64(page) - vgpus, err := c.CloudBroker().VGPU().List(ctx, req) - if err != nil { - return nil, err - } - - for _, vgpu := range vgpus.Data { - if vgpu.ID == vgpuId { - return &vgpu, nil - } - } - } -} diff --git a/internal/service/cloudbroker/vins/resource_utility.go b/internal/service/cloudbroker/vins/resource_utility.go index a6890404..a1d69e49 100644 --- a/internal/service/cloudbroker/vins/resource_utility.go +++ b/internal/service/cloudbroker/vins/resource_utility.go @@ -88,6 +88,8 @@ func createVinsInAcc(ctx context.Context, d *schema.ResourceData, m interface{}, req.ZoneID = uint64(zoneID.(int)) } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + return req, nil } @@ -143,6 +145,8 @@ func createVinsInRG(ctx context.Context, d *schema.ResourceData, m interface{}, req.ZoneID = uint64(zoneID.(int)) } + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + return req, nil } diff --git a/internal/service/cloudbroker/vins/resource_vins.go b/internal/service/cloudbroker/vins/resource_vins.go index 2920d97a..72df5519 100644 --- a/internal/service/cloudbroker/vins/resource_vins.go +++ b/internal/service/cloudbroker/vins/resource_vins.go @@ -115,12 +115,6 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface } } - if d.Get("enable_secgroups").(bool) { - if err := resourceVinsEnableSecgroups(ctx, d, m, vinsID); err != nil { - warnings.Add(err) - } - } - return append(warnings.Get(), resourceVinsRead(ctx, d, m)...) } @@ -437,21 +431,6 @@ func resourceVinsIpReserve(ctx context.Context, d *schema.ResourceData, m interf return errs } -func resourceVinsEnableSecgroups(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error { - c := m.(*controller.ControllerCfg) - - req := vins.UpdateRequest{ - VINSID: vinsID, - EnableSecGroups: true, - } - - _, err := c.CloudBroker().VINS().Update(ctx, req) - if err != nil { - return err - } - return nil -} - func resourceVinsNatRuleAdd(ctx context.Context, d *schema.ResourceData, m interface{}, vinsId uint64) []error { var errs []error c := m.(*controller.ControllerCfg) diff --git a/internal/service/cloudbroker/zone/data_source_zone.go b/internal/service/cloudbroker/zone/data_source_zone.go index cf5ac633..bc6a0c9a 100644 --- a/internal/service/cloudbroker/zone/data_source_zone.go +++ b/internal/service/cloudbroker/zone/data_source_zone.go @@ -150,6 +150,50 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "drs": { + Type: schema.TypeBool, + Computed: true, + }, + "drs_uid": { + Type: schema.TypeString, + Computed: true, + }, + "drs_name": { + Type: schema.TypeString, + Computed: true, + }, + "sso_url": { + Type: schema.TypeString, + Computed: true, + }, + "app_id": { + Type: schema.TypeString, + Computed: true, + }, + "decort_url": { + Type: schema.TypeString, + Computed: true, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, + "ping_addr": { + Type: schema.TypeString, + Computed: true, + }, + "broadcast_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ssl_skip_verify": { + Type: schema.TypeBool, + Computed: true, + }, + "sso_type": { + Type: schema.TypeString, + Computed: true, + }, } } diff --git a/internal/service/cloudbroker/zone/data_source_zone_list.go b/internal/service/cloudbroker/zone/data_source_zone_list.go index 6b5c75df..cfc00b54 100644 --- a/internal/service/cloudbroker/zone/data_source_zone_list.go +++ b/internal/service/cloudbroker/zone/data_source_zone_list.go @@ -158,6 +158,50 @@ func dataSourceZoneListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "drs": { + Type: schema.TypeBool, + Computed: true, + }, + "drs_uid": { + Type: schema.TypeString, + Computed: true, + }, + "drs_name": { + Type: schema.TypeString, + Computed: true, + }, + "sso_url": { + Type: schema.TypeString, + Computed: true, + }, + "app_id": { + Type: schema.TypeString, + Computed: true, + }, + "decort_url": { + Type: schema.TypeString, + Computed: true, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, + "ping_addr": { + Type: schema.TypeString, + Computed: true, + }, + "broadcast_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ssl_skip_verify": { + Type: schema.TypeBool, + Computed: true, + }, + "sso_type": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudbroker/zone/flattens.go b/internal/service/cloudbroker/zone/flattens.go index e9390862..6cb1a597 100644 --- a/internal/service/cloudbroker/zone/flattens.go +++ b/internal/service/cloudbroker/zone/flattens.go @@ -60,6 +60,17 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error { d.Set("bservice_ids", item.BserviceIDs) d.Set("k8s_ids", item.K8SIDs) d.Set("auto_start", item.AutoStart) + d.Set("drs", item.DRS) + d.Set("drs_uid", item.DRSUID) + d.Set("drs_name", item.DRSName) + d.Set("sso_url", item.SSOURL) + d.Set("app_id", item.AppID) + d.Set("decort_url", item.DecortURL) + d.Set("ping_addr", item.PingAddr) + d.Set("broadcast_addr", item.BroadcastAddr) + d.Set("ssl_skip_verify", item.SSLSkipVerify) + d.Set("domain", item.Domain) + d.Set("sso_type", item.SSOType) log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete", item.Name, item.ID) @@ -71,17 +82,28 @@ func flattenZoneList(zone *zone.ListZones) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(zone.Data)) for _, zone := range zone.Data { temp := map[string]interface{}{ - "zone_id": int(zone.ID), - "guid": int(zone.GUID), - "gid": int(zone.GID), - "name": zone.Name, - "description": zone.Description, - "deletable": zone.Deletable, - "status": zone.Status, - "created_time": zone.CreatedTime, - "updated_time": zone.UpdatedTime, - "node_ids": zone.NodeIDs, - "auto_start": zone.AutoStart, + "zone_id": int(zone.ID), + "guid": int(zone.GUID), + "gid": int(zone.GID), + "name": zone.Name, + "description": zone.Description, + "deletable": zone.Deletable, + "status": zone.Status, + "created_time": zone.CreatedTime, + "updated_time": zone.UpdatedTime, + "node_ids": zone.NodeIDs, + "auto_start": zone.AutoStart, + "drs": zone.DRS, + "drs_uid": zone.DRSUID, + "drs_name": zone.DRSName, + "sso_url": zone.SSOURL, + "app_id": zone.AppID, + "decort_url": zone.DecortURL, + "ping_addr": zone.PingAddr, + "broadcast_addr": zone.BroadcastAddr, + "ssl_skip_verify": zone.SSLSkipVerify, + "domain": zone.Domain, + "sso_type": zone.SSOType, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/zone/resource_zone.go b/internal/service/cloudbroker/zone/resource_zone.go index 33eec6f4..05d3f346 100644 --- a/internal/service/cloudbroker/zone/resource_zone.go +++ b/internal/service/cloudbroker/zone/resource_zone.go @@ -64,6 +64,10 @@ func resourceZoneCreate(ctx context.Context, d *schema.ResourceData, m interface req.Description = desc.(string) } + if drs, ok := d.GetOkExists("drs"); ok { + req.DRS = drs.(bool) + } + zoneID, err := c.CloudBroker().Zone().Create(ctx, req) if err != nil { return diag.FromErr(err) @@ -202,6 +206,51 @@ func resourceZoneSchemaMake() map[string]*schema.Schema { Optional: true, Default: false, }, + "drs": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "drs_uid": { + Type: schema.TypeString, + Computed: true, + }, + "drs_name": { + Type: schema.TypeString, + Computed: true, + }, + "sso_url": { + Type: schema.TypeString, + Computed: true, + }, + "app_id": { + Type: schema.TypeString, + Computed: true, + }, + "decort_url": { + Type: schema.TypeString, + Computed: true, + }, + "domain": { + Type: schema.TypeString, + Computed: true, + }, + "ping_addr": { + Type: schema.TypeString, + Computed: true, + }, + "broadcast_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ssl_skip_verify": { + Type: schema.TypeBool, + Computed: true, + }, + "sso_type": { + Type: schema.TypeString, + Computed: true, + }, "zone_id": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/zone/utility_zone.go b/internal/service/cloudbroker/zone/utility_zone.go index dc8a2e6b..7c4dc595 100644 --- a/internal/service/cloudbroker/zone/utility_zone.go +++ b/internal/service/cloudbroker/zone/utility_zone.go @@ -1,159 +1,159 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 zone - -import ( - "context" - "strconv" - - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - log "github.com/sirupsen/logrus" -) - -func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) { - c := m.(*controller.ControllerCfg) - req := zone.GetRequest{} - - if d.Id() != "" { - zoneId, _ := strconv.ParseUint(d.Id(), 10, 64) - req.ID = zoneId - } else { - req.ID = uint64(d.Get("zone_id").(int)) - } - - zoneData, err := c.CloudBroker().Zone().Get(ctx, req) - if err != nil { - return nil, err - } - - return zoneData, nil -} - -func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error { - c := m.(*controller.ControllerCfg) - - if d.HasChanges("name", "description", "auto_start") { - req := zone.UpdateRequest{ - ID: zoneID, - } - - if d.HasChange("name") { - req.Name = d.Get("name").(string) - } - if d.HasChange("description") { - req.Description = d.Get("description").(string) - } - - if d.HasChange("auto_start") { - req.AutoStart = d.Get("auto_start").(bool) - } - - _, err := c.CloudBroker().Zone().Update(ctx, req) - if err != nil { - return err - } - log.Debugf("utilityZoneUpdate: update zone with ID: %d, complete with params=%v", zoneID, req) - } - - addedNodes := make([]interface{}, 0) - removedNodes := make([]interface{}, 0) - - old_set, new_set := d.GetChange("node_ids") - oldSlice := old_set.([]interface{}) - newSlice := new_set.([]interface{}) - - for _, oldElem := range oldSlice { - if !containsNodes(newSlice, oldElem) { - removedNodes = append(removedNodes, oldElem) - } - } - - for _, newElem := range newSlice { - if !containsNodes(oldSlice, newElem) { - addedNodes = append(addedNodes, newElem) - } - } - - log.Debugf("Found node_ids change with %v deletion(s) and %v addition(s) [zoneID=%v]", len(removedNodes), len(addedNodes), zoneID) - - if len(addedNodes) > 0 { - - addedUint := make([]uint64, len(addedNodes)) - for i, v := range addedNodes { - addedUint[i] = uint64(v.(int)) - } - - req := zone.AddNodeRequest{ - ID: zoneID, - NodeIDs: addedUint, - } - if _, err := c.CloudBroker().Zone().AddNode(ctx, req); err != nil { - return err - } - - } - - if len(removedNodes) > 0 { - removedUint := make([]uint64, len(removedNodes)) - for i, v := range removedNodes { - removedUint[i] = uint64(v.(int)) - } - - req := zone.DelNodeRequest{ - ID: zoneID, - NodeIDs: removedUint, - } - log.Debug("del") - log.Debug(req.NodeIDs) - if _, err := c.CloudBroker().Zone().DelNode(ctx, req); err != nil { - return err - } - } - - return nil -} - -func containsNodes(set []interface{}, check interface{}) bool { - for _, elem := range set { - elemConv := elem.(int) - checkConv := check.(int) - if elemConv == checkConv { - return true - } - } - - return false -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 zone + +import ( + "context" + "strconv" + + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" +) + +func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) { + c := m.(*controller.ControllerCfg) + req := zone.GetRequest{} + + if d.Id() != "" { + zoneId, _ := strconv.ParseUint(d.Id(), 10, 64) + req.ID = zoneId + } else { + req.ID = uint64(d.Get("zone_id").(int)) + } + + zoneData, err := c.CloudBroker().Zone().Get(ctx, req) + if err != nil { + return nil, err + } + + return zoneData, nil +} + +func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error { + c := m.(*controller.ControllerCfg) + + if d.HasChanges("name", "description", "auto_start") { + req := zone.UpdateRequest{ + ID: zoneID, + } + + if d.HasChange("name") { + req.Name = d.Get("name").(string) + } + if d.HasChange("description") { + req.Description = d.Get("description").(string) + } + + if d.HasChange("auto_start") { + req.AutoStart = d.Get("auto_start").(bool) + } + + _, err := c.CloudBroker().Zone().Update(ctx, req) + if err != nil { + return err + } + log.Debugf("utilityZoneUpdate: update zone with ID: %d, complete with params=%v", zoneID, req) + } + + addedNodes := make([]interface{}, 0) + removedNodes := make([]interface{}, 0) + + old_set, new_set := d.GetChange("node_ids") + oldSlice := old_set.([]interface{}) + newSlice := new_set.([]interface{}) + + for _, oldElem := range oldSlice { + if !containsNodes(newSlice, oldElem) { + removedNodes = append(removedNodes, oldElem) + } + } + + for _, newElem := range newSlice { + if !containsNodes(oldSlice, newElem) { + addedNodes = append(addedNodes, newElem) + } + } + + log.Debugf("Found node_ids change with %v deletion(s) and %v addition(s) [zoneID=%v]", len(removedNodes), len(addedNodes), zoneID) + + if len(addedNodes) > 0 { + + addedUint := make([]uint64, len(addedNodes)) + for i, v := range addedNodes { + addedUint[i] = uint64(v.(int)) + } + + req := zone.AddNodeRequest{ + ID: zoneID, + NodeIDs: addedUint, + } + if _, err := c.CloudBroker().Zone().AddNode(ctx, req); err != nil { + return err + } + + } + + if len(removedNodes) > 0 { + removedUint := make([]uint64, len(removedNodes)) + for i, v := range removedNodes { + removedUint[i] = uint64(v.(int)) + } + + req := zone.DelNodeRequest{ + ID: zoneID, + NodeIDs: removedUint, + } + log.Debug("del") + log.Debug(req.NodeIDs) + if _, err := c.CloudBroker().Zone().DelNode(ctx, req); err != nil { + return err + } + } + + return nil +} + +func containsNodes(set []interface{}, check interface{}) bool { + for _, elem := range set { + elemConv := elem.(int) + checkConv := check.(int) + if elemConv == checkConv { + return true + } + } + + return false +} diff --git a/internal/service/cloudbroker/zone/utility_zone_list.go b/internal/service/cloudbroker/zone/utility_zone_list.go index febadd32..e17cbf63 100644 --- a/internal/service/cloudbroker/zone/utility_zone_list.go +++ b/internal/service/cloudbroker/zone/utility_zone_list.go @@ -1,85 +1,85 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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 zone - -import ( - "context" - - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) { - c := m.(*controller.ControllerCfg) - req := zone.ListRequest{} - - if byId, ok := d.GetOk("by_id"); ok { - req.ByID = uint64(byId.(int)) - } - if gid, ok := d.GetOk("gid"); ok { - req.GID = uint64(gid.(int)) - } - if name, ok := d.GetOk("name"); ok { - req.Name = name.(string) - } - if description, ok := d.GetOk("description"); ok { - req.Description = description.(string) - } - if status, ok := d.GetOk("status"); ok { - req.Status = status.(string) - } - if deletable, ok := d.GetOk("deletable"); ok { - req.Deletable = deletable.(bool) - } - if nodeID, ok := d.GetOk("nodeId"); ok { - req.NodeID = uint64(nodeID.(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)) - } - - zoneList, err := c.CloudBroker().Zone().List(ctx, req) - if err != nil { - return nil, err - } - - return zoneList, nil -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 zone + +import ( + "context" + + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) { + c := m.(*controller.ControllerCfg) + req := zone.ListRequest{} + + if byId, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byId.(int)) + } + if gid, ok := d.GetOk("gid"); ok { + req.GID = uint64(gid.(int)) + } + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + if description, ok := d.GetOk("description"); ok { + req.Description = description.(string) + } + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } + if deletable, ok := d.GetOk("deletable"); ok { + req.Deletable = deletable.(bool) + } + if nodeID, ok := d.GetOk("nodeId"); ok { + req.NodeID = uint64(nodeID.(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)) + } + + zoneList, err := c.CloudBroker().Zone().List(ctx, req) + if err != nil { + return nil, err + } + + return zoneList, nil +} diff --git a/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go b/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go index 64ea6c8b..c6886256 100644 --- a/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go +++ b/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go @@ -37,3 +37,4 @@ func DataSourceAccessGroupList() *schema.Resource { Schema: dataSourceAccessGroupListSchemaMake(), } } + diff --git a/internal/service/sdn/access_group/schema.go b/internal/service/sdn/access_group/schema.go index 964cf18d..4791e679 100644 --- a/internal/service/sdn/access_group/schema.go +++ b/internal/service/sdn/access_group/schema.go @@ -54,6 +54,10 @@ func dataSourceAccessGroupListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "filter by the upper limit of the creation date", }, + "owner_display_name": { + Type: schema.TypeString, + Optional: true, + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/sdn/access_group/utility_access_group_list.go b/internal/service/sdn/access_group/utility_access_group_list.go index f0c55b15..bfd93f26 100644 --- a/internal/service/sdn/access_group/utility_access_group_list.go +++ b/internal/service/sdn/access_group/utility_access_group_list.go @@ -40,6 +40,9 @@ func utilityAccessGroupListCheckPresence(ctx context.Context, d *schema.Resource if createdTo, ok := d.GetOk("created_to"); ok { req.CreatedTo = createdTo.(string) } + if ownerDisplayName, ok := d.GetOk("owner_display_name"); ok { + req.OwnerDisplayName = ownerDisplayName.(string) + } log.Debugf("utilityAccessGroupListCheckPresence") accessGroupList, err := c.SDN().AccessGroups().List(ctx, req) diff --git a/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go b/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go index 02203214..44758639 100644 --- a/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go +++ b/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go @@ -37,3 +37,4 @@ func DataSourceDefaultSecurityPolicyList() *schema.Resource { Schema: dataSourceDefaultSecurityPolicyListSchemaMake(), } } + diff --git a/internal/service/sdn/default_security_policy/schema.go b/internal/service/sdn/default_security_policy/schema.go index 404f124f..daabaf8a 100644 --- a/internal/service/sdn/default_security_policy/schema.go +++ b/internal/service/sdn/default_security_policy/schema.go @@ -366,3 +366,4 @@ func dataSourceDefaultSecurityPolicyListSchemaMake() map[string]*schema.Schema { return res } + diff --git a/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go b/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go index a1895903..5cf41070 100644 --- a/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go +++ b/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go @@ -37,3 +37,4 @@ func utilityDefaultSecurityPolicyListCheckPresence(ctx context.Context, d *schem return defaultSecurityPolicyList, nil } + diff --git a/internal/service/sdn/hypervisors/data_decort_sdn_hypervisor.go b/internal/service/sdn/hypervisors/data_decort_sdn_hypervisor.go new file mode 100644 index 00000000..f48b8f83 --- /dev/null +++ b/internal/service/sdn/hypervisors/data_decort_sdn_hypervisor.go @@ -0,0 +1,36 @@ +package hypervisors + +import ( + "context" + + "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 dataSourceHypervisorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + hypervisor, err := utilityHypervisorCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenHypervisorDataSource(d, hypervisor) + d.SetId(hypervisor.Name) + return nil +} + +func DataSourceHypervisor() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceHypervisorRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceHypervisorSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/disks/data_source_disk_list_types.go b/internal/service/sdn/hypervisors/data_decort_sdn_hypervisor_list.go similarity index 56% rename from internal/service/cloudbroker/disks/data_source_disk_list_types.go rename to internal/service/sdn/hypervisors/data_decort_sdn_hypervisor_list.go index 4e2e10dd..2090fbd0 100644 --- a/internal/service/cloudbroker/disks/data_source_disk_list_types.go +++ b/internal/service/sdn/hypervisors/data_decort_sdn_hypervisor_list.go @@ -1,4 +1,4 @@ -package disks +package hypervisors import ( "context" @@ -9,8 +9,8 @@ import ( "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" ) -func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m) +func dataSourceHypervisorListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + hypervisorList, err := utilityHypervisorListCheckPresence(ctx, d, m) if err != nil { d.SetId("") return diag.FromErr(err) @@ -18,22 +18,21 @@ func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m id := uuid.New() d.SetId(id.String()) - d.Set("items", listTypes.Data) - d.Set("entry_count", listTypes.EntryCount) - + d.Set("items", flattenHypervisorListDataSource(hypervisorList)) return nil } -func DataSourceDiskListTypes() *schema.Resource { +func DataSourceHypervisorList() *schema.Resource { return &schema.Resource{ SchemaVersion: 1, - ReadContext: dataSourceDiskListTypesRead, + + ReadContext: dataSourceHypervisorListRead, Timeouts: &schema.ResourceTimeout{ Read: &constants.Timeout30s, Default: &constants.Timeout60s, }, - Schema: dataSourceDiskListTypesSchemaMake(), + Schema: dataSourceHypervisorListSchemaMake(), } } diff --git a/internal/service/sdn/hypervisors/flattens.go b/internal/service/sdn/hypervisors/flattens.go new file mode 100644 index 00000000..040189ef --- /dev/null +++ b/internal/service/sdn/hypervisors/flattens.go @@ -0,0 +1,75 @@ +package hypervisors + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors" +) + +func flattenHypervisorResource(d *schema.ResourceData, hypervisor *hypervisors.RecordHypervisor) { + d.Set("display_name", hypervisor.DisplayName) + d.Set("hostname", hypervisor.Hostname) + d.Set("ip", hypervisor.IP) + d.Set("name", hypervisor.Name) + d.Set("ports", flattenPorts(hypervisor.Ports)) + d.Set("status", hypervisor.Status) + d.Set("created_at", hypervisor.CreatedAt) + d.Set("synced_at", hypervisor.SyncedAt) +} + +func flattenHypervisorListDataSource(hypervisorList hypervisors.HypervisorsList) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(hypervisorList)) + for _, v := range hypervisorList { + temp := map[string]interface{}{ + "display_name": v.DisplayName, + "hostname": v.Hostname, + "ip": v.IP, + "name": v.Name, + "ports": flattenPorts(v.Ports), + "status": v.Status, + "created_at": v.CreatedAt, + "synced_at": v.SyncedAt, + } + res = append(res, temp) + } + return res +} + +func flattenHypervisorDataSource(d *schema.ResourceData, hypervisor *hypervisors.RecordHypervisor) { + d.Set("display_name", hypervisor.DisplayName) + d.Set("hostname", hypervisor.Hostname) + d.Set("ip", hypervisor.IP) + d.Set("name", hypervisor.Name) + d.Set("ports", flattenPorts(hypervisor.Ports)) + d.Set("status", hypervisor.Status) + d.Set("created_at", hypervisor.CreatedAt) + d.Set("synced_at", hypervisor.SyncedAt) +} + +func flattenPorts(ports hypervisors.Ports) []map[string]interface{} { + final := make([]map[string]interface{}, 0) + + res := map[string]interface{}{} + + data := make([]map[string]interface{}, 0) + info := map[string]interface{}{} + + for _, v := range ports.Data { + temp := map[string]interface{}{ + "id": v.ID, + "unique_identifier": v.UniqueIdentifier, + "display_name": v.DisplayName, + "up": v.UP, + } + data = append(data, temp) + } + + info["active_ports"] = ports.Info.ActivePorts + info["total_ports"] = ports.Info.TotalPorts + + res["data"] = data + res["info"] = []interface{}{info} + + final = append(final, res) + + return final +} diff --git a/internal/service/sdn/hypervisors/resource_hypervisor.go b/internal/service/sdn/hypervisors/resource_hypervisor.go new file mode 100644 index 00000000..7a87a002 --- /dev/null +++ b/internal/service/sdn/hypervisors/resource_hypervisor.go @@ -0,0 +1,87 @@ +package hypervisors + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func resourceHypervisorCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return diag.Errorf( + "It's impossible to create a hypervisor from terraform") +} + +func resourceHypervisorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + hypervisor, err := utilityHypervisorCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenHypervisorResource(d, hypervisor) + d.SetId(hypervisor.Name) + + return nil +} + +func resourceHypervisorUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + c := m.(*controller.ControllerCfg) + req := hypervisors.UpdateDisplayNameRequest{ + Name: d.Get("name").(string), + DisplayName: d.Get("display_name").(string), + } + + _, err := c.SDN().Hypervisors().UpdateDisplayName(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + return resourceHypervisorRead(ctx, d, m) +} + +func resourceHypervisorDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + c := m.(*controller.ControllerCfg) + + req := hypervisors.DeleteRequest{ + Name: d.Get("name").(string), + } + + _, err := c.SDN().Hypervisors().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceHypervisor() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceHypervisorCreate, + ReadContext: resourceHypervisorRead, + UpdateContext: resourceHypervisorUpdate, + DeleteContext: resourceHypervisorDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout300s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout300s, + Default: &constants.Timeout300s, + }, + + Schema: resourceHypervisorSchemaMake(), + } +} diff --git a/internal/service/sdn/hypervisors/schema.go b/internal/service/sdn/hypervisors/schema.go new file mode 100644 index 00000000..3ded6bda --- /dev/null +++ b/internal/service/sdn/hypervisors/schema.go @@ -0,0 +1,320 @@ +package hypervisors + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceHypervisorSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "display_name": { + Type: schema.TypeString, + Required: true, + }, + "hostname": { + Type: schema.TypeString, + Computed: true, + }, + "ip": { + Type: schema.TypeString, + Computed: true, + }, + "ports": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "unique_identifier": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "up": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "active_ports": { + Type: schema.TypeInt, + Computed: true, + }, + "total_ports": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func dataSourceHypervisorListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"name", "hostname", "last_sync", + "display_name", "ip", "created_at", "updated_at"}, false), + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "desc"}, false), + }, + "port_info": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"detailed", "general"}, false), + }, + "hostname": { + Type: schema.TypeString, + Optional: true, + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + }, + "ip": { + Type: schema.TypeString, + Optional: true, + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + }, + "updated_from": { + Type: schema.TypeString, + Optional: true, + }, + "updated_to": { + Type: schema.TypeString, + Optional: true, + }, + "items": { + Type: schema.TypeList, + Computed: true, + Description: "List of hypervisors", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "hostname": { + Type: schema.TypeString, + Computed: true, + }, + "ip": { + Type: schema.TypeString, + Computed: true, + }, + "ports": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "unique_identifier": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "up": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "active_ports": { + Type: schema.TypeInt, + Computed: true, + }, + "total_ports": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + } + + return res +} + +func dataSourceHypervisorSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "port_info": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"detailed", "general"}, false), + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "hostname": { + Type: schema.TypeString, + Computed: true, + }, + "ip": { + Type: schema.TypeString, + Computed: true, + }, + "ports": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "unique_identifier": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "up": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "active_ports": { + Type: schema.TypeInt, + Computed: true, + }, + "total_ports": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + } + + return res +} diff --git a/internal/service/sdn/hypervisors/utility_sdn_hypervisor.go b/internal/service/sdn/hypervisors/utility_sdn_hypervisor.go new file mode 100644 index 00000000..7d10d467 --- /dev/null +++ b/internal/service/sdn/hypervisors/utility_sdn_hypervisor.go @@ -0,0 +1,32 @@ +package hypervisors + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityHypervisorCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*hypervisors.RecordHypervisor, error) { + c := m.(*controller.ControllerCfg) + + req := hypervisors.GetRequest{} + + if d.Id() != "" { + req.Name = d.Id() + } else { + req.Name = d.Get("name").(string) + } + + if portInfo, ok := d.GetOk("port_info"); ok { + req.PortInfo = portInfo.(string) + } + + hypervisor, err := c.SDN().Hypervisors().Get(ctx, req) + if err != nil { + return nil, err + } + + return hypervisor, nil +} diff --git a/internal/service/sdn/hypervisors/utility_sdn_hypervisor_list.go b/internal/service/sdn/hypervisors/utility_sdn_hypervisor_list.go new file mode 100644 index 00000000..1280a0e2 --- /dev/null +++ b/internal/service/sdn/hypervisors/utility_sdn_hypervisor_list.go @@ -0,0 +1,69 @@ +package hypervisors + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/hypervisors" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityHypervisorListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (hypervisors.HypervisorsList, error) { + c := m.(*controller.ControllerCfg) + req := hypervisors.ListRequest{} + + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + + if portInfo, ok := d.GetOk("port_info"); ok { + req.PortInfo = portInfo.(string) + } + + if hostname, ok := d.GetOk("hostname"); ok { + req.Hostname = hostname.(string) + } + + if displayName, ok := d.GetOk("display_name"); ok { + req.DisplayName = displayName.(string) + } + + if ip, ok := d.GetOk("ip"); ok { + req.IP = ip.(string) + } + + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + + if updatedFrom, ok := d.GetOk("updated_from"); ok { + req.UpdatedFrom = updatedFrom.(string) + } + + if updatedTo, ok := d.GetOk("updated_to"); ok { + req.UpdatedTo = updatedTo.(string) + } + + hypervisorList, err := c.SDN().Hypervisors().List(ctx, req) + if err != nil { + return nil, err + } + + return hypervisorList, nil +} diff --git a/internal/service/sdn/logicalports/flattens.go b/internal/service/sdn/logicalports/flattens.go index 2bf2a8eb..da6f5227 100644 --- a/internal/service/sdn/logicalports/flattens.go +++ b/internal/service/sdn/logicalports/flattens.go @@ -14,6 +14,7 @@ func flattenLogicalPortResource(d *schema.ResourceData, logicalPort *logicalport d.Set("description", logicalPort.Description) d.Set("display_name", logicalPort.DisplayName) d.Set("enabled", logicalPort.Enabled) + d.Set("external_network_id", logicalPort.ExternalNetworkID) d.Set("hypervisor", logicalPort.Hypervisor) d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName) d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV) @@ -21,6 +22,7 @@ func flattenLogicalPortResource(d *schema.ResourceData, logicalPort *logicalport d.Set("unique_identifier", logicalPort.UniqueIdentifier) d.Set("version_id", logicalPort.VersionID) d.Set("bindings", flattenBindings(logicalPort.Bindings)) + d.Set("labels", flattenLabels(logicalPort.Labels)) d.Set("created_at", logicalPort.CreatedAt) } @@ -38,11 +40,13 @@ func flattenLogicalPortList(lpl *logicalports.LogicalPortsList) []map[string]int "enabled": v.Enabled, "hypervisor": v.Hypervisor, "hypervisor_display_name": v.HypervisorDisplayName, + "external_network_id": v.ExternalNetworkID, "live_migration_target_hv": v.LiveMigrationTargetHV, "status": flattenStatus(v.Status), "unique_identifier": v.UniqueIdentifier, "version_id": v.VersionID, "bindings": flattenBindings(v.Bindings), + "labels": flattenLabels(v.Labels), "created_at": v.CreatedAt, "updated_at": v.UpdatedAt, } @@ -60,6 +64,7 @@ func flattenLogicalPort(d *schema.ResourceData, logicalPort *logicalports.Logica d.Set("description", logicalPort.Description) d.Set("display_name", logicalPort.DisplayName) d.Set("enabled", logicalPort.Enabled) + d.Set("external_network_id", logicalPort.ExternalNetworkID) d.Set("hypervisor", logicalPort.Hypervisor) d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName) d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV) @@ -67,32 +72,63 @@ func flattenLogicalPort(d *schema.ResourceData, logicalPort *logicalports.Logica d.Set("unique_identifier", logicalPort.UniqueIdentifier) d.Set("version_id", logicalPort.VersionID) d.Set("bindings", flattenBindings(logicalPort.Bindings)) + d.Set("labels", flattenLabels(logicalPort.Labels)) d.Set("created_at", logicalPort.CreatedAt) d.Set("updated_at", logicalPort.UpdatedAt) } +func flattenLabels(labels logicalports.Labels) []map[string]interface{} { + if labels.VMID == "" && labels.VMName == "" { + return []map[string]interface{}{} + } + return []map[string]interface{}{ + { + "vm_id": labels.VMID, + "vm_name": labels.VMName, + }, + } +} + func flattenBindings(bindings logicalports.Bindings) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "id": bindings.ID, - "segment_id": bindings.SegmentID, - "segment_display_name": bindings.SegmentDisplayName, - "port_security": bindings.PortSecurity, - "address_detection": bindings.AddressDetection, - "is_excluded_from_firewall": bindings.IsExcludedFromFirewall, - "version_id": bindings.VersionID, - "created_at": bindings.CreatedAt, - "updated_at": bindings.UpdatedAt, + "id": bindings.ID, + "segment_id": bindings.SegmentID, + "segment_display_name": bindings.SegmentDisplayName, + "port_security": bindings.PortSecurity, + "address_detection": bindings.AddressDetection, + "version_id": bindings.VersionID, + "created_at": bindings.CreatedAt, + "updated_at": bindings.UpdatedAt, + "logical_port_addresses": flattenLogicalPortAddresses(bindings.LogicalPortAddresses), } res = append(res, temp) return res } +func flattenLogicalPortAddresses(addrs []logicalports.LogicalPortAddress) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(addrs)) + for _, a := range addrs { + res = append(res, map[string]interface{}{ + "ip": a.IP, + "ip_type": a.IPType, + "mac": a.MAC, + "id": a.ID, + "logical_port_id": a.LogicalPortID, + "assigned_at": a.AssignedAt, + "is_discovered": a.IsDiscovered, + "is_primary": a.IsPrimary, + }) + } + return res +} + func flattenStatus(status logicalports.Status) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "common": status.Common, - "hypervisors": flattenHypervisors(status.Hypervisors), + "operation_status": status.OperationStatus, + "hypervisor_status": status.HypervisorStatus, + "hypervisors": flattenHypervisors(status.Hypervisors), } res = append(res, temp) return res @@ -102,7 +138,7 @@ func flattenHypervisors(hv []logicalports.HypervisorStatus) []map[string]interfa res := make([]map[string]interface{}, 0, len(hv)) for _, v := range hv { temp := map[string]interface{}{ - "status": v.Status, + "operation_status": v.OperationStatus, "name": v.Name, "display_name": v.DisplayName, "hypervisor_status": v.HypervisorStatus, diff --git a/internal/service/sdn/logicalports/resource_logical_port.go b/internal/service/sdn/logicalports/resource_logical_port.go index 69949b63..2af9f31f 100644 --- a/internal/service/sdn/logicalports/resource_logical_port.go +++ b/internal/service/sdn/logicalports/resource_logical_port.go @@ -17,14 +17,13 @@ func resourceLogicalPortCreate(ctx context.Context, d *schema.ResourceData, m in c := m.(*controller.ControllerCfg) req := logicalports.CreateRequest{ - AccessGroupID: d.Get("access_group_id").(string), - Description: d.Get("description").(string), - DisplayName: d.Get("display_name").(string), - Enabled: d.Get("enabled").(bool), - IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool), - Hypervisor: d.Get("hypervisor").(string), - PortSecurity: d.Get("port_security").(bool), - SegmentID: d.Get("segment_id").(string), + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + Hypervisor: d.Get("hypervisor").(string), + PortSecurity: d.Get("port_security").(bool), + SegmentID: d.Get("segment_id").(string), } if adapterMAC, ok := d.GetOk("adapter_mac"); ok { @@ -33,6 +32,16 @@ func resourceLogicalPortCreate(ctx context.Context, d *schema.ResourceData, m in if uniqueID, ok := d.GetOk("unique_identifier"); ok { req.UniqueIdentifier = uniqueID.(string) } + if labelsRaw, ok := d.GetOk("labels"); ok { + labelsList := labelsRaw.([]interface{}) + if len(labelsList) > 0 { + labelsMap := labelsList[0].(map[string]interface{}) + req.Labels = logicalports.CreateLabels{ + VMID: labelsMap["vm_id"].(string), + VMName: labelsMap["vm_name"].(string), + } + } + } if logicalPortAddresses, ok := d.GetOk("logical_port_addresses"); ok { logicalPortAddressesList := logicalPortAddresses.([]interface{}) logicalPortsAddressesArr := make([]logicalports.LogicalPortAddress, 0) @@ -46,7 +55,7 @@ func resourceLogicalPortCreate(ctx context.Context, d *schema.ResourceData, m in if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { logicalPortAddress.IsDiscovered = isDiscovered.(bool) } - if mac, ok := logicalPortAddressMap["mac_address"]; ok { + if mac, ok := logicalPortAddressMap["mac"]; ok { logicalPortAddress.MAC = mac.(string) } logicalPortsAddressesArr = append(logicalPortsAddressesArr, logicalPortAddress) @@ -84,17 +93,37 @@ func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m in log.Debugf("resourceLogicalPortUpdate: called logical port with id %s", d.Id()) c := m.(*controller.ControllerCfg) + migrate := d.Get("migrate").(bool) + req := logicalports.UpdateRequest{ - LogicalPortID: d.Id(), - VersionID: uint64(d.Get("version_id").(int)), - AdapterMAC: d.Get("adapter_mac").(string), - Description: d.Get("description").(string), - DisplayName: d.Get("display_name").(string), - Enabled: d.Get("enabled").(bool), - Hypervisor: d.Get("hypervisor").(string), - PortSecurity: d.Get("port_security").(bool), - IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool), - SegmentID: d.Get("segment_id").(string), + LogicalPortID: d.Id(), + VersionID: uint64(d.Get("version_id").(int)), + AdapterMAC: d.Get("adapter_mac").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + PortSecurity: d.Get("port_security").(bool), + SegmentID: d.Get("segment_id").(string), + } + + if !migrate { + req.Hypervisor = d.Get("hypervisor").(string) + } else { + old, _ := d.GetChange("hypervisor") + req.Hypervisor = old.(string) + } + + if d.HasChange("labels") { + if labelsRaw, ok := d.GetOk("labels"); ok { + labelsList := labelsRaw.([]interface{}) + if len(labelsList) > 0 { + labelsMap := labelsList[0].(map[string]interface{}) + req.Labels = logicalports.UpdateLabels{ + VMID: labelsMap["vm_id"].(string), + VMName: labelsMap["vm_name"].(string), + } + } + } } if d.HasChange("logical_port_addresses") { @@ -112,7 +141,7 @@ func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m in if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { logicalPortAddress.IsDiscovered = isDiscovered.(bool) } - if mac, ok := logicalPortAddressMap["mac_address"]; ok { + if mac, ok := logicalPortAddressMap["mac"]; ok { logicalPortAddress.MAC = mac.(string) } oldAddressesMap[logicalPortAddress.IP] = logicalPortAddress @@ -128,19 +157,19 @@ func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m in if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { logicalPortAddress.IsDiscovered = isDiscovered.(bool) } - if mac, ok := logicalPortAddressMap["mac_address"]; ok { + if mac, ok := logicalPortAddressMap["mac"]; ok { logicalPortAddress.MAC = mac.(string) } newAddressesMap[logicalPortAddress.IP] = logicalPortAddress } - for addressIP, _ := range oldAddressesMap { - removeAddresses := make([]string, 0) + removeAddresses := make([]string, 0) + for addressIP := range oldAddressesMap { if _, exists := newAddressesMap[addressIP]; !exists { removeAddresses = append(removeAddresses, addressIP) } - req.RemoveAddresses = removeAddresses } + req.RemoveAddresses = removeAddresses for addressIP, address := range newAddressesMap { if oldAddressIP, exists := oldAddressesMap[addressIP]; !exists || address != oldAddressIP { @@ -174,6 +203,34 @@ func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m in return diag.FromErr(err) } + if migrate { + if targetHV, ok := d.GetOk("hypervisor"); ok { + // Re-read version_id + lp, err := utilityLogicalPortCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + migrateReq := logicalports.MigrateStartRequest{ + LogicalPortID: d.Id(), + VersionID: lp.VersionID, + TargetHypervisor: targetHV.(string), + } + + _, err = c.SDN().LogicalPorts().StartMigrate(ctx, migrateReq) + if err != nil { + return diag.FromErr(err) + } + // to prevent drift on the next plan + diags := resourceLogicalPortRead(ctx, d, m) + if diags.HasError() { + return diags + } + d.Set("hypervisor", targetHV.(string)) + return diags + } + } + return resourceLogicalPortRead(ctx, d, m) } diff --git a/internal/service/sdn/logicalports/schema.go b/internal/service/sdn/logicalports/schema.go index 8cc7709d..b2715509 100644 --- a/internal/service/sdn/logicalports/schema.go +++ b/internal/service/sdn/logicalports/schema.go @@ -5,6 +5,49 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) +func logicalPortAddressesSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip": { + Type: schema.TypeString, + Computed: true, + }, + "ip_type": { + Type: schema.TypeString, + Computed: true, + }, + "mac": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "logical_port_id": { + Type: schema.TypeString, + Computed: true, + }, + "assigned_at": { + Type: schema.TypeString, + Computed: true, + }, + "is_discovered": { + Type: schema.TypeBool, + Computed: true, + }, + "is_primary": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + } +} + func resourceLogicalPortSchemaMake() map[string]*schema.Schema { res := map[string]*schema.Schema{ "access_group_id": { @@ -27,10 +70,6 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Required: true, Description: "Whether the logical port should be enabled", }, - "is_excluded_from_firewall": { - Type: schema.TypeBool, - Required: true, - }, "hypervisor": { Type: schema.TypeString, Required: true, @@ -61,6 +100,12 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Optional: true, Default: false, }, + "migrate": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "If true, triggers live migration to the hypervisor specified in the 'hypervisor' field. If false, hypervisor changes are applied via the regular update endpoint.", + }, "logical_port_addresses": { Type: schema.TypeList, Optional: true, @@ -127,20 +172,25 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Common status", + Description: "Operation status", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Hypervisor status", }, "hypervisors": { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Status of the hypervisor", + Description: "Operation status of the hypervisor", }, "name": { Type: schema.TypeString, @@ -198,10 +248,6 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "If the adapter address detection is enabled", }, - "is_excluded_from_firewall": { - Type: schema.TypeBool, - Computed: true, - }, "version_id": { Type: schema.TypeInt, Computed: true, @@ -217,6 +263,7 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time of the binding", }, + "logical_port_addresses": logicalPortAddressesSchema(), }, }, }, @@ -225,6 +272,29 @@ func resourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Version ID of the logical port", }, + "labels": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vm_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "VM ID label", + }, + "vm_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "VM name label", + }, + }, + }, + Description: "Labels", + }, } return res } @@ -322,6 +392,21 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Optional: true, ValidateFunc: validation.StringInSlice([]string{"asc", "dec"}, false), }, + "operation_status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "Idle", "SynchronizingAtCore", "SynchronizingAtOVN", + "Synchronized", "NoHypervisorAtOVN", "FailedAtCore", "TemporaryFailedAtCore", + }, false), + Description: "Filter by operation status", + }, + "hypervisor_status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Up", "Warning", "Error"}, false), + Description: "Filter by hypervisor status", + }, "items": { Type: schema.TypeList, Computed: true, @@ -377,6 +462,10 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Display name of the hypervisor", }, + "external_network_id": { + Type: schema.TypeString, + Computed: true, + }, "live_migration_target_hv": { Type: schema.TypeString, Computed: true, @@ -386,20 +475,25 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Common status", + Description: "Operation status", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Hypervisor status", }, "hypervisors": { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Status of the hypervisor", + Description: "Operation status of the hypervisor", }, "name": { Type: schema.TypeString, @@ -467,10 +561,6 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "If the adapter address detection is enabled", }, - "is_excluded_from_firewall": { - Type: schema.TypeBool, - Computed: true, - }, "version_id": { Type: schema.TypeInt, Computed: true, @@ -486,6 +576,7 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time of the binding", }, + "logical_port_addresses": logicalPortAddressesSchema(), }, }, }, @@ -499,6 +590,25 @@ func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time the logical port", }, + "labels": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vm_id": { + Type: schema.TypeString, + Computed: true, + Description: "VM ID label", + }, + "vm_name": { + Type: schema.TypeString, + Computed: true, + Description: "VM name label", + }, + }, + }, + Description: "Labels", + }, }, }, }, @@ -558,6 +668,10 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Display name of the hypervisor", }, + "external_network_id": { + Type: schema.TypeString, + Computed: true, + }, "live_migration_target_hv": { Type: schema.TypeString, Computed: true, @@ -567,20 +681,25 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Common status", + Description: "Operation status", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Hypervisor status", }, "hypervisors": { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Status of the hypervisor", + Description: "Operation status of the hypervisor", }, "name": { Type: schema.TypeString, @@ -643,10 +762,6 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { Computed: true, Description: "If the adapter address detection is enabled", }, - "is_excluded_from_firewall": { - Type: schema.TypeBool, - Computed: true, - }, "version_id": { Type: schema.TypeInt, Computed: true, @@ -662,6 +777,7 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time of the binding", }, + "logical_port_addresses": logicalPortAddressesSchema(), }, }, }, @@ -675,6 +791,25 @@ func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time the logical port", }, + "labels": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vm_id": { + Type: schema.TypeString, + Computed: true, + Description: "VM ID label", + }, + "vm_name": { + Type: schema.TypeString, + Computed: true, + Description: "VM name label", + }, + }, + }, + Description: "Labels", + }, } return res } @@ -731,6 +866,10 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Display name of the hypervisor", }, + "external_network_id": { + Type: schema.TypeString, + Computed: true, + }, "live_migration_target_hv": { Type: schema.TypeString, Computed: true, @@ -740,20 +879,25 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Common status", + Description: "Operation status", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Hypervisor status", }, "hypervisors": { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, - Description: "Status of the hypervisor", + Description: "Operation status of the hypervisor", }, "name": { Type: schema.TypeString, @@ -821,10 +965,6 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "If the adapter address detection is enabled", }, - "is_excluded_from_firewall": { - Type: schema.TypeBool, - Computed: true, - }, "version_id": { Type: schema.TypeInt, Computed: true, @@ -840,6 +980,7 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time of the binding", }, + "logical_port_addresses": logicalPortAddressesSchema(), }, }, }, @@ -853,6 +994,25 @@ func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Update time the logical port", }, + "labels": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vm_id": { + Type: schema.TypeString, + Computed: true, + Description: "VM ID label", + }, + "vm_name": { + Type: schema.TypeString, + Computed: true, + Description: "VM name label", + }, + }, + }, + Description: "Labels", + }, } return res } diff --git a/internal/service/sdn/logicalports/utility_logical_port_list.go b/internal/service/sdn/logicalports/utility_logical_port_list.go index 4fa39724..46378cea 100644 --- a/internal/service/sdn/logicalports/utility_logical_port_list.go +++ b/internal/service/sdn/logicalports/utility_logical_port_list.go @@ -69,6 +69,12 @@ func utilityLogicalPortListCheckPresence(ctx context.Context, d *schema.Resource if sortOrder, ok := d.GetOk("sort_order"); ok { req.SortOrder = sortOrder.(string) } + if operationStatus, ok := d.GetOk("operation_status"); ok { + req.OperationStatus = operationStatus.(string) + } + if hypervisorStatus, ok := d.GetOk("hypervisor_status"); ok { + req.HypervisorStatus = hypervisorStatus.(string) + } logicalPortList, err := c.SDN().LogicalPorts().List(ctx, req) if err != nil { diff --git a/internal/service/sdn/netobjgroups/computed_schemas.go b/internal/service/sdn/netobjgroups/computed_schemas.go new file mode 100644 index 00000000..e545cd24 --- /dev/null +++ b/internal/service/sdn/netobjgroups/computed_schemas.go @@ -0,0 +1,572 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 netobjgroups + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func hypervisorsInfoComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operation_status": {Type: schema.TypeString, Computed: true}, + "name": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "hypervisor_status": {Type: schema.TypeString, Computed: true}, + "synced_at": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func statusComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operation_status": {Type: schema.TypeString, Computed: true}, + "hypervisor_status": {Type: schema.TypeString, Computed: true}, + "hypervisors": hypervisorsInfoComputedSchema(), + }, + }, + } +} + +func logicalPortAddressesComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip": {Type: schema.TypeString, Computed: true}, + "ip_type": {Type: schema.TypeString, Computed: true}, + "is_discovered": {Type: schema.TypeBool, Computed: true}, + "is_primary": {Type: schema.TypeBool, Computed: true}, + "mac": {Type: schema.TypeString, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "logical_port_id": {Type: schema.TypeString, Computed: true}, + "assigned_at": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func bindingsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": {Type: schema.TypeString, Computed: true}, + "segment_display_name": {Type: schema.TypeString, Computed: true}, + "segment_id": {Type: schema.TypeString, Computed: true}, + "port_security": {Type: schema.TypeBool, Computed: true}, + "address_detection": {Type: schema.TypeBool, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "logical_port_addresses": logicalPortAddressesComputedSchema(), + }, + }, + } +} + +func excludeFirewallComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "exclusion_reason": {Type: schema.TypeString, Computed: true}, + "logical_port_addresses_excluded": {Type: schema.TypeBool, Computed: true}, + "logical_port_excluded": {Type: schema.TypeBool, Computed: true}, + }, + }, + } +} + +func labelsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vm_id": {Type: schema.TypeString, Computed: true}, + "vm_name": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func ipv6ConfigComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address_mode": {Type: schema.TypeString, Computed: true}, + "enable_periodic_ra": {Type: schema.TypeBool, Computed: true}, + "interval_ra": {Type: schema.TypeInt, Computed: true}, + "router_preference": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func routerGatewayPortComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "router_display_name": {Type: schema.TypeString, Computed: true}, + "router_id": {Type: schema.TypeString, Computed: true}, + "snat_enabled": {Type: schema.TypeBool, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func logicalPortSchemaFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "id": {Type: schema.TypeString, Computed: true}, + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "adapter_mac": {Type: schema.TypeString, Computed: true}, + "address_detection": {Type: schema.TypeBool, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "exclude_firewall": excludeFirewallComputedSchema(), + "external_network_id": {Type: schema.TypeString, Computed: true}, + "hypervisor": {Type: schema.TypeString, Computed: true}, + "hypervisor_display_name": {Type: schema.TypeString, Computed: true}, + "labels": labelsComputedSchema(), + "live_migration_target_hv": {Type: schema.TypeString, Computed: true}, + "status": statusComputedSchema(), + "bindings": bindingsComputedSchema(), + "unique_identifier": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + } +} + +func logicalPortsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: logicalPortSchemaFields(), + }, + } +} + +func l2ExternalNetworkComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bridge_network_name": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "id": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + "vlan_tag": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func l2ConnectionPortsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": {Type: schema.TypeString, Computed: true}, + "access_group_id": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + "l2_external_network": l2ExternalNetworkComputedSchema(), + }, + }, + } +} + +func appliedNetObjectGroupsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": {Type: schema.TypeString, Computed: true}, + "name": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func securityRuleNetObjectComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": {Type: schema.TypeString, Computed: true}, + "net_address_pool_id": {Type: schema.TypeString, Computed: true}, + "net_object_group_id": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func securityRuleFiltersComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "all": {Type: schema.TypeBool, Computed: true}, + "arp": {Type: schema.TypeBool, Computed: true}, + "dhcp": {Type: schema.TypeBool, Computed: true}, + "expression": {Type: schema.TypeString, Computed: true}, + "icmp": {Type: schema.TypeBool, Computed: true}, + "ip": {Type: schema.TypeBool, Computed: true}, + "ip_v4": {Type: schema.TypeBool, Computed: true}, + "ip_v6": {Type: schema.TypeBool, Computed: true}, + "keep_opened_sessions": {Type: schema.TypeBool, Computed: true}, + "nd": {Type: schema.TypeBool, Computed: true}, + "tcp": {Type: schema.TypeBool, Computed: true}, + "tcp_dst_ports": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "udp": {Type: schema.TypeBool, Computed: true}, + "udp_dst_ports": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + } +} + +func securityRuleFilterComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": {Type: schema.TypeString, Computed: true}, + "filters": securityRuleFiltersComputedSchema(), + }, + }, + } +} + +func securityRulesComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "action": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "destination_net_object": securityRuleNetObjectComputedSchema(), + "direction": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "filter": securityRuleFilterComputedSchema(), + "id": {Type: schema.TypeString, Computed: true}, + "log_enabled": {Type: schema.TypeBool, Computed: true}, + "log_name": {Type: schema.TypeString, Computed: true}, + "log_severity": {Type: schema.TypeString, Computed: true}, + "priority": {Type: schema.TypeInt, Computed: true}, + "security_policy_id": {Type: schema.TypeString, Computed: true}, + "source_net_object": securityRuleNetObjectComputedSchema(), + "statistics_enabled": {Type: schema.TypeBool, Computed: true}, + "type": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func securityPoliciesComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "applied_net_object_groups": appliedNetObjectGroupsComputedSchema(), + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "end_priority": {Type: schema.TypeInt, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "security_rules": securityRulesComputedSchema(), + "start_priority": {Type: schema.TypeInt, Computed: true}, + "status": statusComputedSchema(), + "type": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} + +func gateawayPortsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "external_l4_port_max": {Type: schema.TypeInt, Computed: true}, + "external_l4_port_min": {Type: schema.TypeInt, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "snat_enabled": {Type: schema.TypeBool, Computed: true}, + "status": statusComputedSchema(), + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func policiesComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "match": {Type: schema.TypeString, Computed: true}, + "next_ipv4_address": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "next_ipv6_address": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "priority": {Type: schema.TypeInt, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func segmentComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "subnet_v4": {Type: schema.TypeString, Computed: true}, + "subnet_v6": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func routerPortsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "id": {Type: schema.TypeString, Computed: true}, + "ipv4_address": {Type: schema.TypeString, Computed: true}, + "ipv6_address": {Type: schema.TypeString, Computed: true}, + "ipv6_config": ipv6ConfigComputedSchema(), + "mac": {Type: schema.TypeString, Computed: true}, + "segment_id": {Type: schema.TypeString, Computed: true}, + "segment": segmentComputedSchema(), + "status": statusComputedSchema(), + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func routerComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "gateaway_ports": gateawayPortsComputedSchema(), + "id": {Type: schema.TypeString, Computed: true}, + "policies": policiesComputedSchema(), + "ports": routerPortsComputedSchema(), + "status": statusComputedSchema(), + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + }, + }, + } +} + +func floatingIPComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "version_id": {Type: schema.TypeInt, Computed: true}, + "logical_port": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: logicalPortSchemaFields(), + }, + }, + "router": routerComputedSchema(), + }, + }, + } +} + +func externalNetworkPortFieldsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "comment": {Type: schema.TypeString, Computed: true}, + "display_name": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "ipv4": {Type: schema.TypeString, Computed: true}, + "ipv6": {Type: schema.TypeString, Computed: true}, + "ipv6_config": ipv6ConfigComputedSchema(), + "mac": {Type: schema.TypeString, Computed: true}, + "router_gateaway_port": routerGatewayPortComputedSchema(), + "floating_ip": floatingIPComputedSchema(), + }, + }, + } +} + +func externalNetworkPortsComputedSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": {Type: schema.TypeString, Computed: true}, + "access_group_id": {Type: schema.TypeString, Computed: true}, + "access_group_name": {Type: schema.TypeString, Computed: true}, + "bridge_network_name": {Type: schema.TypeString, Computed: true}, + "comment": {Type: schema.TypeString, Computed: true}, + "default_gateway_ipv4": {Type: schema.TypeString, Computed: true}, + "default_gateway_ipv6": {Type: schema.TypeString, Computed: true}, + "description": {Type: schema.TypeString, Computed: true}, + "enabled": {Type: schema.TypeBool, Computed: true}, + "external_network_ports": externalNetworkPortFieldsComputedSchema(), + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "ipv4": {Type: schema.TypeString, Computed: true}, + "status": statusComputedSchema(), + "version_id": {Type: schema.TypeInt, Computed: true}, + "subnet_v4": {Type: schema.TypeString, Computed: true}, + "subnet_v6": {Type: schema.TypeString, Computed: true}, + "created_at": {Type: schema.TypeString, Computed: true}, + "updated_at": {Type: schema.TypeString, Computed: true}, + "vlan_tag": {Type: schema.TypeInt, Computed: true}, + "mac": {Type: schema.TypeString, Computed: true}, + }, + }, + } +} diff --git a/internal/service/sdn/netobjgroups/decort_sdn_network_object_group.go b/internal/service/sdn/netobjgroups/decort_sdn_network_object_group.go new file mode 100644 index 00000000..76c16456 --- /dev/null +++ b/internal/service/sdn/netobjgroups/decort_sdn_network_object_group.go @@ -0,0 +1,178 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 netobjgroups + +import ( + "context" + + "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 dataSourceNetworkObjectGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + rec, err := utilityNetworkObjectGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenNetworkObjectGroupDataSource(d, rec) + d.SetId(rec.ID) + + return nil +} + +func dataSourceNetworkObjectGroupSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "net_object_group_id": { + Type: schema.TypeString, + Required: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "purpose": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "net_address_type": { + Type: schema.TypeString, + Computed: true, + }, + "ip_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ip_addr_range_end": { + Type: schema.TypeString, + Computed: true, + }, + "ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + "mac_addr": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "counters": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "addresses_count": { + Type: schema.TypeInt, + Computed: true, + }, + "l2_connection_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "logical_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_policies_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_rules_count": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "l2_connection_ports": l2ConnectionPortsComputedSchema(), + "logical_ports": logicalPortsComputedSchema(), + "external_network_ports": externalNetworkPortsComputedSchema(), + "security_policies": securityPoliciesComputedSchema(), + } +} + +func DataSourceNetworkObjectGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceNetworkObjectGroupRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceNetworkObjectGroupSchemaMake(), + } +} diff --git a/internal/service/sdn/netobjgroups/decort_sdn_network_object_group_list.go b/internal/service/sdn/netobjgroups/decort_sdn_network_object_group_list.go new file mode 100644 index 00000000..b997fdb6 --- /dev/null +++ b/internal/service/sdn/netobjgroups/decort_sdn_network_object_group_list.go @@ -0,0 +1,233 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 netobjgroups + +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 dataSourceNetworkObjectGroupListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + list, err := utilityNetworkObjectGroupListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenNetworkObjectGroupList(list)) + d.Set("entry_count", len(list.Objects)) + + return nil +} + +func dataSourceNetworkObjectGroupListSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "access_group_id": { + Type: schema.TypeString, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + }, + "updated_from": { + Type: schema.TypeString, + Optional: true, + }, + "updated_to": { + Type: schema.TypeString, + Optional: true, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "purpose": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "net_address_type": { + Type: schema.TypeString, + Computed: true, + }, + "ip_addr": { + Type: schema.TypeString, + Computed: true, + }, + "ip_addr_range_end": { + Type: schema.TypeString, + Computed: true, + }, + "ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + "mac_addr": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "counters": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "addresses_count": { + Type: schema.TypeInt, + Computed: true, + }, + "l2_connection_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "logical_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_policies_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_rules_count": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "l2_connection_ports": l2ConnectionPortsComputedSchema(), + "logical_ports": logicalPortsComputedSchema(), + "external_network_ports": externalNetworkPortsComputedSchema(), + "security_policies": securityPoliciesComputedSchema(), + }, + }, + }, + } +} + +func DataSourceNetworkObjectGroupList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceNetworkObjectGroupListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceNetworkObjectGroupListSchemaMake(), + } +} diff --git a/internal/service/sdn/netobjgroups/flattens.go b/internal/service/sdn/netobjgroups/flattens.go new file mode 100644 index 00000000..a578ecb1 --- /dev/null +++ b/internal/service/sdn/netobjgroups/flattens.go @@ -0,0 +1,581 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 netobjgroups + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups" +) + +func flattenNetworkObjectGroupResource(d *schema.ResourceData, rec *netobjgroups.RecordNetObjGroup) { + d.Set("name", rec.Name) + d.Set("access_group_id", rec.AccessGroupID) + d.Set("access_group_name", rec.AccessGroupName) + d.Set("description", rec.Description) + d.Set("type", rec.Type) + d.Set("purpose", rec.Purpose) + d.Set("version_id", int(rec.VersionID)) + d.Set("addresses", flattenAddresses(rec.Addresses)) + d.Set("counters", flattenCounters(rec.Counters)) + d.Set("l2_connection_ports", flattenL2ConnectionPorts(rec.L2ConnectionPorts)) + d.Set("logical_ports", flattenLogicalPorts(rec.LogicalPorts)) + d.Set("external_network_ports", flattenExternalNetworkPorts(rec.ExternalNetworkPorts)) + d.Set("security_policies", flattenSecurityPolicies(rec.SecurityPolicies)) +} + +func flattenNetworkObjectGroupDataSource(d *schema.ResourceData, rec *netobjgroups.RecordNetObjGroup) { + d.Set("name", rec.Name) + d.Set("access_group_id", rec.AccessGroupID) + d.Set("access_group_name", rec.AccessGroupName) + d.Set("description", rec.Description) + d.Set("type", rec.Type) + d.Set("purpose", rec.Purpose) + d.Set("version_id", int(rec.VersionID)) + d.Set("created_at", rec.CreatedAt) + d.Set("updated_at", rec.UpdatedAt) + d.Set("addresses", flattenAddresses(rec.Addresses)) + d.Set("counters", flattenCounters(rec.Counters)) + d.Set("l2_connection_ports", flattenL2ConnectionPorts(rec.L2ConnectionPorts)) + d.Set("logical_ports", flattenLogicalPorts(rec.LogicalPorts)) + d.Set("external_network_ports", flattenExternalNetworkPorts(rec.ExternalNetworkPorts)) + d.Set("security_policies", flattenSecurityPolicies(rec.SecurityPolicies)) +} + +func flattenAddresses(addrs netobjgroups.NetAddresses) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(addrs)) + for _, a := range addrs { + res = append(res, map[string]interface{}{ + "id": a.ID, + "net_address_type": a.NetAddressType, + "ip_addr": a.IPAddr, + "ip_addr_range_end": a.IPAddrRangeEnd, + "ip_prefix": a.IPPrefix, + "mac_addr": a.MACAddr, + }) + } + return res +} + +func flattenCounters(c netobjgroups.Counter) []map[string]interface{} { + return []map[string]interface{}{ + { + "addresses_count": int(c.AddressesCount), + "l2_connection_ports_count": int(c.L2ConnectionPortsCount), + "logical_ports_count": int(c.LogicalPortsCount), + "security_policies_count": int(c.SecurityPoliciesCount), + "security_rules_count": int(c.SecurityRulesCount), + }, + } +} + +func flattenStatus(s netobjgroups.Status) []map[string]interface{} { + return []map[string]interface{}{ + { + "operation_status": s.OperationStatus, + "hypervisor_status": s.HypervisorStatus, + "hypervisors": flattenHypervisorsInfo(s.Hypervisors), + }, + } +} + +func flattenHypervisorsInfo(hvs netobjgroups.HypervisorsInfo) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(hvs)) + for _, hv := range hvs { + res = append(res, map[string]interface{}{ + "operation_status": hv.OperationStatus, + "name": hv.Name, + "display_name": hv.DisplayName, + "hypervisor_status": hv.HypervisorStatus, + "synced_at": hv.SyncedAt, + }) + } + return res +} + +func flattenLogicalPortAddresses(addrs netobjgroups.LogicalPortAddresses) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(addrs)) + for _, a := range addrs { + res = append(res, map[string]interface{}{ + "ip": a.IP, + "ip_type": a.IPType, + "is_discovered": a.IsDiscovered, + "is_primary": a.IsPrimary, + "mac": a.MAC, + "id": a.ID, + "logical_port_id": a.LogicalPortID, + "assigned_at": a.AssignedAt, + }) + } + return res +} + +func flattenBindings(b netobjgroups.Bindings) []map[string]interface{} { + return []map[string]interface{}{ + { + "id": b.ID, + "segment_display_name": b.SegmentDisplayName, + "segment_id": b.SegmentID, + "port_security": b.PortSecurity, + "address_detection": b.AddressDetection, + "version_id": int(b.VersionID), + "created_at": b.CreatedAt, + "updated_at": b.UpdatedAt, + "logical_port_addresses": flattenLogicalPortAddresses(b.LogicalPortAddresses), + }, + } +} + +func flattenExcludeFirewall(e netobjgroups.ExcludeFirewall) []map[string]interface{} { + return []map[string]interface{}{ + { + "exclusion_reason": e.ExclusionReason, + "logical_port_addresses_excluded": e.LogicalPortAddressesExcluded, + "logical_port_excluded": e.LogicalPortExcluded, + }, + } +} + +func flattenLabels(l netobjgroups.Labels) []map[string]interface{} { + return []map[string]interface{}{ + { + "vm_id": l.VMID, + "vm_name": l.VMName, + }, + } +} + +func flattenLogicalPort(lp netobjgroups.LogicalPort) map[string]interface{} { + return map[string]interface{}{ + "id": lp.ID, + "access_group_id": lp.AccessGroupID, + "access_group_name": lp.AccessGroupName, + "adapter_mac": lp.AdapterMAC, + "address_detection": lp.AddressDetection, + "description": lp.Description, + "created_at": lp.CreatedAt, + "display_name": lp.DisplayName, + "enabled": lp.Enabled, + "exclude_firewall": flattenExcludeFirewall(lp.ExcludeFirewall), + "external_network_id": lp.ExternalNetworkID, + "hypervisor": lp.Hypervisor, + "hypervisor_display_name": lp.HypervisorDisplayName, + "labels": flattenLabels(lp.Labels), + "live_migration_target_hv": lp.LiveMigrationTargetHV, + "status": flattenStatus(lp.Status), + "bindings": flattenBindings(lp.Bindings), + "unique_identifier": lp.UniqueIdentifier, + "updated_at": lp.UpdatedAt, + "version_id": int(lp.VersionID), + } +} + +func flattenLogicalPorts(ports netobjgroups.LogicalPorts) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ports)) + for _, lp := range ports { + res = append(res, flattenLogicalPort(lp)) + } + return res +} + +func flattenL2ExternalNetwork(n netobjgroups.L2ExternalNetwork) []map[string]interface{} { + hypervisors := make([]interface{}, 0, len(n.Hypervisors)) + for _, h := range n.Hypervisors { + hypervisors = append(hypervisors, h) + } + vlanTag := 0 + if n.VLANTag != nil { + vlanTag = *n.VLANTag + } + return []map[string]interface{}{ + { + "bridge_network_name": n.BridgeNetworkName, + "created_at": n.CreatedAt, + "description": n.Description, + "display_name": n.DisplayName, + "hypervisors": hypervisors, + "id": n.ID, + "updated_at": n.UpdatedAt, + "version_id": int(n.VersionID), + "vlan_tag": vlanTag, + }, + } +} + +func flattenL2ConnectionPorts(ports netobjgroups.L2ConnectionPorts) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ports)) + for _, p := range ports { + res = append(res, map[string]interface{}{ + "id": p.ID, + "access_group_id": p.AccessGroupID, + "created_at": p.CreatedAt, + "updated_at": p.UpdatedAt, + "version_id": int(p.VersionID), + "l2_external_network": flattenL2ExternalNetwork(p.L2ExternalNetwork), + }) + } + return res +} + +func flattenIPv6Config(c netobjgroups.IPv6Config) []map[string]interface{} { + return []map[string]interface{}{ + { + "address_mode": c.AddressMode, + "enable_periodic_ra": c.EnablePeriodicRA, + "interval_ra": int(c.IntervalRA), + "router_preference": c.RouterPreference, + }, + } +} + +func flattenRouterGatewayPort(r netobjgroups.RouterGateawayPort) []map[string]interface{} { + return []map[string]interface{}{ + { + "created_at": r.CreatedAt, + "description": r.Description, + "id": r.ID, + "router_display_name": r.RouterDisplayName, + "router_id": r.RouterID, + "snat_enabled": r.SNATEnabled, + "updated_at": r.UpdatedAt, + }, + } +} + +func flattenSegment(s netobjgroups.Segment) []map[string]interface{} { + return []map[string]interface{}{ + { + "access_group_id": s.AccessGroupID, + "access_group_name": s.AccessGroupName, + "created_at": s.CreatedAt, + "description": s.Description, + "display_name": s.DisplayName, + "enabled": s.Enabled, + "id": s.ID, + "subnet_v4": s.SubnetV4, + "subnet_v6": s.SubnetV6, + "updated_at": s.UpdatedAt, + "version_id": int(s.VersionID), + }, + } +} + +func flattenRouter(r netobjgroups.Router) []map[string]interface{} { + gateawayPorts := make([]map[string]interface{}, 0, len(r.GateawayPorts)) + for _, gp := range r.GateawayPorts { + gateawayPorts = append(gateawayPorts, map[string]interface{}{ + "created_at": gp.CreatedAt, + "description": gp.Description, + "external_l4_port_max": int(gp.ExternalL4PortMax), + "external_l4_port_min": int(gp.ExternalL4PortMin), + "id": gp.ID, + "snat_enabled": gp.SNATEnabled, + "status": flattenStatus(gp.Status), + "updated_at": gp.UpdatedAt, + "version_id": int(gp.VersionID), + }) + } + + policies := make([]map[string]interface{}, 0, len(r.Policies)) + for _, pol := range r.Policies { + nextIPv4 := make([]interface{}, 0, len(pol.NextIPv4Address)) + for _, ip := range pol.NextIPv4Address { + nextIPv4 = append(nextIPv4, ip) + } + nextIPv6 := make([]interface{}, 0, len(pol.NextIPv6Address)) + for _, ip := range pol.NextIPv6Address { + nextIPv6 = append(nextIPv6, ip) + } + policies = append(policies, map[string]interface{}{ + "action": pol.Action, + "created_at": pol.CreatedAt, + "display_name": pol.DisplayName, + "enabled": pol.Enabled, + "id": pol.ID, + "match": pol.Match, + "next_ipv4_address": nextIPv4, + "next_ipv6_address": nextIPv6, + "priority": pol.Priority, + "updated_at": pol.UpdatedAt, + "version_id": int(pol.VersionID), + }) + } + + ports := make([]map[string]interface{}, 0, len(r.Port)) + for _, port := range r.Port { + ports = append(ports, map[string]interface{}{ + "created_at": port.CreatedAt, + "description": port.Description, + "enabled": port.Enabled, + "id": port.ID, + "ipv4_address": port.IPv4Address, + "ipv6_address": port.IPv6Address, + "ipv6_config": flattenIPv6Config(port.IPv6Config), + "mac": port.MAC, + "segment_id": port.SegmentID, + "segment": flattenSegment(port.Segment), + "status": flattenStatus(port.Status), + "updated_at": port.UpdatedAt, + "version_id": int(port.VersionID), + }) + } + + return []map[string]interface{}{ + { + "access_group_id": r.AccessGroupID, + "access_group_name": r.AccessGroupName, + "created_at": r.CreatedAt, + "description": r.Description, + "display_name": r.DisplayName, + "enabled": r.Enabled, + "gateaway_ports": gateawayPorts, + "id": r.ID, + "policies": policies, + "ports": ports, + "status": flattenStatus(r.Status), + "updated_at": r.UpdatedAt, + "version_id": int(r.VersionID), + }, + } +} + +func flattenFloatingIP(f netobjgroups.FloatingIP) []map[string]interface{} { + return []map[string]interface{}{ + { + "access_group_id": f.AccessGroupID, + "access_group_name": f.AccessGroupName, + "created_at": f.CreatedAt, + "updated_at": f.UpdatedAt, + "version_id": int(f.VersionID), + "logical_port": []map[string]interface{}{flattenLogicalPort(f.LogicalPort)}, + "router": flattenRouter(f.Router), + }, + } +} + +func flattenExternalNetworkPortFields(ports netobjgroups.ExternalNetworkPortsField) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ports)) + for _, p := range ports { + res = append(res, map[string]interface{}{ + "access_group_id": p.AccessGroupID, + "access_group_name": p.AccessGroupName, + "comment": p.Comment, + "display_name": p.DisplayName, + "enabled": p.Enabled, + "ipv4": p.IPv4, + "ipv6": p.IPv6, + "ipv6_config": flattenIPv6Config(p.IPv6Config), + "mac": p.MAC, + "router_gateaway_port": flattenRouterGatewayPort(p.RouterGateawayPort), + "floating_ip": flattenFloatingIP(p.FloatingIP), + }) + } + return res +} + +func flattenExternalNetworkPorts(ports netobjgroups.ExternalNetworkPorts) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ports)) + for _, p := range ports { + hypervisors := make([]interface{}, 0, len(p.Hypervisors)) + for _, h := range p.Hypervisors { + hypervisors = append(hypervisors, h) + } + res = append(res, map[string]interface{}{ + "id": p.ID, + "access_group_id": p.AccessGroupID, + "access_group_name": p.AccessGroupName, + "bridge_network_name": p.BridgeNetworkName, + "comment": p.Comment, + "default_gateway_ipv4": p.DefaultGatewayIPv4, + "default_gateway_ipv6": p.DefaultGatewayIPv6, + "description": p.Description, + "enabled": p.Enabled, + "external_network_ports": flattenExternalNetworkPortFields(p.ExternalNetworkPorts), + "hypervisors": hypervisors, + "ipv4": p.IPv4, + "status": flattenStatus(p.Status), + "version_id": int(p.VersionID), + "subnet_v4": p.SubnetV4, + "subnet_v6": p.SubnetV6, + "created_at": p.CreatedAt, + "updated_at": p.UpdatedAt, + "vlan_tag": p.VLANTag, + "mac": p.MAC, + }) + } + return res +} + +func flattenAppliedNetObjectGroups(groups netobjgroups.AppliedNetObjectGroups) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(groups)) + for _, g := range groups { + res = append(res, map[string]interface{}{ + "id": g.ID, + "name": g.Name, + "version_id": int(g.VersionID), + }) + } + return res +} + +func flattenSecurityRules(rules netobjgroups.SecurityRules) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(rules)) + for _, r := range rules { + srcNetObj := []map[string]interface{}{} + if r.SourceNetObject != nil { + srcNetObj = []map[string]interface{}{ + { + "display_name": r.SourceNetObject.DisplayName, + "net_address_pool_id": r.SourceNetObject.NetAddressPoolID, + "net_object_group_id": r.SourceNetObject.NetObjectGroupID, + }, + } + } + dstNetObj := []map[string]interface{}{} + if r.DestinationNetObject != nil { + dstNetObj = []map[string]interface{}{ + { + "display_name": r.DestinationNetObject.DisplayName, + "net_address_pool_id": r.DestinationNetObject.NetAddressPoolID, + "net_object_group_id": r.DestinationNetObject.NetObjectGroupID, + }, + } + } + filter := []map[string]interface{}{} + if r.Filter != nil { + tcpDstPorts := make([]interface{}, 0, len(r.Filter.Filters.TCPDstPorts)) + for _, p := range r.Filter.Filters.TCPDstPorts { + tcpDstPorts = append(tcpDstPorts, p) + } + udpDstPorts := make([]interface{}, 0, len(r.Filter.Filters.UDPDstPorts)) + for _, p := range r.Filter.Filters.UDPDstPorts { + udpDstPorts = append(udpDstPorts, p) + } + filter = []map[string]interface{}{ + { + "name": r.Filter.Name, + "filters": []map[string]interface{}{ + { + "all": r.Filter.Filters.All, + "arp": r.Filter.Filters.ARP, + "dhcp": r.Filter.Filters.DHCP, + "expression": r.Filter.Filters.Expression, + "icmp": r.Filter.Filters.ICMP, + "ip": r.Filter.Filters.IP, + "ip_v4": r.Filter.Filters.IPv4, + "ip_v6": r.Filter.Filters.IPv6, + "keep_opened_sessions": r.Filter.Filters.KeepOpenedSessions, + "nd": r.Filter.Filters.ND, + "tcp": r.Filter.Filters.TCP, + "tcp_dst_ports": tcpDstPorts, + "udp": r.Filter.Filters.UDP, + "udp_dst_ports": udpDstPorts, + }, + }, + }, + } + } + res = append(res, map[string]interface{}{ + "access_group_id": r.AccessGroupID, + "action": r.Action, + "description": r.Description, + "destination_net_object": dstNetObj, + "direction": r.Direction, + "display_name": r.DisplayName, + "enabled": r.Enabled, + "filter": filter, + "id": r.ID, + "log_enabled": r.LogEnabled, + "log_name": r.LogName, + "log_severity": r.LogSeverity, + "priority": r.Priority, + "security_policy_id": r.SecurityPolicyID, + "source_net_object": srcNetObj, + "statistics_enabled": r.StatisticsEnabled, + "type": r.Type, + "version_id": int(r.VersionID), + }) + } + return res +} + +func flattenSecurityPolicies(policies netobjgroups.SecurityPolicies) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(policies)) + for _, p := range policies { + res = append(res, map[string]interface{}{ + "access_group_id": p.AccessGroupID, + "access_group_name": p.AccessGroupName, + "applied_net_object_groups": flattenAppliedNetObjectGroups(p.AppliedNetObjectGroups), + "created_at": p.CreatedAt, + "description": p.Description, + "display_name": p.DisplayName, + "enabled": p.Enabled, + "end_priority": int(p.EndPriority), + "id": p.ID, + "security_rules": flattenSecurityRules(p.SecurityRules), + "start_priority": int(p.StartPriority), + "status": flattenStatus(p.Status), + "type": p.Type, + "version_id": int(p.VersionID), + "updated_at": p.UpdatedAt, + }) + } + return res +} + +func flattenNetworkObjectGroupList(list *netobjgroups.NetObjGroupList) []map[string]interface{} { + if list == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(list.Objects)) + for _, v := range list.Objects { + res = append(res, map[string]interface{}{ + "id": v.ID, + "name": v.Name, + "access_group_id": v.AccessGroupID, + "access_group_name": v.AccessGroupName, + "description": v.Description, + "type": v.Type, + "purpose": v.Purpose, + "version_id": int(v.VersionID), + "created_at": v.CreatedAt, + "updated_at": v.UpdatedAt, + "addresses": flattenAddresses(v.Addresses), + "counters": flattenCounters(v.Counters), + "l2_connection_ports": flattenL2ConnectionPorts(v.L2ConnectionPorts), + "logical_ports": flattenLogicalPorts(v.LogicalPorts), + "external_network_ports": flattenExternalNetworkPorts(v.ExternalNetworkPorts), + "security_policies": flattenSecurityPolicies(v.SecurityPolicies), + }) + } + return res +} diff --git a/internal/service/sdn/netobjgroups/resource_decort_sdn_network_object_group.go b/internal/service/sdn/netobjgroups/resource_decort_sdn_network_object_group.go new file mode 100644 index 00000000..7ff3a2e8 --- /dev/null +++ b/internal/service/sdn/netobjgroups/resource_decort_sdn_network_object_group.go @@ -0,0 +1,322 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +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 netobjgroups + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func resourceNetworkObjectGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceNetworkObjectGroupCreate: called with name %s", d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + + req := netobjgroups.CreateRequest{ + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + Name: d.Get("name").(string), + } + + if addrRaw, ok := d.GetOk("addresses"); ok { + req.Addresses = buildAddressesRequest(addrRaw.([]interface{})) + } + + if l2Raw, ok := d.GetOk("l2_connection_ports_bindings"); ok { + req.L2ConnectionPortsBindings = buildL2PortsBindingsRequest(l2Raw.([]interface{})) + } + + rec, err := c.SDN().NetworkObjectGroups().Create(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + d.SetId(rec.ID) + + return resourceNetworkObjectGroupRead(ctx, d, m) +} + +func resourceNetworkObjectGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceNetworkObjectGroupRead: called with id %s", d.Id()) + + rec, err := utilityNetworkObjectGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenNetworkObjectGroupResource(d, rec) + d.SetId(rec.ID) + + return nil +} + +func resourceNetworkObjectGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceNetworkObjectGroupUpdate: called with id %s", d.Id()) + + c := m.(*controller.ControllerCfg) + + req := netobjgroups.UpdateRequest{ + ObjectGroupID: d.Id(), + VersionID: uint64(d.Get("version_id").(int)), + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + Name: d.Get("name").(string), + } + + if addrRaw, ok := d.GetOk("addresses"); ok { + req.Addresses = buildAddressesRequest(addrRaw.([]interface{})) + } + + rec, err := c.SDN().NetworkObjectGroups().Update(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(rec.ID) + + return resourceNetworkObjectGroupRead(ctx, d, m) +} + +func resourceNetworkObjectGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceNetworkObjectGroupDelete: called with id %s", d.Id()) + + c := m.(*controller.ControllerCfg) + + req := netobjgroups.DeleteRequest{ + ObjectGroupID: d.Id(), + VersionID: uint64(d.Get("version_id").(int)), + } + + _, err := c.SDN().NetworkObjectGroups().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + return nil +} + +func buildL2PortsBindingsRequest(raw []interface{}) []netobjgroups.LogicalPortsBindings { + result := make([]netobjgroups.LogicalPortsBindings, 0, len(raw)) + for _, item := range raw { + m := item.(map[string]interface{}) + result = append(result, netobjgroups.LogicalPortsBindings{ + PortID: m["port_id"].(string), + PortVersion: uint64(m["port_version"].(int)), + }) + } + return result +} + +func buildAddressesRequest(raw []interface{}) []netobjgroups.NetAddressRequest { + result := make([]netobjgroups.NetAddressRequest, 0, len(raw)) + for _, item := range raw { + addrMap := item.(map[string]interface{}) + addr := netobjgroups.NetAddressRequest{ + NetAddressType: addrMap["net_address_type"].(string), + } + if v, ok := addrMap["ip_addr"].(string); ok && v != "" { + addr.IPAddr = v + } + if v, ok := addrMap["ip_addr_range_end"].(string); ok && v != "" { + addr.IPAddrRangeEnd = v + } + if v, ok := addrMap["ip_prefix"].(string); ok && v != "" { + addr.IPPrefix = v + } + if v, ok := addrMap["mac_addr"].(string); ok && v != "" { + addr.MACAddr = v + } + result = append(result, addr) + } + return result +} + +func resourceNetworkObjectGroupSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "access_group_id": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Required: true, + }, + "addresses": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "net_address_type": { + Type: schema.TypeString, + Required: true, + }, + "ip_addr": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "ip_addr_range_end": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "ip_prefix": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "mac_addr": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + }, + }, + }, + "l2_connection_ports_bindings": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "port_id": { + Type: schema.TypeString, + Required: true, + }, + "port_version": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "purpose": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + "counters": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "addresses_count": { + Type: schema.TypeInt, + Computed: true, + }, + "l2_connection_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "logical_ports_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_policies_count": { + Type: schema.TypeInt, + Computed: true, + }, + "security_rules_count": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "l2_connection_ports": l2ConnectionPortsComputedSchema(), + "logical_ports": logicalPortsComputedSchema(), + "external_network_ports": externalNetworkPortsComputedSchema(), + "security_policies": securityPoliciesComputedSchema(), + } +} + +func ResourceNetworkObjectGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceNetworkObjectGroupCreate, + ReadContext: resourceNetworkObjectGroupRead, + UpdateContext: resourceNetworkObjectGroupUpdate, + DeleteContext: resourceNetworkObjectGroupDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error { + changedKeys := diff.GetChangedKeysPrefix("") + if len(changedKeys) > 0 { + diff.SetNewComputed("version_id") + } + return nil + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout300s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout300s, + Default: &constants.Timeout300s, + }, + + Schema: resourceNetworkObjectGroupSchemaMake(), + } +} diff --git a/internal/service/cloudapi/disks/utility_disk_types_list.go b/internal/service/sdn/netobjgroups/utility_network_object_group.go similarity index 67% rename from internal/service/cloudapi/disks/utility_disk_types_list.go rename to internal/service/sdn/netobjgroups/utility_network_object_group.go index 41183443..8222d0fe 100644 --- a/internal/service/cloudapi/disks/utility_disk_types_list.go +++ b/internal/service/sdn/netobjgroups/utility_network_object_group.go @@ -30,38 +30,31 @@ builds seamlessly. Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki */ -package disks +package netobjgroups 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/decort-golang-sdk/pkg/sdn/netobjgroups" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" ) -func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) { +func utilityNetworkObjectGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*netobjgroups.RecordNetObjGroup, error) { c := m.(*controller.ControllerCfg) - req := disks.ListTypesRequest{ - Detailed: false, + + req := netobjgroups.GetRequest{} + + if d.Id() != "" { + req.NetObjGroupID = d.Id() + } else { + req.NetObjGroupID = d.Get("net_object_group_id").(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("utilityDiskListTypesCheckPresence: load disk list Types Detailed") - typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req) + netObjGroup, err := c.SDN().NetworkObjectGroups().Get(ctx, req) if err != nil { return nil, err } - return typesList, nil + return netObjGroup, nil } diff --git a/internal/service/cloudapi/disks/utility_disk_types_detailed_list.go b/internal/service/sdn/netobjgroups/utility_network_object_group_list.go similarity index 58% rename from internal/service/cloudapi/disks/utility_disk_types_detailed_list.go rename to internal/service/sdn/netobjgroups/utility_network_object_group_list.go index 69665d4e..e9019013 100644 --- a/internal/service/cloudapi/disks/utility_disk_types_detailed_list.go +++ b/internal/service/sdn/netobjgroups/utility_network_object_group_list.go @@ -30,38 +30,58 @@ builds seamlessly. Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki */ -package disks +package netobjgroups 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/decort-golang-sdk/pkg/sdn/netobjgroups" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" ) -func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) { +func utilityNetworkObjectGroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*netobjgroups.NetObjGroupList, error) { c := m.(*controller.ControllerCfg) - req := disks.ListTypesRequest{ - Detailed: true, - } - if sortBy, ok := d.GetOk("sort_by"); ok { - req.SortBy = sortBy.(string) + req := netobjgroups.ListRequest{} + + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + if accessGroupID, ok := d.GetOk("access_group_id"); ok { + req.AccessGroupID = accessGroupID.(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 perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + if updatedFrom, ok := d.GetOk("updated_from"); ok { + req.UpdatedFrom = updatedFrom.(string) + } + if updatedTo, ok := d.GetOk("updated_to"); ok { + req.UpdatedTo = updatedTo.(string) } - log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed") - listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req) + log.Debugf("utilityNetworkObjectGroupListCheckPresence") + list, err := c.SDN().NetworkObjectGroups().List(ctx, req) if err != nil { return nil, err } - return listTypesDetailed, nil + return list, nil } diff --git a/internal/service/sdn/segments/decort_sdn_get_status.go b/internal/service/sdn/segments/decort_sdn_get_status.go deleted file mode 100644 index 4c62333d..00000000 --- a/internal/service/sdn/segments/decort_sdn_get_status.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, - -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 segments - -import ( - "context" - - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceSegmentGetStatusRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - status, err := utilitySegmentGetStatusCheckPresence(ctx, d, m) - if err != nil { - d.SetId("") - return diag.FromErr(err) - } - - if d.Id() == "" { - d.SetId(d.Get("segment_id").(string)) - } - - d.Set("status", status) - return nil -} - -func DataSourceSegmentGetStatus() *schema.Resource { - return &schema.Resource{ - SchemaVersion: 1, - - ReadContext: dataSourceSegmentGetStatusRead, - - Timeouts: &schema.ResourceTimeout{ - Read: &constants.Timeout30s, - Default: &constants.Timeout60s, - }, - Schema: dataSourceSegmentGetStatusSchemaMake(), - } -} diff --git a/internal/service/sdn/segments/flattens.go b/internal/service/sdn/segments/flattens.go index d1181193..13000a3b 100644 --- a/internal/service/sdn/segments/flattens.go +++ b/internal/service/sdn/segments/flattens.go @@ -14,11 +14,13 @@ func flattenSegment(d *schema.ResourceData, segmentRecord *segments.SegmentRespo d.Set("dhcp_v6", flattenDHCPv6(segmentRecord.DHCPv6)) d.Set("display_name", segmentRecord.DisplayName) d.Set("enabled", segmentRecord.Enabled) + d.Set("l2_connection_port", flattenL2ConnectionPort(segmentRecord.L2ConnectionPort)) d.Set("logical_ports_info", flattenEntity(segmentRecord.LogicalPortsInfo)) d.Set("routers_info", flattenEntity(segmentRecord.RoutersInfo)) d.Set("status", flattenStatus(segmentRecord.Status)) d.Set("subnet_v4", segmentRecord.SubnetV4) d.Set("subnet_v6", segmentRecord.SubnetV6) + d.Set("type", segmentRecord.Type) d.Set("updated_at", segmentRecord.UpdatedAt.String()) d.Set("version_id", segmentRecord.VersionID) } @@ -26,8 +28,8 @@ func flattenSegment(d *schema.ResourceData, segmentRecord *segments.SegmentRespo func flattenStatus(s segments.Status) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "common": s.Common, - "hypervisors": flattenHypervisors(s.Hypervisors), + "operation_status": s.OperationStatus, + "hypervisors": flattenHypervisors(s.Hypervisors), } res = append(res, temp) return res @@ -37,7 +39,7 @@ func flattenHypervisors(hv []segments.HypervisorStatus) []map[string]interface{} res := make([]map[string]interface{}, 0, len(hv)) for _, v := range hv { temp := map[string]interface{}{ - "status": v.Status, + "operation_status": v.OperationStatus, "name": v.Name, "display_name": v.DisplayName, "hypervisor_status": v.HypervisorStatus, @@ -90,6 +92,42 @@ func flattenDHCPv6(dchp segments.DHCPv6Config) []map[string]interface{} { return res } +func flattenL2ExternalNetwork(net segments.L2ExternalNetwork) []map[string]interface{} { + return []map[string]interface{}{ + { + "id": net.ID, + "display_name": net.DisplayName, + "description": net.Description, + "bridge_network_name": net.BridgeNetworkName, + "hypervisors": net.Hypervisors, + "vlan_tag": net.VLANTag, + "version_id": net.VersionID, + "created_at": net.CreatedAt.String(), + "created_by": net.CreatedBy, + "updated_at": net.UpdatedAt.String(), + "updated_by": net.UpdatedBy, + }, + } +} + +func flattenL2ConnectionPort(port *segments.L2ConnectionPort) []map[string]interface{} { + if port == nil { + return nil + } + return []map[string]interface{}{ + { + "id": port.ID, + "access_group_id": port.AccessGroupID, + "version_id": port.VersionID, + "created_at": port.CreatedAt.String(), + "created_by": port.CreatedBy, + "updated_at": port.UpdatedAt.String(), + "updated_by": port.UpdatedBy, + "l2_external_network": flattenL2ExternalNetwork(port.L2ExternalNetwork), + }, + } +} + func flattenSegmentList(sl *segments.ListSegment) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(*sl)) for _, v := range *sl { @@ -102,12 +140,14 @@ func flattenSegmentList(sl *segments.ListSegment) []map[string]interface{} { "dhcp_v6": flattenDHCPv6(v.DHCPv6), "display_name": v.DisplayName, "enabled": v.Enabled, + "l2_connection_port": flattenL2ConnectionPort(v.L2ConnectionPort), "logical_ports_info": flattenEntity(v.LogicalPortsInfo), "routers_info": flattenEntity(v.RoutersInfo), "status": flattenStatus(v.Status), "id": v.ID, "subnet_v4": v.SubnetV4, "subnet_v6": v.SubnetV6, + "type": v.Type, "updated_at": v.UpdatedAt.String(), "version_id": v.VersionID, } diff --git a/internal/service/sdn/segments/resource_sdn_segment.go b/internal/service/sdn/segments/resource_sdn_segment.go index 53327f11..e04b4af5 100644 --- a/internal/service/sdn/segments/resource_sdn_segment.go +++ b/internal/service/sdn/segments/resource_sdn_segment.go @@ -61,6 +61,10 @@ func resourceSegmentCreate(ctx context.Context, d *schema.ResourceData, m interf Enabled: d.Get("enabled").(bool), } + if t, ok := d.GetOk("type"); ok { + req.Type = t.(string) + } + if v4ok { req.SubnetV4 = subnetV4.(string) } @@ -192,10 +196,14 @@ func resourceSegmentUpdate(ctx context.Context, d *schema.ResourceData, m interf Enabled: d.Get("enabled").(bool), } - if d.HasChanges("access_group_id", "description", "display_name", "enabled") { + if d.HasChanges("access_group_id", "description", "display_name", "enabled", "type") { needUpdate = true } + if t, ok := d.GetOk("type"); ok { + req.Type = t.(string) + } + if v4ok { req.SubnetV4 = subnetV4.(string) } diff --git a/internal/service/sdn/segments/schema.go b/internal/service/sdn/segments/schema.go index c2794c9c..2174c8a1 100644 --- a/internal/service/sdn/segments/schema.go +++ b/internal/service/sdn/segments/schema.go @@ -5,6 +5,98 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) +func l2ExternalNetworkSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "bridge_network_name": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "vlan_tag": { + Type: schema.TypeInt, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + } +} + +func l2ConnectionPortSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + "l2_external_network": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: l2ExternalNetworkSchema(), + }, + }, + } +} + func dataSourceSegmentSchemaMake() map[string]*schema.Schema { sch := map[string]*schema.Schema{ "segment_id": { @@ -117,6 +209,13 @@ func dataSourceSegmentSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "l2_connection_port": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: l2ConnectionPortSchema(), + }, + }, "logical_ports_info": { Type: schema.TypeList, Computed: true, @@ -154,7 +253,7 @@ func dataSourceSegmentSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -163,7 +262,7 @@ func dataSourceSegmentSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -197,6 +296,10 @@ func dataSourceSegmentSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "type": { + Type: schema.TypeString, + Computed: true, + }, "updated_at": { Type: schema.TypeString, Computed: true, @@ -278,6 +381,12 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "find by updated date", }, + "operation_status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Idle", "SynchronizingAtCore", "SynchronizingAtOVN", "Synchronized", "NoHypervisorAtOVN", "FailedAtCore", "TemporaryFailedAtCore"}, false), + Description: "filter by operation status", + }, "items": { Type: schema.TypeList, Computed: true, @@ -392,6 +501,13 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "l2_connection_port": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: l2ConnectionPortSchema(), + }, + }, "logical_ports_info": { Type: schema.TypeList, Computed: true, @@ -429,7 +545,7 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -438,7 +554,7 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -472,6 +588,10 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "type": { + Type: schema.TypeString, + Computed: true, + }, "updated_at": { Type: schema.TypeString, Computed: true, @@ -492,28 +612,6 @@ func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { return res } -func dataSourceSegmentGetStatusSchemaMake() map[string]*schema.Schema { - res := map[string]*schema.Schema{ - "segment_id": { - Type: schema.TypeString, - Required: true, - }, - "version_id": { - Type: schema.TypeInt, - Optional: true, - }, - "detailed": { - Type: schema.TypeBool, - Optional: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - } - return res -} - func resourceSegmentSchemaMake() map[string]*schema.Schema { res := map[string]*schema.Schema{ "access_group_id": { @@ -646,6 +744,13 @@ func resourceSegmentSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "l2_connection_port": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: l2ConnectionPortSchema(), + }, + }, "logical_ports_info": { Type: schema.TypeList, Computed: true, @@ -683,7 +788,7 @@ func resourceSegmentSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "common": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -692,7 +797,7 @@ func resourceSegmentSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { + "operation_status": { Type: schema.TypeString, Computed: true, }, @@ -718,6 +823,11 @@ func resourceSegmentSchemaMake() map[string]*schema.Schema { }, }, }, + "type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "updated_at": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/sdn/segments/utility_segment_get_status.go b/internal/service/sdn/segments/utility_segment_get_status.go deleted file mode 100644 index 85b5f334..00000000 --- a/internal/service/sdn/segments/utility_segment_get_status.go +++ /dev/null @@ -1,36 +0,0 @@ -package segments - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" -) - -func utilitySegmentGetStatusCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) { - c := m.(*controller.ControllerCfg) - - req := segments.GetStatusRequest{} - - if d.Id() != "" { - req.SegmentID = d.Id() - } else { - req.SegmentID = d.Get("segment_id").(string) - } - - if version, ok := d.GetOk("version"); ok { - req.VersionID = uint64(version.(int)) - } - - if detailed, ok := d.GetOk("detailed"); ok { - req.Detailed = detailed.(bool) - } - - segment, err := c.SDN().Segments().GetStatus(ctx, req) - if err != nil { - return "", err - } - - return segment, nil -} diff --git a/internal/service/sdn/segments/utility_segment_list.go b/internal/service/sdn/segments/utility_segment_list.go index 52c8ef93..9265afdc 100644 --- a/internal/service/sdn/segments/utility_segment_list.go +++ b/internal/service/sdn/segments/utility_segment_list.go @@ -29,7 +29,7 @@ func utilitySegmentListCheckPresence(ctx context.Context, d *schema.ResourceData req.Enabled = enabled.(bool) } if isSynced, ok := d.GetOk("is_synced"); ok { - req.Enabled = isSynced.(bool) + req.IsSynced = isSynced.(bool) } if displayName, ok := d.GetOk("display_name"); ok { req.DisplayName = displayName.(string) @@ -47,11 +47,14 @@ func utilitySegmentListCheckPresence(ctx context.Context, d *schema.ResourceData req.CreatedTo = createdTo.(string) } if updatedFrom, ok := d.GetOk("updated_from"); ok { - req.UpdatedTo = updatedFrom.(string) + req.UpdatedFrom = updatedFrom.(string) } if updatedTo, ok := d.GetOk("updated_to"); ok { req.UpdatedTo = updatedTo.(string) } + if operationStatus, ok := d.GetOk("operation_status"); ok { + req.OperationStatus = operationStatus.(string) + } log.Debugf("utilitySegmentListCheckPresence") segmentList, err := c.SDN().Segments().List(ctx, req) diff --git a/samples/README.md b/samples/README.md index 3de8b26c..5112faa3 100644 --- a/samples/README.md +++ b/samples/README.md @@ -293,6 +293,7 @@ - cb_vins - cb_vins_static_route - cb_virtual_image + - decort_cb_multi_image - cb_zone - sdn - data: @@ -301,15 +302,20 @@ - sdn_access_group_user_list - sdn_default_security_policy_list - sdn_segment - - sdn_segment_get_status - sdn_segment_list - sdn_logical_port - sdn_logical_port_get_by_unique_identifier - sdn_logical_port_list + - sdn_hypervisor + - sdn_hypervisor_list + - sdn_network_object_group + - sdn_network_object_group_list - resources: - sdn_access_group - sdn_segment - sdn_logical_port + - sdn_hypervisor + - sdn_network_object_group ## Как пользоваться примерами diff --git a/samples/cloudapi/disk/data_disk_list/main.tf b/samples/cloudapi/disk/data_disk_list/main.tf index 6045fdbf..13254d0e 100644 --- a/samples/cloudapi/disk/data_disk_list/main.tf +++ b/samples/cloudapi/disk/data_disk_list/main.tf @@ -62,12 +62,6 @@ data "decort_disk_list" "dl" { #тип - целое число #account_id = 11111 - #тип диска - #опциональный параметр - #тип - строка - #возможные типы: "B" - boot_disk, "D" - data_disk - #type = "D" - #id SEP для получения списка дисков #опциональный параметр #тип - целое число @@ -98,6 +92,16 @@ data "decort_disk_list" "dl" { #опциональный параметр #тип - целое число #storage_policy_id = 1 + + #фильтр по id ресурсной группы + #опциональный параметр + #тип - целое число + #rg_id = 1281 + + #фильтр по id ВМ + #опциональный параметр + #тип - целое число + #compute_id = 123 } output "test" { diff --git a/samples/cloudapi/disk/data_disk_list_deleted/main.tf b/samples/cloudapi/disk/data_disk_list_deleted/main.tf index c70eafe5..40132734 100644 --- a/samples/cloudapi/disk/data_disk_list_deleted/main.tf +++ b/samples/cloudapi/disk/data_disk_list_deleted/main.tf @@ -58,12 +58,6 @@ data "decort_disk_list_deleted" "dld" { #тип - целое число #account_id = 11111 - #тип диска - #опциональный параметр - #тип - строка - #возможные типы: "b" - boot_disk, "d" - data_disk - #type = "d" - #сортировка по одному из поддерживаемых полей #опциональный параметр #тип - строка diff --git a/samples/cloudapi/disk/data_disk_list_types/main.tf b/samples/cloudapi/disk/data_disk_list_types/main.tf deleted file mode 100644 index 5134e1a3..00000000 --- a/samples/cloudapi/disk/data_disk_list_types/main.tf +++ /dev/null @@ -1,51 +0,0 @@ -/* -Пример использования -Получение списка типов дисков -*/ - -#Раскомментируйте этот код, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ - -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - -data "decort_disk_list_types" "dlt" { - #сортировка по одному из поддерживаемых полей - #опциональный параметр - #тип - строка - #формат - "+поле" по возрастанию / "-поле" по убыванию - #sort_by = "+name" - - #номер страницы для отображения - #опциональный параметр - #тип - целое число - #если не задан - выводятся все доступные данные - #page = 2 - - #размер страницы - #опциональный параметр - #тип - целое число - #если не задан - выводятся все доступные данные - #size = 3 -} - -output "test" { - value = data.decort_disk_list_types.dlt -} diff --git a/samples/cloudapi/disk/data_disk_list_types_detailed/main.tf b/samples/cloudapi/disk/data_disk_list_types_detailed/main.tf deleted file mode 100644 index 5b32509c..00000000 --- a/samples/cloudapi/disk/data_disk_list_types_detailed/main.tf +++ /dev/null @@ -1,52 +0,0 @@ -/* -Пример использования -Получение списка типов дисков, но детально -*/ - -#Раскомментируйте этот код, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ - -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - - -data "decort_disk_list_types_detailed" "dltd" { - #сортировка по одному из поддерживаемых полей - #опциональный параметр - #тип - строка - #формат - "+поле" по возрастанию / "-поле" по убыванию - #sort_by = "+name" - - #номер страницы для отображения - #опциональный параметр - #тип - целое число - #если не задан - выводятся все доступные данные - #page = 2 - - #размер страницы - #опциональный параметр - #тип - целое число - #если не задан - выводятся все доступные данные - #size = 3 -} - -output "test" { - value = data.decort_disk_list_types_detailed.dltd -} diff --git a/samples/cloudapi/disk/data_disk_list_unattached/main.tf b/samples/cloudapi/disk/data_disk_list_unattached/main.tf index b56048c3..5c454066 100644 --- a/samples/cloudapi/disk/data_disk_list_unattached/main.tf +++ b/samples/cloudapi/disk/data_disk_list_unattached/main.tf @@ -49,12 +49,6 @@ data "decort_disk_list_unattached" "dlu" { #тип - строка #status = "ENABLED" - #фильтр по типу - #опциональный параметр - #тип - строка - #возможные типы: "b" - boot_disk, "d" - data_disk - #type = "d" - #фильтр по id аккаунта #опциональный параметр #тип - целое число diff --git a/samples/cloudapi/image/resource_image_from_blank_compute/main.tf b/samples/cloudapi/image/resource_image_from_blank_compute/main.tf index ac8083c7..82319c44 100644 --- a/samples/cloudapi/image/resource_image_from_blank_compute/main.tf +++ b/samples/cloudapi/image/resource_image_from_blank_compute/main.tf @@ -53,6 +53,12 @@ resource "decort_image_from_blank_compute" "img" { #используется при создании type = "linux" + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #юзернейм для образа #опциональный параметр #тип - строка diff --git a/samples/cloudapi/image/resource_image_from_platform_disk/main.tf b/samples/cloudapi/image/resource_image_from_platform_disk/main.tf index 96435e63..a6422b73 100644 --- a/samples/cloudapi/image/resource_image_from_platform_disk/main.tf +++ b/samples/cloudapi/image/resource_image_from_platform_disk/main.tf @@ -55,10 +55,10 @@ resource "decort_image_from_platform_disk" "img" { type = "linux" #драйверы компьютов, подходящие для данного образа - #обязательный параметр + #опциональный параметр #тип - массив строк #используется при создании - drivers = ["KVM_X86"] + #drivers = ["KVM_X86"] #имя пользователя для образа #опциональный параметр diff --git a/samples/cloudapi/kvmvm/resource_kvmvm/main.tf b/samples/cloudapi/kvmvm/resource_kvmvm/main.tf index 8329b04a..d4ae931b 100644 --- a/samples/cloudapi/kvmvm/resource_kvmvm/main.tf +++ b/samples/cloudapi/kvmvm/resource_kvmvm/main.tf @@ -112,6 +112,12 @@ resource "decort_kvmvm" "comp" { #используется при создании #without_boot_disk = true + #создание без образа ОС + #опциональный параметр + #тип - булев + #используется при создании + #create_blank = false + #необходимость выравнивать ВМ по NUMA #опциональный параметр #возможные значения - "none, "strict", "loose" @@ -120,6 +126,12 @@ resource "decort_kvmvm" "comp" { #используется при создании и обновлении #numa_affinity = "loose" + #id образа CD-ROM для загрузки + #опциональный параметр + #тип - целое число + #используется при создании и обновлении + #alt_boot_id = 1 + #необходимость запускать ВМ на выделенных CPU ядрах #опциональный параметр #по умолчанию - false @@ -160,11 +172,6 @@ resource "decort_kvmvm" "comp" { #тип - целое число #size = 5 - #тип диска - #опциональный параметр - #тип - строка - #disk_type = "D" - #id сепа #опциональный параметр #тип - целое число @@ -228,7 +235,7 @@ resource "decort_kvmvm" "comp" { #тип - строка #policy = "RECOMMENDED" - #режим проверки + #режим проверки #обязательный параметр #возможные значения - ANY, EQ, NE #тип - строка @@ -263,7 +270,7 @@ resource "decort_kvmvm" "comp" { #тип - строка #policy = "RECOMMENDED" - #режим проверки + #режим проверки #обязательный параметр #возможные значения - ANY, EQ, NE #тип - строка @@ -287,20 +294,6 @@ resource "decort_kvmvm" "comp" { #affinity_label = "test4" - #наименование системы - #опциональный параметр - #по умолчанию - не задан - #тип - строка - #используется при создании - #is = "" - - #назначение вм - #опциональный параметр - #по умолчанию - не задан - #тип - строка - #используется при создании - #ipa_type = "" - #id экстра дисков #опциональный параметр #тип - список целых чисел @@ -342,8 +335,8 @@ resource "decort_kvmvm" "comp" { #weight = 15 #максимальный объём данных, который может быть передан за одну итерацию - #используется только с сетями типа "DPDK" и "EXTNET" - #возможные значения - 1-9216 + #используется с сетями типа "DPDK", "TRUNK", "EXTNET" + #возможные значения - 1500-9216 #опциональный параметр #тип - целое число #mtu = 1500 @@ -365,18 +358,19 @@ resource "decort_kvmvm" "comp" { #используется только с сетями типа "DPDK" и "VFNIC" #опциональный параметр #тип - целое число - #net_mask = 32 + #net_mask = 32 #} #группы безопасности #опциональный параметр #тип - блок + #не применяется к сетям типа "VFNIC", "TRUNK", "SDN" #используется при создании и обновлении #security_groups { #тип сети #обязательный параметр #тип - строка - #возможные значения - "VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK" (при выборе типа DPDK, необходимо указать hp_backed = true) + #возможные значения - "VINS", "EXTNET", "DPDK" (при выборе типа DPDK, необходимо указать hp_backed = true) #net_type = "VINS" #id сети @@ -598,17 +592,17 @@ resource "decort_kvmvm" "comp" { #используется при создании и обновлении #network_interface_naming = "ens" - #идентификатор экземпляра zone + #идентификатор экземпляра zone #опциональный параметр - #тип - целое число + #тип - целое число #используется при создании и обновлении #zone_id = 1111 #версия ОС, установленная на ВМ - #опциональный параметр + #опциональный параметр #тип - строка #используется при создании и обновлении - #os_version = "name" + #os_version = "name" } output "test" { diff --git a/samples/cloudapi/vins/resource_vins/main.tf b/samples/cloudapi/vins/resource_vins/main.tf index 75cf99e5..a0c375b9 100644 --- a/samples/cloudapi/vins/resource_vins/main.tf +++ b/samples/cloudapi/vins/resource_vins/main.tf @@ -188,12 +188,19 @@ resource "decort_vins" "vins" { #используется при создании и обновлении #dns = ["1.1.1.1", "2.2.2.2"] - #идентификатор экземпляра zone + #идентификатор экземпляра zone #опциональный параметр - #тип - целое число + #тип - целое число #используется при создании и обновлении #zone_id = 1111 + #флаг, указывающий, включены ли группы безопасности для этой сети + #опциональный параметр + #тип - булев + #используется при создании + #значение по умолчанию - false + #enable_secgroups = false + } output "test" { diff --git a/samples/cloudbroker/disk/data_disk_list/main.tf b/samples/cloudbroker/disk/data_disk_list/main.tf index e70b3ec9..c0817e50 100644 --- a/samples/cloudbroker/disk/data_disk_list/main.tf +++ b/samples/cloudbroker/disk/data_disk_list/main.tf @@ -62,12 +62,6 @@ data "decort_cb_disk_list" "dl" { #тип - целое число #account_id = 11111 - #тип диска - #опциональный параметр - #тип - строка - #возможные типы: "b" - boot_disk, "d" - data_disk - #type = "d" - #фильтр по sep id #опциональный параметр #тип - целое число @@ -99,6 +93,15 @@ data "decort_cb_disk_list" "dl" { #тип - целое число #storage_policy_id = 1 + #фильтр по id ресурсной группы + #опциональный параметр + #тип - целое число + #rg_id = 1281 + + #фильтр по id ВМ + #опциональный параметр + #тип - целое число + #compute_id = 123 } output "test" { diff --git a/samples/cloudbroker/disk/data_disk_list_deleted/main.tf b/samples/cloudbroker/disk/data_disk_list_deleted/main.tf index 25060c63..da447141 100644 --- a/samples/cloudbroker/disk/data_disk_list_deleted/main.tf +++ b/samples/cloudbroker/disk/data_disk_list_deleted/main.tf @@ -57,12 +57,6 @@ data "decort_cb_disk_list_deleted" "dld" { #тип - целое число #account_id = 11111 - #тип диска - #опциональный параметр - #возможные типы: "b" - boot_disk, "d" - data_disk - #тип - строка - #type = "d" - #сортировка по одному из поддерживаемых полей #опциональный параметр #формат - "+поле" по возрастанию / "-поле" по убыванию diff --git a/samples/cloudbroker/disk/data_disk_list_types/main.tf b/samples/cloudbroker/disk/data_disk_list_types/main.tf deleted file mode 100644 index 41a34fb8..00000000 --- a/samples/cloudbroker/disk/data_disk_list_types/main.tf +++ /dev/null @@ -1,52 +0,0 @@ -/* -Пример использования -Получение списка типов дисков (недетализированное) -*/ - -#Раскомментируйте этот код, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ - -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - -data "decort_cb_disk_list_types" "dlt" { - #сортировка по одному из поддерживаемых полей - #опциональный параметр - #формат - "+поле" по возрастанию / "-поле" по убыванию - #тип - строка - #sort_by = "+name" - - #номер страницы для отображения - #опциональный параметр - #если не задан - выводятся все доступные данные - #тип - целое число - #page = 2 - - #размер страницы - #опциональный параметр - #если не задан - выводятся все доступные данные - #тип - целое число - #size = 3 - -} - -output "test" { - value = data.decort_cb_disk_list_types.dlt -} diff --git a/samples/cloudbroker/disk/data_disk_list_types_detailed/main.tf b/samples/cloudbroker/disk/data_disk_list_types_detailed/main.tf deleted file mode 100644 index d366a178..00000000 --- a/samples/cloudbroker/disk/data_disk_list_types_detailed/main.tf +++ /dev/null @@ -1,52 +0,0 @@ -/* -Пример использования -Получение списка типов дисков, но детально -*/ - -#Раскомментируйте этот код, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ - -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - -data "decort_cb_disk_list_types_detailed" "dltd" { - #сортировка по одному из поддерживаемых полей - #опциональный параметр - #формат - "+поле" по возрастанию / "-поле" по убыванию - #тип - строка - #sort_by = "+name" - - #номер страницы для отображения - #опциональный параметр - #если не задан - выводятся все доступные данные - #тип - целое число - #page = 2 - - #размер страницы - #опциональный параметр - #если не задан - выводятся все доступные данные - #тип - целое число - #size = 3 - -} - -output "test" { - value = data.decort_cb_disk_list_types_detailed.dltd -} diff --git a/samples/cloudbroker/disk/data_disk_list_unattached/main.tf b/samples/cloudbroker/disk/data_disk_list_unattached/main.tf index 4c0d15dc..7b55b218 100644 --- a/samples/cloudbroker/disk/data_disk_list_unattached/main.tf +++ b/samples/cloudbroker/disk/data_disk_list_unattached/main.tf @@ -47,12 +47,6 @@ data "decort_cb_disk_list_unattached" "dlu" { #тип - строка #status = "ENABLED" - #фильтр по типу - #опциональный параметр - #тип - строка - #возможные типы: "b" - boot_disk, "d" - data_disk - #type = "d" - #фильтр по id аккаунта #опциональный параметр #тип - целое число diff --git a/samples/cloudbroker/disk/resource_disk/main.tf b/samples/cloudbroker/disk/resource_disk/main.tf index 5dd84e60..491bb8eb 100644 --- a/samples/cloudbroker/disk/resource_disk/main.tf +++ b/samples/cloudbroker/disk/resource_disk/main.tf @@ -138,6 +138,13 @@ resource "decort_cb_disk" "my_disk01" { #по умолчанию - false #используется при создании и обновлении #blk_discard = false + + #размер блока диска + #опциональный параметр + #доступные значения - "4k", "512", "512e" + #тип - строка + #используется при создании и обновлении + #block_size = "4k" } output "test" { diff --git a/samples/cloudbroker/image/resource_image_cdrom/main.tf b/samples/cloudbroker/image/resource_image_cdrom/main.tf index d1a46e45..06ca1f32 100644 --- a/samples/cloudbroker/image/resource_image_cdrom/main.tf +++ b/samples/cloudbroker/image/resource_image_cdrom/main.tf @@ -80,13 +80,6 @@ resource "decort_cb_cdrom_image" "my_image" { #используется при создании #pool_name = "vmstor" - #архитектура системы образа - #опциональный параметр - #тип - строка - #доступные значения: "X86_64" - #используется при создании - #architecture = "X86_64" - #доступность образа #опциональный параметр #тип - булев diff --git a/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf b/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf index 7f900d99..5da83a28 100644 --- a/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf +++ b/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf @@ -56,6 +56,12 @@ resource "decort_cb_image_from_blank_compute" "my_image" { #используется при создании image_type = "linux" + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #имя пользователя для образа #опциональный параметр #тип - строка diff --git a/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf b/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf index f0901b74..d882cd2d 100644 --- a/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf +++ b/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf @@ -56,7 +56,6 @@ resource "decort_cb_image_from_platform_disk" "my_image" { #используется при создании image_type = "linux" - #имя пользователя для образа #опциональный параметр #тип - строка diff --git a/samples/cloudbroker/image/resource_multi_image/main.tf b/samples/cloudbroker/image/resource_multi_image/main.tf new file mode 100644 index 00000000..53c858d6 --- /dev/null +++ b/samples/cloudbroker/image/resource_multi_image/main.tf @@ -0,0 +1,100 @@ +/* +Пример использования +Ресурса multi image +Ресурс позволяет: +1. Создавать образ +2. Редактировать образ +3. Удалять образ +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_cb_multi_image" "my_multi_image" { + #имя мульти-образа + #обязательный параметр + #тип - строка + #используется при создании и обновлении + name = "test_multi_image" + + #список id реальных образов, на основе которых создаётся мульти-образ + #обязательный параметр + #тип - массив целых чисел + #используется при создании и обновлении (добавляет/удаляет привязки) + target_ids = [6125, 6126] + + #id аккаунта владельца образа + #опциональный параметр + #тип данных - целое число + #используется при создании и обновлении + #account_id = 57252 + + #является ли образ загрузочным + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #bootable = true + + #поддержка hot resize + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #hot_resize = true + + #имя пользователя + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #username = "Valera" + + #пароль пользователя + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #password = "123" + + #доступность образа + #опциональный параметр + #тип - булев, по умолчанию true + #используется при создании и обновлении + #enabled = false + + #настройка доступа образа аккаунтам + #опциональный параметр + #пустой массив - удаление всех доступов, если они были + #тип - массив целых чисел + #используется при создании и обновлении + #shared_with = [28096, 57121] + + #установка computeci + #опциональный параметр + #чтобы сбросить, необходимо передать 0 + #тип - целое число + #используется при создании и обновлении + #computeci_id = 1 + +} + +output "test" { + value = decort_cb_multi_image.my_multi_image +} diff --git a/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf b/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf index b700dae4..c5ef1d8d 100644 --- a/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf +++ b/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf @@ -83,6 +83,12 @@ resource "decort_cb_kvmvm" "comp" { #используется при создании #without_boot_disk = true + #создание без образа ОС + #опциональный параметр + #тип - булев + #используется при создании + #create_blank = false + #размер загрузочного диска #опциональный параметр #тип - целое число @@ -130,7 +136,7 @@ resource "decort_cb_kvmvm" "comp" { #id образа CD-ROM для загрузки #опциональный параметр #тип - целое число - #используется при обновлении, при повторном старте вм + #используется при создании и обновлении #alt_boot_id = 1 #необходимость выравнивать ВМ по NUMA @@ -191,11 +197,7 @@ resource "decort_cb_kvmvm" "comp" { #возможные варианты: "none" или "writethrough" #cache = "none" - #тип диска - #опциональный параметр - #тип - строка - #disk_type = "D" - + #опциональный параметр #тип - целое число #sep_id = 1 @@ -230,23 +232,31 @@ resource "decort_cb_kvmvm" "comp" { #по умолчанию - false #blk_discard = false - #блок для управления IO-лимитами диска + #размер блока диска + #опциональный параметр + #тип - строка + #возможные варианты: "512", "512e", "4k" + #block_size = "4k" + + #настройки лимитов операций ввода/вывода диска #опциональный параметр #тип - блок + #тип вложенных полей - целое число + #используется при создании и обновлении #iotune { - #read_bytes_sec = 0 - #read_bytes_sec_max = 0 - #read_iops_sec = 0 - #read_iops_sec_max = 0 - #size_iops_sec = 0 - #total_bytes_sec = 0 + #read_bytes_sec = 0 + #read_bytes_sec_max = 0 + #read_iops_sec = 0 + #read_iops_sec_max = 0 + #size_iops_sec = 0 + #total_bytes_sec = 0 #total_bytes_sec_max = 0 - #total_iops_sec = 3000 - #total_iops_sec_max = 0 - #write_bytes_sec = 0 + #total_iops_sec = 3000 + #total_iops_sec_max = 0 + #write_bytes_sec = 0 #write_bytes_sec_max = 0 - #write_iops_sec = 0 - #write_iops_sec_max = 0 + #write_iops_sec = 0 + #write_iops_sec_max = 0 #} #} @@ -326,20 +336,6 @@ resource "decort_cb_kvmvm" "comp" { #используется при создании и обновлении #affinity_label = "test4" - #наименование системы - #опциональный параметр - #по умолчанию - не задан - #тип - строка - #используется при создании - #is = "" - - #назначение вм - #опциональный параметр - #по умолчанию - не задан - #тип - строка - #используется при создании - #ipa_type = "" - #id экстра дисков #опциональный параметр #тип - список чисел @@ -387,8 +383,8 @@ resource "decort_cb_kvmvm" "comp" { #weight = 15 #максимальный объём данных, который может быть передан за одну итерацию - #используется только с сетями типа "DPDK" и "EXTNET" - #возможные значения - 1-9216 + #используется с сетями типа "DPDK", "TRUNK", "EXTNET" + #возможные значения - 1500-9216 #опциональный параметр #тип - целое число #mtu = 1500 @@ -416,12 +412,13 @@ resource "decort_cb_kvmvm" "comp" { #группы безопасности #опциональный параметр #тип - блок + #не применяется к сетям типа "VFNIC", "TRUNK", "SDN" #используется при создании и обновлении #security_groups { #тип сети #обязательный параметр #тип - строка - #возможные значения - "VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK" (при выборе типа DPDK, необходимо указать hp_backed = true) + #возможные значения - "VINS", "EXTNET", "DPDK" (при выборе типа DPDK, необходимо указать hp_backed = true) #net_type = "VINS" #id сети @@ -714,11 +711,17 @@ resource "decort_cb_kvmvm" "comp" { #zone_id = 1111 #версия ОС, установленная на ВМ - #опциональный параметр + #опциональный параметр #тип - строка #используется при создании и обновлении #os_version = "name" + #вес ВМ + #опциональный параметр + #тип - целое число + #используется при создании и обновлении + #weight = 1 + #включение режима unmap для boot диска #опциональный параметр #тип - булев diff --git a/samples/cloudbroker/node/data_node_list/main.tf b/samples/cloudbroker/node/data_node_list/main.tf index 4f711d08..a195b805 100644 --- a/samples/cloudbroker/node/data_node_list/main.tf +++ b/samples/cloudbroker/node/data_node_list/main.tf @@ -62,6 +62,12 @@ data "decort_cb_node_list" "nodes" { #тип - строка #status = "disabled" + #фильтр по id зоны + #опциональный параметр + #значение по умолчанию - 0 + #тип - целое число + #zone_id = 54 + #сортировка по одному из поддерживаемых полей #опциональный параметр #тип - строка diff --git a/samples/cloudbroker/zone/resource_zone/main.tf b/samples/cloudbroker/zone/resource_zone/main.tf index e38b7b0e..2ec44467 100644 --- a/samples/cloudbroker/zone/resource_zone/main.tf +++ b/samples/cloudbroker/zone/resource_zone/main.tf @@ -56,11 +56,15 @@ resource "decort_cb_zone" "zone" { #по умолчанию - false #используется при создании и обновлении #auto_start = false + + #включение/отключение drs + #опциональный параметр + #тип - булев + #значение по умолчанию - false + #используется при создании + #drs = false } output "test" { value = decort_cb_zone.zone } - - - diff --git a/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf b/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf index bc837d48..f43107c0 100644 --- a/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf +++ b/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf @@ -65,15 +65,18 @@ data "decort_sdn_access_group_list" "name" { #фильтр по нижней границе даты создания #опциональный параметр - #тип - строка - #значение по умолчанию - null + #тип - строка #created_from = "2023-01-01T00:00:00Z" #фильтр по верхней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_to = "2023-01-01T00:00:00Z" + + #фильтр по отображаемому имени владельца группы доступа + #опциональный параметр + #тип - строка + #owner_display_name = "owner_name" } output "test" { diff --git a/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf b/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf index d23d69e0..6b03dd38 100644 --- a/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf +++ b/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf @@ -106,13 +106,11 @@ data "decort_sdn_access_group_user_list" "name" { #фильтр по нижней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_from = "2023-01-01T00:00:00Z" #фильтр по верхней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_to = "2023-01-01T00:00:00Z" } diff --git a/samples/sdn/segments/data_segment_get_status/main.tf b/samples/sdn/hypervisors/data_decort_sdn_hypervisor/main.tf similarity index 61% rename from samples/sdn/segments/data_segment_get_status/main.tf rename to samples/sdn/hypervisors/data_decort_sdn_hypervisor/main.tf index 60f87607..a27dca98 100644 --- a/samples/sdn/segments/data_segment_get_status/main.tf +++ b/samples/sdn/hypervisors/data_decort_sdn_hypervisor/main.tf @@ -1,48 +1,44 @@ -/* -Пример использования -Получение информации о статусе segment по ее id -*/ - -#Расскомментируйте этот код, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - -data "decort_sdn_segment_get_status" "name" { - #идентификатор сегмента - #обязательный параметр - #тип - строка - segment_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" - - #идентификатор версии - #опциональный параметр - #тип - целое число - #version_id = 378849 - - #подробный статус - #опциональный параметр - #тип - булев - #detailed = true -} - -output "test" { - value = data.decort_sdn_segment_get_status.name -} - +/* +Пример использования +Получение информации о hypervisor по его id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_hypervisor" "test" { + #имя гипервизора + #обязательный параметр + #тип - строка + name = "name" + + #объем информации + #опциональный параметр + #тип - строка + #возможные значения - detailed, general + #port_info = "detailed" +} + +output "test" { + value = data.decort_sdn_hypervisor.test +} \ No newline at end of file diff --git a/samples/sdn/hypervisors/data_decort_sdn_hypervisor_list/main.tf b/samples/sdn/hypervisors/data_decort_sdn_hypervisor_list/main.tf new file mode 100644 index 00000000..db9e7dd1 --- /dev/null +++ b/samples/sdn/hypervisors/data_decort_sdn_hypervisor_list/main.tf @@ -0,0 +1,96 @@ +/* +Пример использования +Получение информации о списке гипервизоров +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_hypervisor_list" "test" { + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - name, hostname, last_sync, display_name, ip, created_at, updated_at + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" + + #объем информации + #опциональный параметр + #тип - строка + #возможные значения - detailed, general + #port_info = "detailed" + + #хостнейм + #опциональный параметр + #тип - строка + #hostname = "hostname" + + #фильтр по отображаемому имени + #опциональный параметр + #тип - строка + #display_name = "name" + + #IP + #опциональный параметр + #тип - строка + #ip = "192.168. 123.132" + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #created_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #created_to = "2023-01-01T00:00:00Z" + + #фильтр по нижней границе даты обновления + #опциональный параметр + #тип - строка + #updated_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты обновления + #опциональный параметр + #тип - строка + #updated_to = "2023-01-01T00:00:00Z" +} + +output "test" { + value = data.decort_sdn_hypervisor_list.test +} diff --git a/samples/sdn/hypervisors/resource_hypervisor/main.tf b/samples/sdn/hypervisors/resource_hypervisor/main.tf new file mode 100644 index 00000000..aca52273 --- /dev/null +++ b/samples/sdn/hypervisors/resource_hypervisor/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования ресурса гипервизора +Ресурс позволяет: +1. Редактировать гипервизор +2. Удалять гипервизор +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +resource "decort_sdn_hypervisor" "test" { + #имя гипервизора (текущее) + #обязательный параметр + #тип - строка + #используется при обновлении + name = "name" + + #отображаемое имя гипервизора (новое) + #обязательный параметр + #тип - строка + #используется при обновлении + display_name = "name" +} + +output "test" { + value = decort_sdn_hypervisor.test +} diff --git a/samples/sdn/logicalports/data_logical_port_list/main.tf b/samples/sdn/logicalports/data_logical_port_list/main.tf index 273e8032..3d8553fa 100644 --- a/samples/sdn/logicalports/data_logical_port_list/main.tf +++ b/samples/sdn/logicalports/data_logical_port_list/main.tf @@ -92,16 +92,24 @@ data "decort_sdn_logical_port_list" "test" { #тип - булев #enabled = false + #фильтр по статусу операции + #опциональный параметр + #тип - строка + #operation_status = "Synchronized" + + #фильтр по статусу гипервизора + #опциональный параметр + #тип - строка + #hypervisor_status = "Warning" + #фильтр по нижней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_from = "2023-01-01T00:00:00Z" #фильтр по верхней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_to = "2023-01-01T00:00:00Z" #номер страницы результата diff --git a/samples/sdn/logicalports/resource_logical_port/main.tf b/samples/sdn/logicalports/resource_logical_port/main.tf index f19b1cfb..f3f1fb71 100644 --- a/samples/sdn/logicalports/resource_logical_port/main.tf +++ b/samples/sdn/logicalports/resource_logical_port/main.tf @@ -55,12 +55,6 @@ resource "decort_sdn_logical_port" "test" { #используется при создании и обновлении enabled = true - #исключение порта из правил фаервола - #обязательный параметр - #тип - булев - #используется при создании и обновлении - is_excluded_from_firewall = true - #связанный гипервизор #обязательный параметр #тип - строка @@ -88,7 +82,6 @@ resource "decort_sdn_logical_port" "test" { #уникальный идентификатор порта #опциональный параметр #тип - строка - #значение по умолчанию - null #используется при создании #unique_identifier = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" @@ -123,14 +116,35 @@ resource "decort_sdn_logical_port" "test" { #MAC адрес #опциональный параметр #тип - строка - #значение по умолчанию - null #mac = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$" #} + #метки + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #labels { + # #идентификатор виртуальной машины + # #опциональный параметр + # #тип - строка + # #vm_id = "vmid-420" + + # #имя виртуальной машины + # #опциональный параметр + # #тип - строка + # #vm_name = "my-vm" + #} + + #флаг инициации миграции на гипервизор из поля hypervisor + #опциональный параметр + #тип - булев + #значение по умолчанию - false + #используется при обновлении + #migrate = true + #флаг принудительного удаления #опциональный параметр #тип - булев - #значение по умолчанию - null #используется при обновлении #force = true } diff --git a/samples/cloudapi/vgpu/data_vgpu/main.tf b/samples/sdn/netobjgroups/data_decort_sdn_network_object_group/main.tf similarity index 56% rename from samples/cloudapi/vgpu/data_vgpu/main.tf rename to samples/sdn/netobjgroups/data_decort_sdn_network_object_group/main.tf index dfe40fc9..014a5d4a 100644 --- a/samples/cloudapi/vgpu/data_vgpu/main.tf +++ b/samples/sdn/netobjgroups/data_decort_sdn_network_object_group/main.tf @@ -1,39 +1,37 @@ -/* -Пример использования -Получение данных vgpu -*/ - -#Раскомментируйте код ниже, -#и внесите необходимые правки в версию и путь, -#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером -/* -terraform { - required_providers { - decort = { - source = "basis/decort/decort" - version = "" - } - } -} -*/ - -provider "decort" { - authenticator = "decs3o" - #controller_url = - controller_url = "https://ds1.digitalenergy.online" - #oauth2_url = - oauth2_url = "https://sso.digitalenergy.online" - allow_unverified_ssl = true -} - -data "decort_vgpu" "vgpu" { - #id vgpu - #обязательный параметр - #тип - целое число - vgpu_id = 1111 - -} - -output "test" { - value = data.decort_vgpu.vgpu -} +/* +Пример использования +Получение информации о группе сетевых объектов по её id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_network_object_group" "name" { + #идентификатор группы сетевых объектов + #обязательный параметр + #тип - строка + net_object_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" +} + +output "test" { + value = data.decort_sdn_network_object_group.name +} diff --git a/samples/sdn/netobjgroups/data_decort_sdn_network_object_group_list/main.tf b/samples/sdn/netobjgroups/data_decort_sdn_network_object_group_list/main.tf new file mode 100644 index 00000000..da8f2539 --- /dev/null +++ b/samples/sdn/netobjgroups/data_decort_sdn_network_object_group_list/main.tf @@ -0,0 +1,88 @@ +/* +Пример использования +Получение списка групп сетевых объектов +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_network_object_group_list" "name" { + #фильтр по имени группы сетевых объектов + #опциональный параметр + #тип - строка + #name = "my-group" + + #фильтр по id группы доступа + #опциональный параметр + #тип - строка + #access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 10 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - name, created_at, updated_at + #sort_by = "name" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_from = "2024-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_to = "2025-01-01T00:00:00Z" + + #фильтр по нижней границе даты обновления + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #updated_from = "2024-01-01T00:00:00Z" + + #фильтр по верхней границе даты обновления + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #updated_to = "2025-01-01T00:00:00Z" +} + +output "test" { + value = data.decort_sdn_network_object_group_list.name +} diff --git a/samples/sdn/netobjgroups/resource_decort_sdn_network_object_group/main.tf b/samples/sdn/netobjgroups/resource_decort_sdn_network_object_group/main.tf new file mode 100644 index 00000000..7661de64 --- /dev/null +++ b/samples/sdn/netobjgroups/resource_decort_sdn_network_object_group/main.tf @@ -0,0 +1,101 @@ +/* +Пример использования +Ресурс позволяет: +1. Создавать группу сетевых объектов +2. Изменять группу сетевых объектов +3. Удалять группу сетевых объектов +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_sdn_network_object_group" "name" { + #имя группы сетевых объектов + #обязательный параметр + #тип - строка + #используется при создании и обновлении + name = "my-net-obj-group" + + #id группы доступа + #обязательный параметр + #тип - строка + #используется при создании и обновлении + access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #описание группы сетевых объектов + #обязательный параметр + #тип - строка + #используется при создании и обновлении + description = "description" + + #привязка и отвязка l2 портов + #опциональный параметр + #тип - блок + #используется при создании + #l2_connection_ports_bindings { + #id порта + #обязательный параметр + #тип - строка + #port_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #версия порта + #обязательный параметр + #тип - целое число + #port_version = 1747141621952 + #} + + #список сетевых адресов + #опциональный параметр + #тип - блок (может быть несколько) + #используется при создании и обновлении + #addresses { + #тип сетевого адреса + #обязательный параметр + #тип - строка + #net_address_type = "ip" + + #IP-адрес + #опциональный параметр + #тип - строка + #ip_addr = "192.168.1.10" + + #конец диапазона IP-адресов + #опциональный параметр + #тип - строка + #ip_addr_range_end = "192.168.1.20" + + #IP-префикс (CIDR) + #опциональный параметр + #тип - строка + #ip_prefix = "192.168.1.0/24" + + #MAC-адрес + #опциональный параметр + #тип - строка + #mac_addr = "aa:bb:cc:dd:ee:ff" + #} +} + +output "test" { + value = decort_sdn_network_object_group.name +} diff --git a/samples/sdn/segments/data_segment_list/main.tf b/samples/sdn/segments/data_segment_list/main.tf index abae4949..77096e17 100644 --- a/samples/sdn/segments/data_segment_list/main.tf +++ b/samples/sdn/segments/data_segment_list/main.tf @@ -76,26 +76,28 @@ data "decort_sdn_segment_list" "name" { #фильтр по нижней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_from = "2023-01-01T00:00:00Z" #фильтр по верхней границе даты создания #опциональный параметр #тип - строка - #значение по умолчанию - null #created_to = "2023-01-01T00:00:00Z" #фильтр по нижней границе даты обновления #опциональный параметр #тип - строка - #значение по умолчанию - null #updated_from = "2023-01-01T00:00:00Z" #фильтр по верхней границе даты обновления #опциональный параметр #тип - строка - #значение по умолчанию - null #updated_to = "2023-01-01T00:00:00Z" + + #фильтр по статусу операции + #опциональный параметр + #тип - строка + #возможные значения - Idle, SynchronizingAtCore, SynchronizingAtOVN, Synchronized, NoHypervisorAtOVN, FailedAtCore, TemporaryFailedAtCore + #operation_status = "Idle" } output "test" { diff --git a/samples/sdn/segments/resource_segment/main.tf b/samples/sdn/segments/resource_segment/main.tf index f58fbdd9..4f4be0e3 100644 --- a/samples/sdn/segments/resource_segment/main.tf +++ b/samples/sdn/segments/resource_segment/main.tf @@ -138,10 +138,16 @@ resource "decort_sdn_segment" "name" { #enabled = true #} + #тип сегмента + #опциональный параметр + #тип - строка + #возможные значения - User, ExtNet + #используется при создании и обновлении + #type = "User" + #флаг принудительного удаления #опциональный параметр #тип - булев - #значение по умолчанию - null #используется при обновлении #force = true }