Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89c77ddcbe | |||
| c00c608ce9 |
274
CHANGELOG.md
274
CHANGELOG.md
@@ -1,241 +1,93 @@
|
||||
## Version 4.12.0
|
||||
## Version 4.13.0
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### account
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1265 | Вычисляемое поле `zero_access_enabled` в datasource `decort_cb_grid_list` в cloudbroker/grid |
|
||||
| BATF-1311 | Вычисляемые поля `cpu_allocation_ratio_vm`, `cpu_allocation_ratio`, `custom_backup_path`, `interface_generation_scheme`, `mac_address_prefix`, `node_self_stop_timer_uptime_monitor` и `node_self_stop_uptime_monitor` в datasource `decort_cb_grid_get_settings` в cloudbroker/grid |
|
||||
| BATF-1311 | Вычисляемое поле `zero_access_enabled` в datasource `decort_cb_grid` в cloudbroker/grid |
|
||||
| BATF-1311 | Вычисляемое поле `policies` в datasource `decort_cb_grid_get_consumption` в cloudbroker/grid |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1302 | Вычисляемое поле `free_ips` в datasource `decort_extnet_list` в cloudapi/extnet |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1306 | Вычисляемое поле `pci_devices` в datasource `decort_cb_node_list` в cloudbroker/node |
|
||||
| BATF-1294 | Вычисляемые поля `one_g_free`, `one_g_reserved`, `one_g_available`, `one_g_used`, `one_g_dpdk_reserved`, `two_m_free`, `two_m_reserved`, `two_m_available` и `two_m_used` в блоке `memory` в datasources `decort_cb_node` и `decort_cb_node_list` в cloudbroker/node |
|
||||
| BATF-1305 | Datasources `decort_cb_node_network_info` и `decort_cb_node_pci_devices` в cloudbroker/node |
|
||||
|
||||
#### kvmvm
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1303 | Опциональное поле `clock` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1303 | Опциональное поле `clock` в resource `decort_kvmvm` в cloudapi/kvmvm |
|
||||
| BATF-1303 | Вычисляемое поле `clock` в datasources `decort_cb_kvmvm`, `decort_cb_kvmvm_list` и `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm |
|
||||
| BATF-1303 | Вычисляемое поле `clock` в datasources `decort_kvmvm`, `decort_kvmvm_list` и `decort_kvmvm_list_deleted` в cloudapi/kvmvm |
|
||||
| BATF-1297 | Datasource `decort_cb_kvmvm_cpu_alignment_profile` в cloudbroker/kvmvm |
|
||||
| BATF-1297 | Datasource `decort_kvmvm_cpu_alignment_profile` в cloudapi/kvmvm |
|
||||
| BATF-1297 | Опциональное поле `cpu_alignment_profile` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm и |
|
||||
| BATF-1297 | Опциональное поле `cpu_alignment_profile` в resource `decort_kvmvm` в cloudapi/kvmvm |
|
||||
| BATF-1297 | Вычисляемое поле `cpu_alignment_profiles` в datasources `decort_cb_kvmvm`, `decort_cb_kvmvm_list` и `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm |
|
||||
| BATF-1297 | Вычисляемое поле `cpu_alignment_profiles` в datasources `decort_kvmvm`, `decort_kvmvm_list` и `decort_kvmvm_list_deleted` в cloudapi/kvmvm |
|
||||
|
||||
#### zone
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1295 | Опциональное поле `hypervisor_similarity_in_percentage` и вычисляемое поле `cpu_alignment_profiles` в resource `decort_cb_zone` в cloudbroker/zone |
|
||||
| BATF-1295 | Datasources `decort_cb_zone_cpu_alignment_profile`, `decort_cb_zone_cpu_alignment_profile_list` и `decort_cb_zone_cpu_alignment_profile_test` в cloudbroker/zone |
|
||||
|
||||
### Изменено
|
||||
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| BATF-1304 | Тип опционального поля `type_image` с `string` на `[]string` в datasource `decort_image_list` в cloudapi/image |
|
||||
| BATF-1304 | Тип опционального поля `type_image` с `string` на `[]string` в datasource `decort_cb_image_list` в cloudbroker/image |
|
||||
|
||||
#### kvmvm
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1261 | Вычисляемое поле `ZeroAccessEnabled` в datasource `decort_locations_list` в cloudapi/locations |
|
||||
| BATF-1275 | Вычисляемое поле `BROEnabled` в datasource `decort_locations_list` в cloudapi/locations |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1228 | Вычисляемое поле `email` в блоке `acl` в resource и datasource `decort_resgroup` в cloudapi/rg |
|
||||
| BATF-1228 | Вычисляемое поле `email` в блоке `acl` в resource и datasource `decort_cb_rg` в cloudbroker/rg |
|
||||
|
||||
#### storage policy
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1266 | Опциональное поле `enable_secgroups` в resource `decort_vins` в cloudapi/vins |
|
||||
|
||||
#### SDN logical ports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1113 | Resource `decort_sdn_hypervisor` и datasources `decort_sdn_hypervisor` и `decort_sdn_hypervisor_list` в sdn/hypervisors |
|
||||
|
||||
#### SDN access group
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1155 | Опциональное поле `owner_display_name` в datasource `decort_sdn_access_group_list` в sdn/access_group |
|
||||
|
||||
|
||||
#### SDN network object group
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1115| Resource `decort_sdn_network_object_group`, datasources `decort_sdn_network_object_group` и `decort_sdn_network_object_group_list` в sdn/netobjgroups |
|
||||
|
||||
#### zone
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1249 | Минимальное значение опционального поля `mtu` в блоке `network` с 1 на 1500 в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
|
||||
#### node
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1258 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в блоке `FreeResourcesInfo` в datasource `decort_cb_node` в cloudbroker/node |
|
||||
|
||||
#### zone
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1253 | Поле `lb_ids` было переименовано в `lbs_ids` в datasource `decort_zone` в cloudapi/zone |
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### flipgroup
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1283 | Установка поля `desc` с платформы в ресурсе `decort_cb_flipgroup` в cloudbroker/flipgroup |
|
||||
|
||||
#### dpdknet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---
|
||||
| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_dpdknet` в cloudbroker/dpdknet |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---
|
||||
| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_extnet` в cloudbroker/extnet |
|
||||
|
||||
#### kvmvm
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1276 | Ошибка при старте ВМ с указанием поля `alt_boot_id` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
|
||||
#### rg
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1214 | Поведение ресурса при использовании параметра `net_type` в блоке `def_net` со значением `PRIVATE` в resource `decort_resgroup` в cloudapi/rg и в resource `decort_cb_rg` в cloudbroker/rg |
|
||||
|
||||
#### vins
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | ---
|
||||
| BATF-1266 | Оптимизировано количество запросов при создании `decort_cb_vins` в cloudbroker/vins |
|
||||
|
||||
#### SDN logical ports
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1271 | Формирование списка `remove_addresses` при обновлении `logical_port_addresses` в resource `decort_sdn_logical_port` в sdn/logicalports |
|
||||
|
||||
#### trunk
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1285 | Установка полей `account_ids`, `ovs_bridge`, `native_vlan_id`, `trunk_tags` с платформы в ресурсе `decort_cb_trunk ` в cloudbroker/trunk |
|
||||
|
||||
#### vfpool
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
|
||||
### Удалено
|
||||
| BATF-1300 | Тип вычисляемого поля `blk_discard` с `bool` на `string` и переименование в `discard` в блоке `disks` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1300 | Тип опционального поля `blk_discard` с `bool` на `string` и переименование в `discard` в блоке `disks` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1300 | Тип опционального поля `boot_disk_blk_discard` с `bool` на `string` и переименование в `boot_disk_discard` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1300 | Тип вычисляемого поля `blk_discard` с `bool` на `string` и переименование в `discard` в блоке `disks` в datasource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1300 | Тип вычисляемого поля `blk_discard` с `bool` на `string` и переименование в `discard` в блоке `disks` в resource `decort_kvmvm` и datasource `decort_kvmvm` в cloudapi/kvmvm |
|
||||
|
||||
#### disks
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| BATF-1300 | Тип опционального поля `blk_discard` с `bool` на `string` и переименование в `discard` в resource `decort_cb_disk` в cloudbroker/disks |
|
||||
| BATF-1300 | Тип вычисляемого поля `blk_discard` с `bool` на `string` и переименование в `discard` в datasources `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_unattached` и `decort_cb_disk_list_deleted` в cloudbroker/disks |
|
||||
| BATF-1300 | Тип вычисляемого поля `blk_discard` с `bool` на `string` и переименование в `discard` в resource `decort_disk` и datasources `decort_disk`, `decort_disk_list`, `decort_disk_list_unattached` и `decort_disk_list_deleted` в cloudapi/disks |
|
||||
|
||||
#### kvmvm
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| BATF-1293 | Тип поля `password` с опционального на обязательный в resource `decort_cb_user` в cloudbroker/user |
|
||||
|
||||
#### storage policy
|
||||
#### image
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1235 | Вычисляемое поле `storage_policy_id` из resource `decort_cb_storage_policy` в cloudbroker/stpolicy |
|
||||
| BATF-1299 | Тип поля `account_id` c опционального на обязательное в resource `decort_image_virtual` в cloudapi/image |
|
||||
|
||||
#### SDN logical ports
|
||||
|
||||
### Исправлено
|
||||
|
||||
|
||||
### Удалено
|
||||
|
||||
#### grid
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| BATF-1311 | Вычисляемые поля `ckey` и `meta` в datasource `decort_cb_grid` в cloudbroker/grid |
|
||||
|
||||
#### SDN segments
|
||||
#### user
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| BATF-1293 | Вычисляемое поле `password` в datasources `decort_cb_user` и `decort_cb_user_list` в cloudbroker/user |
|
||||
|
||||
|
||||
2
Makefile
2
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.12.0
|
||||
VERSION=4.13.0
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
|
||||
4
go.mod
4
go.mod
@@ -9,9 +9,11 @@ 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.14.11
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.15.1
|
||||
)
|
||||
|
||||
replace repository.basistech.ru/BASIS/decort-golang-sdk => ../decort-sdk-local
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
||||
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -318,5 +318,3 @@ 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.14.11 h1:lG35W5nKyEgaLMQp6B0Ur1n7bjXDCmB2FHQI/mM59U0=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.14.11/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM=
|
||||
|
||||
@@ -165,6 +165,7 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||
"decort_kvmvm_cpu_alignment_profile": kvmvm.DataSourceComputeCPUAlignmentProfile(),
|
||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||
@@ -229,8 +230,11 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
||||
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
|
||||
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
|
||||
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
|
||||
"decort_cb_kvmvm_cpu_alignment_profile": cb_kvmvm.DataSourceComputeCPUAlignmentProfile(),
|
||||
"decort_cb_node": cb_node.DataSourceNode(),
|
||||
"decort_cb_node_list": cb_node.DataSourceNodeList(),
|
||||
"decort_cb_node_network_info": cb_node.DataSourceNodeNetworkInfo(),
|
||||
"decort_cb_node_pci_devices": cb_node.DataSourceNodePCIDevices(),
|
||||
"decort_cb_disk": cb_disks.DataSourceDisk(),
|
||||
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
|
||||
"decort_cb_disk_list_deleted": cb_disks.DataSourceDiskListDeleted(),
|
||||
@@ -297,8 +301,11 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
||||
"decort_cb_k8s_wg_cloud_init": cb_k8s.DataSourceK8sWgCloudInit(),
|
||||
"decort_cb_k8s_wg_list": cb_k8s.DataSourceK8sWgList(),
|
||||
"decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(),
|
||||
"decort_cb_zone": cb_zone.DataSourceZone(),
|
||||
"decort_cb_zone_list": cb_zone.DataSourceZoneList(),
|
||||
"decort_cb_zone": cb_zone.DataSourceZone(),
|
||||
"decort_cb_zone_list": cb_zone.DataSourceZoneList(),
|
||||
"decort_cb_zone_cpu_alignment_profile": cb_zone.DataSourceZoneCPUAlignmentProfile(),
|
||||
"decort_cb_zone_cpu_alignment_profile_list": cb_zone.DataSourceZoneCPUAlignmentProfileList(),
|
||||
"decort_cb_zone_cpu_alignment_profile_test": cb_zone.DataSourceZoneCPUAlignmentProfileTest(),
|
||||
|
||||
"decort_sdn_access_group": accessgroup.DataSourceAccessGroup(),
|
||||
"decort_sdn_access_group_list": accessgroup.DataSourceAccessGroupList(),
|
||||
|
||||
@@ -80,8 +80,8 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
|
||||
@@ -152,8 +152,8 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
|
||||
@@ -155,8 +155,8 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
|
||||
@@ -123,8 +123,8 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
|
||||
@@ -25,7 +25,7 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
|
||||
"account_id": unattachedDisk.AccountID,
|
||||
"account_name": unattachedDisk.AccountName,
|
||||
"acl": string(unattachedDiskAcl),
|
||||
"blk_discard": unattachedDisk.BLKDiscard,
|
||||
"discard": unattachedDisk.Discard,
|
||||
"block_size": unattachedDisk.BlockSize,
|
||||
"boot_partition": unattachedDisk.BootPartition,
|
||||
"created_time": unattachedDisk.CreatedTime,
|
||||
@@ -79,7 +79,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||
d.Set("account_id", disk.AccountID)
|
||||
d.Set("account_name", disk.AccountName)
|
||||
d.Set("acl", string(diskAcl))
|
||||
d.Set("blk_discard", disk.BLKDiscard)
|
||||
d.Set("discard", disk.Discard)
|
||||
d.Set("block_size", disk.BlockSize)
|
||||
// d.Set("boot_partition", disk.BootPartition)
|
||||
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||
@@ -225,7 +225,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
"account_id": disk.AccountID,
|
||||
"account_name": disk.AccountName,
|
||||
"acl": string(diskAcl),
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"computes": flattenDiskComputes(disk.Computes),
|
||||
"created_by": disk.CreatedBy,
|
||||
|
||||
@@ -419,3 +419,12 @@ func resourceDiskV1() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceDiskV2() *schema.Resource {
|
||||
s := resourceDiskSchemaMake()
|
||||
s["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
@@ -805,10 +805,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Flag indicating whether blk-discard is enabled for the disk",
|
||||
Description: "Discard mode of the disk",
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
@@ -821,7 +821,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceDisk() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 2,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CreateContext: resourceDiskCreate,
|
||||
ReadContext: resourceDiskRead,
|
||||
@@ -847,6 +847,11 @@ func ResourceDisk() *schema.Resource {
|
||||
Upgrade: resourceDiskUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceDiskV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceDiskUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,3 +12,17 @@ func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{},
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceDiskUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceDiskUpgradeV2: upgrading state")
|
||||
if v, ok := rawState["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
rawState["discard"] = "unmap"
|
||||
} else {
|
||||
rawState["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(rawState, "blk_discard")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -138,6 +138,10 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"free_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -133,10 +133,11 @@ func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(el.Data))
|
||||
for _, e := range el.Data {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
"name": e.Name,
|
||||
"status": e.Status,
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
"name": e.Name,
|
||||
"status": e.Status,
|
||||
"free_ips": e.FreeIPs,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -83,9 +83,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Filter by architecture",
|
||||
},
|
||||
"type_image": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "Filter by image type",
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"image_size": {
|
||||
Type: schema.TypeInt,
|
||||
|
||||
@@ -64,7 +64,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("type", img.Type)
|
||||
d.Set("image_type", img.Type)
|
||||
d.Set("username", img.Username)
|
||||
d.Set("version", img.Version)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
|
||||
"size": img.Size,
|
||||
"status": img.Status,
|
||||
"storage_policy_id": img.StoragePolicyID,
|
||||
"type": img.Type,
|
||||
"image_type": img.Type,
|
||||
"username": img.Username,
|
||||
"virtual": img.Virtual,
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
|
||||
func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema {
|
||||
delete(sch, "show_all")
|
||||
|
||||
sch["name"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
@@ -52,9 +53,8 @@ func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*s
|
||||
|
||||
sch["account_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "account_id",
|
||||
Required: true,
|
||||
Description: "Account ID",
|
||||
}
|
||||
|
||||
sch["image_id"] = &schema.Schema{
|
||||
|
||||
@@ -63,7 +63,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
}
|
||||
|
||||
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||
req.TypeImage = typeImage.(string)
|
||||
for _, v := range typeImage.([]interface{}) {
|
||||
req.TypeImage = append(req.TypeImage, v.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if imageSize, ok := d.GetOk("image_size"); ok {
|
||||
|
||||
@@ -256,8 +256,8 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -766,6 +766,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_order": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -807,6 +811,26 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
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 dataSourceComputeCPUAlignmentProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
profile, err := utilityComputeGetCPUAlignmentProfile(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("model", profile.Model)
|
||||
d.Set("name", profile.Name)
|
||||
d.Set("vendor", profile.Vendor)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeCPUAlignmentProfileSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the compute instance",
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU model of the alignment profile",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the CPU alignment profile",
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU vendor of the alignment profile",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputeCPUAlignmentProfile() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeCPUAlignmentProfileRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeCPUAlignmentProfileSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clones": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -167,6 +171,26 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
|
||||
@@ -193,10 +193,12 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"bootdisk_size": compute.BootDiskSize,
|
||||
"boot_image_id": compute.BootImageID,
|
||||
"chipset": compute.Chipset,
|
||||
"clock": compute.Clock,
|
||||
"cd_image_id": compute.CdImageId,
|
||||
"clone_reference": compute.CloneReference,
|
||||
"clones": compute.Clones,
|
||||
"computeci_id": compute.ComputeCIID,
|
||||
"cpu_alignment_profiles": flattenCPUAlignmentProfile(compute.CPUAlignmentProfile),
|
||||
"cpu_pin": compute.CPUPin,
|
||||
"cpus": compute.CPU,
|
||||
"created_by": compute.CreatedBy,
|
||||
@@ -278,7 +280,7 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
"storage_policy_id": bootDisk.StoragePolicyID,
|
||||
"to_clean": bootDisk.ToClean,
|
||||
"cache": bootDisk.Cache,
|
||||
"blk_discard": bootDisk.BLKDiscard,
|
||||
"discard": bootDisk.Discard,
|
||||
"block_size": bootDisk.BlockSize,
|
||||
"bus_number": bootDisk.BusNumber,
|
||||
"provision": bootDisk.Provision,
|
||||
@@ -346,7 +348,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"permanently": pernamentlyValue,
|
||||
"cache": disk.Cache,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"provision": disk.Provision,
|
||||
"iotune": flattenIotune(disk.IOTune),
|
||||
@@ -440,6 +442,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("sep_id", bootDisk.SepID)
|
||||
d.Set("pool", bootDisk.Pool)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("clock", computeRec.Clock)
|
||||
d.Set("clone_reference", computeRec.CloneReference)
|
||||
d.Set("clones", computeRec.Clones)
|
||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||
@@ -505,6 +508,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
d.Set("cpu_pin", computeRec.CPUPin)
|
||||
d.Set("cpu_alignment_profile", computeRec.CPUAlignmentProfile.Name)
|
||||
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||
d.Set("hp_backed", computeRec.HPBacked)
|
||||
d.Set("weight", computeRec.Weight)
|
||||
@@ -613,7 +617,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"_ckey": disk.CKey,
|
||||
"acl": string(acl),
|
||||
"account_id": disk.AccountID,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
@@ -713,6 +717,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("auto_start_w_node", computeRec.AutoStart)
|
||||
d.Set("arch", computeRec.Architecture)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("clock", computeRec.Clock)
|
||||
d.Set("boot_order", computeRec.BootOrder)
|
||||
d.Set("bootdisk_size", computeRec.BootDiskSize)
|
||||
d.Set("boot_image_id", computeRec.BootImageID)
|
||||
@@ -785,9 +790,23 @@ 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("cpu_alignment_profiles", flattenCPUAlignmentProfile(computeRec.CPUAlignmentProfile))
|
||||
d.Set("weight", computeRec.Weight)
|
||||
}
|
||||
|
||||
func flattenCPUAlignmentProfile(profile compute.CPUAlignmentProfile) []map[string]interface{} {
|
||||
if profile.Name == "" && profile.Model == "" && profile.Vendor == "" {
|
||||
return nil
|
||||
}
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"name": profile.Name,
|
||||
"model": profile.Model,
|
||||
"vendor": profile.Vendor,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
|
||||
res := make([]uint64, 0, len(pciList.Data))
|
||||
|
||||
|
||||
@@ -1427,3 +1427,19 @@ func resourceComputeResourceV2() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceComputeResourceV3() *schema.Resource {
|
||||
s := ResourceComputeSchemaMake()
|
||||
|
||||
for _, blockKey := range []string{"disks", "boot_disk"} {
|
||||
if block, ok := s[blockKey]; ok {
|
||||
if res, ok := block.Elem.(*schema.Resource); ok {
|
||||
res.Schema["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.BootDisk = uint64(bootSize.(int))
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
ns := networks.(*schema.Set).List()
|
||||
@@ -264,6 +262,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.CPUPin = d.Get("cpu_pin").(bool)
|
||||
createReqX86.HPBacked = d.Get("hp_backed").(bool)
|
||||
createReqX86.Chipset = d.Get("chipset").(string)
|
||||
if clock, ok := d.GetOk("clock"); ok {
|
||||
createReqX86.Clock = clock.(string)
|
||||
}
|
||||
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
@@ -513,6 +514,17 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if profileName, ok := d.GetOk("cpu_alignment_profile"); ok {
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName.(string),
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if ars, ok := d.GetOk("affinity_rules"); ok {
|
||||
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", computeId)
|
||||
addedAR := ars.([]interface{})
|
||||
@@ -1042,6 +1054,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
if d.HasChanges("description",
|
||||
"name",
|
||||
"clock",
|
||||
"numa_affinity",
|
||||
"cpu_pin",
|
||||
"hp_backed",
|
||||
@@ -1069,6 +1082,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if d.HasChange("chipset") {
|
||||
req.Chipset = d.Get("chipset").(string)
|
||||
}
|
||||
if d.HasChange("clock") {
|
||||
req.Clock = d.Get("clock").(string)
|
||||
}
|
||||
if d.HasChange("preferred_cpu") {
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
@@ -1911,6 +1927,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cpu_alignment_profile") {
|
||||
if err := utilityComputeUpdateCPUAlignmentProfile(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||
// between Compute resource and Compute data source schemas
|
||||
|
||||
@@ -2230,8 +2252,8 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -2382,6 +2404,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), // observe case while validating
|
||||
Description: "Type of the emulated system.",
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "default",
|
||||
ValidateFunc: validation.StringInSlice([]string{"default", "linux", "windows", "none"}, false),
|
||||
Description: "Clock synchronization mode.",
|
||||
},
|
||||
"without_boot_disk": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -2405,6 +2434,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Set affinity label for compute",
|
||||
},
|
||||
"cpu_alignment_profile": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "CPU alignment profile name",
|
||||
},
|
||||
"affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -3095,7 +3129,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceCompute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 3,
|
||||
SchemaVersion: 4,
|
||||
|
||||
CreateContext: resourceComputeCreate,
|
||||
ReadContext: resourceComputeRead,
|
||||
@@ -3142,6 +3176,11 @@ func ResourceCompute() *schema.Resource {
|
||||
Upgrade: resourceComputeStateUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
{
|
||||
Type: resourceComputeResourceV3().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceComputeStateUpgradeV3,
|
||||
Version: 3,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,31 @@ func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]int
|
||||
|
||||
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
|
||||
|
||||
|
||||
delete(rawState, "with_default_vins")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceComputeStateUpgradeV3(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV3: upgrading state")
|
||||
|
||||
for _, blockKey := range []string{"disks", "boot_disk"} {
|
||||
if items, ok := rawState[blockKey].([]interface{}); ok {
|
||||
for _, item := range items {
|
||||
if disk, ok := item.(map[string]interface{}); ok {
|
||||
if v, ok := disk["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
disk["discard"] = "unmap"
|
||||
} else {
|
||||
disk["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(disk, "blk_discard")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityComputeUpdateCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
profileName := d.Get("cpu_alignment_profile").(string)
|
||||
if profileName == "" {
|
||||
req := compute.DeleteCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []uint64{computeId},
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().DeleteCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName,
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeGetCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.CPUAlignmentProfile, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.GetCPUAlignmentProfileRequest{
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
return c.CloudAPI().Compute().GetCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
@@ -208,20 +208,20 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if cpuAllocationRatio, ok := d.GetOk("cpu_allocation_ratio"); ok {
|
||||
cpuAllocationRatio := cpuAllocationRatio.(float64)
|
||||
// if cpuAllocationRatio, ok := d.GetOk("cpu_allocation_ratio"); ok {
|
||||
// cpuAllocationRatio := cpuAllocationRatio.(float64)
|
||||
|
||||
req := account.SetCPUAllocationRatioRequest{
|
||||
AccountID: accountId,
|
||||
Ratio: cpuAllocationRatio,
|
||||
}
|
||||
// req := account.SetCPUAllocationRatioRequest{
|
||||
// AccountID: accountId,
|
||||
// // Ratio: cpuAllocationRatio,
|
||||
// }
|
||||
|
||||
log.Debugf("setting account cpu allocation ratio")
|
||||
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, req)
|
||||
if err != nil {
|
||||
w.Add(err)
|
||||
}
|
||||
}
|
||||
// log.Debugf("setting account cpu allocation ratio")
|
||||
// _, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, req)
|
||||
// if err != nil {
|
||||
// w.Add(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
if !d.Get("enable").(bool) {
|
||||
_, err := c.CloudBroker().Account().Disable(ctx, account.DisableRequest{
|
||||
|
||||
@@ -117,11 +117,11 @@ func utilityAccountCPURatioUpdate(ctx context.Context, d *schema.ResourceData, m
|
||||
|
||||
accountId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
cpuAllocacationRatio := d.Get("cpu_allocation_ratio").(float64)
|
||||
// cpuAllocacationRatio := d.Get("cpu_allocation_ratio").(float64)
|
||||
|
||||
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, account.SetCPUAllocationRatioRequest{
|
||||
AccountID: accountId,
|
||||
Ratio: cpuAllocacationRatio,
|
||||
// Ratio: cpuAllocacationRatio,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -13,7 +13,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||
d.Set("account_id", disk.AccountID)
|
||||
d.Set("account_name", disk.AccountName)
|
||||
d.Set("acl", string(diskAcl))
|
||||
d.Set("blk_discard", disk.BLKDiscard)
|
||||
d.Set("discard", disk.Discard)
|
||||
d.Set("block_size", disk.BlockSize)
|
||||
d.Set("boot_partition", disk.BootPartition)
|
||||
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||
@@ -187,7 +187,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
"account_id": disk.AccountID,
|
||||
"account_name": disk.AccountName,
|
||||
"acl": string(diskAcl),
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"computes": flattenDiskComputes(disk.Computes),
|
||||
@@ -276,7 +276,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
|
||||
"account_id": unattachedDisk.AccountID,
|
||||
"account_name": unattachedDisk.AccountName,
|
||||
"acl": string(unattachedDiskAcl),
|
||||
"blk_discard": unattachedDisk.BLKDiscard,
|
||||
"discard": unattachedDisk.Discard,
|
||||
"block_size": unattachedDisk.BlockSize,
|
||||
"boot_partition": unattachedDisk.BootPartition,
|
||||
"created_time": unattachedDisk.CreatedTime,
|
||||
|
||||
@@ -5,6 +5,16 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func resourceDiskV2() *schema.Resource {
|
||||
s := resourceDiskSchemaMake()
|
||||
s["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
func resourceDiskV1() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
||||
@@ -79,8 +79,8 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
req.Cache = cache.(string)
|
||||
}
|
||||
|
||||
if blkDiscard, ok := d.GetOk("blk_discard"); ok {
|
||||
req.BLKDiscard = blkDiscard.(bool)
|
||||
if discard, ok := d.GetOk("discard"); ok {
|
||||
req.Discard = discard.(string)
|
||||
}
|
||||
|
||||
diskID, err := c.CloudBroker().Disks().Create(ctx, req)
|
||||
@@ -250,15 +250,15 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChanges("cache", "blk_discard", "block_size") {
|
||||
if d.HasChanges("cache", "discard", "block_size") {
|
||||
updateReq := disks.UpdateRequest{
|
||||
DiskID: uint64(d.Get("disk_id").(int)),
|
||||
}
|
||||
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("discard") {
|
||||
updateReq.Discard = d.Get("discard").(string)
|
||||
}
|
||||
if d.HasChange("block_size") {
|
||||
updateReq.BlockSize = d.Get("block_size").(string)
|
||||
@@ -460,7 +460,7 @@ func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m inte
|
||||
|
||||
func ResourceDisk() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 2,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CreateContext: resourceDiskCreate,
|
||||
ReadContext: resourceDiskRead,
|
||||
@@ -486,6 +486,11 @@ func ResourceDisk() *schema.Resource {
|
||||
Upgrade: resourceDiskUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceDiskV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceDiskUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -478,8 +478,8 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -913,8 +913,8 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -1367,8 +1367,8 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -1926,10 +1926,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "restore deleting disk",
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "ignore",
|
||||
ValidateFunc: validation.StringInSlice([]string{"unmap", "ignore"}, false),
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -12,3 +12,17 @@ func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{},
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceDiskUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceDiskUpgradeV2: upgrading state")
|
||||
if v, ok := rawState["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
rawState["discard"] = "unmap"
|
||||
} else {
|
||||
rawState["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(rawState, "blk_discard")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
)
|
||||
|
||||
func flattenGrid(d *schema.ResourceData, grid *grid.RecordGrid) {
|
||||
d.Set("ckey", grid.CKey)
|
||||
d.Set("meta", flattens.FlattenMeta(grid.Meta))
|
||||
d.Set("auth_broker", flattens.FlattenMeta(grid.AuthBroker))
|
||||
d.Set("name", grid.Name)
|
||||
d.Set("flag", grid.Flag)
|
||||
@@ -20,7 +18,7 @@ func flattenGrid(d *schema.ResourceData, grid *grid.RecordGrid) {
|
||||
d.Set("id", grid.ID)
|
||||
d.Set("network_modes", grid.NetworkModes)
|
||||
d.Set("sdn_support", grid.SDNSupport)
|
||||
|
||||
d.Set("zero_access_enabled", grid.ZeroAccessEnabled)
|
||||
}
|
||||
|
||||
func flattenGridList(gl *grid.ListGrids) []map[string]interface{} {
|
||||
@@ -77,11 +75,26 @@ func flattenGridRecordResource(rr grid.RecordResource) []map[string]interface{}
|
||||
"gpu": rr.GPU,
|
||||
"ram": rr.RAM,
|
||||
"seps": flattenGridSeps(rr.SEPs),
|
||||
"policies": flattenGridPolicies(rr.Policies),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridPolicies(policies map[string]grid.PolicyUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(policies))
|
||||
for policyID, policy := range policies {
|
||||
temp := map[string]interface{}{
|
||||
"policy_id": policyID,
|
||||
"disk_size": policy.DiskSize,
|
||||
"disk_size_max": policy.DiskSizeMax,
|
||||
"seps": flattenGridSeps(policy.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridSeps(seps map[string]map[string]grid.DiskUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for sepKey, sepVal := range seps {
|
||||
@@ -102,15 +115,22 @@ func flattenGridSettings(d *schema.ResourceData, gridSettings *grid.RecordSettin
|
||||
limits, _ := json.Marshal(gridSettings.Limits)
|
||||
d.Set("allowed_ports", gridSettings.Allowedports)
|
||||
d.Set("cleanup_retention_period", gridSettings.CleanupRetentionPeriod)
|
||||
d.Set("cpu_allocation_ratio_vm", gridSettings.CPUAllocationRatioVM)
|
||||
d.Set("cpu_allocation_ratio", gridSettings.CPUAllocationRatio)
|
||||
d.Set("custom_backup_path", gridSettings.CustomBackupPath)
|
||||
d.Set("docker_registry", flattenDockerRegistry(gridSettings.DockerRegistry))
|
||||
d.Set("enable_uptime_monitor", gridSettings.EnableUptimeMonitor)
|
||||
d.Set("extnet_max_pre_reservations_num", gridSettings.ExtnetMaxPreReservationsNum)
|
||||
d.Set("healthcheck_notifications", flattenHealthcheckNotifications(gridSettings.HealthcheckNotifications))
|
||||
d.Set("interface_generation_scheme", gridSettings.InterfaceGenerationScheme)
|
||||
d.Set("k8s_cleanup_enabled", gridSettings.K8sCleanupEnabled)
|
||||
d.Set("limits", string(limits))
|
||||
d.Set("location_url", gridSettings.LocationURL)
|
||||
d.Set("mac_address_prefix", gridSettings.MACAddressPrefix)
|
||||
d.Set("net_qos", flattenNetQOS(gridSettings.NetQOS))
|
||||
d.Set("networks", gridSettings.Networks)
|
||||
d.Set("node_self_stop_timer_uptime_monitor", gridSettings.NodeSelfStopTimerUptimeMonitor)
|
||||
d.Set("node_self_stop_uptime_monitor", gridSettings.NodeSelfStopUptimeMonitor)
|
||||
d.Set("prometheus", flattenPrometheus(gridSettings.Prometheus))
|
||||
d.Set("vins_max_pre_reservations_num", gridSettings.VinsMaxPreReservationsNum)
|
||||
d.Set("vnfdev_mgmt_net_range", gridSettings.VnfdevMgmtNetRange)
|
||||
|
||||
@@ -8,18 +8,6 @@ func dataSourceGetGridSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"meta": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Description: "meta",
|
||||
},
|
||||
"auth_broker": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -62,6 +50,10 @@ func dataSourceGetGridSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"zero_access_enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +299,53 @@ func dataSourceGridListEmailsSchemaMake() map[string]*schema.Schema {
|
||||
return rets
|
||||
}
|
||||
|
||||
func gridPoliciesSchemaMake() *schema.Schema {
|
||||
return &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"policy_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size_max": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"seps": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"data_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size_max": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceGridGetConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"grid_id": {
|
||||
@@ -366,6 +405,7 @@ func dataSourceGridGetConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"policies": gridPoliciesSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -422,6 +462,7 @@ func dataSourceGridGetConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"policies": gridPoliciesSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -489,6 +530,7 @@ func dataSourceGridListConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"policies": gridPoliciesSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -545,6 +587,7 @@ func dataSourceGridListConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"policies": gridPoliciesSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -749,5 +792,36 @@ func dataSourceGridGetSettingsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio_vm": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"custom_backup_path": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"interface_generation_scheme": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mac_address_prefix": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"node_self_stop_timer_uptime_monitor": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"node_self_stop_uptime_monitor": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||
Description: "find by architecture",
|
||||
},
|
||||
"type_image": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "find by type",
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"image_size": {
|
||||
Type: schema.TypeInt,
|
||||
|
||||
@@ -58,7 +58,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||
req.TypeImage = typeImage.(string)
|
||||
for _, v := range typeImage.([]interface{}) {
|
||||
req.TypeImage = append(req.TypeImage, v.(string))
|
||||
}
|
||||
}
|
||||
if imageSize, ok := d.GetOk("image_size"); ok {
|
||||
req.ImageSize = uint64(imageSize.(int))
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
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 dataSourceComputeCPUAlignmentProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
profile, err := utilityComputeGetCPUAlignmentProfile(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("model", profile.Model)
|
||||
d.Set("name", profile.Name)
|
||||
d.Set("vendor", profile.Vendor)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeCPUAlignmentProfileSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the compute instance",
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU model of the alignment profile",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the CPU alignment profile",
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU vendor of the alignment profile",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputeCPUAlignmentProfile() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeCPUAlignmentProfileRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeCPUAlignmentProfileSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,10 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("boot_disk_id", bootDisk.ID)
|
||||
// we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform
|
||||
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||
d.Set("boot_disk_discard", bootDisk.Discard)
|
||||
d.Set("boot_image_id", bootDisk.ImageID)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("clock", computeRec.Clock)
|
||||
d.Set("cd_image_id", computeRec.CdImageId)
|
||||
d.Set("clone_reference", computeRec.CloneReference)
|
||||
d.Set("clones", computeRec.Clones)
|
||||
@@ -111,12 +113,26 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("os_version", computeRec.OSVersion)
|
||||
d.Set("cpu_pin", computeRec.CPUPin)
|
||||
d.Set("cpu_alignment_profile", computeRec.CPUAlignmentProfile.Name)
|
||||
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||
d.Set("hp_backed", computeRec.HPBacked)
|
||||
d.Set("weight", computeRec.Weight)
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenCPUAlignmentProfile(profile compute.CPUAlignmentProfile) []map[string]interface{} {
|
||||
if profile.Name == "" && profile.Model == "" && profile.Vendor == "" {
|
||||
return nil
|
||||
}
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"name": profile.Name,
|
||||
"model": profile.Model,
|
||||
"vendor": profile.Vendor,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
|
||||
res := make([]uint64, 0, len(pciList.Data))
|
||||
|
||||
@@ -291,7 +307,7 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
||||
"delete_time": disk.DeletedTime,
|
||||
"update_time": disk.UpdatedTime,
|
||||
"cache": disk.Cache,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"provision": disk.Provision,
|
||||
"iotune": flattenIOTune(disk.IOTune),
|
||||
@@ -346,6 +362,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"clock": computeItem.Clock,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"boot_image_id": computeItem.BootImageID,
|
||||
@@ -367,6 +384,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_alignment_profiles": flattenCPUAlignmentProfile(computeItem.CPUAlignmentProfile),
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"live_migration_job_id": computeItem.LiveMigrationJobID,
|
||||
@@ -438,6 +456,7 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"clock": computeItem.Clock,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
@@ -459,6 +478,7 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_alignment_profiles": flattenCPUAlignmentProfile(computeItem.CPUAlignmentProfile),
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"lock_status": computeItem.LockStatus,
|
||||
@@ -779,10 +799,12 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("boot_order", compFacts.BootOrder)
|
||||
d.Set("boot_image_id", compFacts.ImageID)
|
||||
d.Set("chipset", compFacts.Chipset)
|
||||
d.Set("clock", compFacts.Clock)
|
||||
d.Set("cd_image_id", compFacts.CdImageId)
|
||||
d.Set("clone_reference", compFacts.CloneReference)
|
||||
d.Set("clones", compFacts.Clones)
|
||||
d.Set("computeci_id", compFacts.ComputeCIID)
|
||||
d.Set("cpu_alignment_profiles", flattenCPUAlignmentProfile(compFacts.CPUAlignmentProfile))
|
||||
d.Set("cpu_pin", compFacts.CPUPin)
|
||||
d.Set("cpus", compFacts.CPUs)
|
||||
d.Set("created_by", compFacts.CreatedBy)
|
||||
@@ -907,7 +929,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
|
||||
"ckey": disk.CKey,
|
||||
"meta": flattens.FlattenMeta(disk.Meta),
|
||||
"account_id": disk.AccountID,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
|
||||
@@ -1058,3 +1058,20 @@ func resourceComputeResourceV1() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceComputeResourceV2() *schema.Resource {
|
||||
s := resourceComputeSchemaMake()
|
||||
// Add blk_discard
|
||||
s["disks"].Elem.(*schema.Resource).Schema["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
// Add boot_disk_blk_discard
|
||||
s["boot_disk_blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
if bootDiskBLKDiscard, ok := d.GetOk("boot_disk_blk_discard"); ok {
|
||||
createReqX86.BootDiskBLKDiscard = bootDiskBLKDiscard.(bool)
|
||||
if bootDiskDiscard, ok := d.GetOk("boot_disk_discard"); ok {
|
||||
createReqX86.BootDiskDiscard = bootDiskDiscard.(string)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
ns := networks.(*schema.Set).List()
|
||||
@@ -179,8 +177,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if cache, ok := diskVal["cache"]; ok {
|
||||
reqDataDisk.Cache = cache.(string)
|
||||
}
|
||||
if blkDiscard, ok := diskVal["blk_discard"]; ok {
|
||||
reqDataDisk.BLKDiscard = blkDiscard.(bool)
|
||||
if discard, ok := diskVal["discard"]; ok {
|
||||
reqDataDisk.Discard = discard.(string)
|
||||
}
|
||||
disksX86 = append(disksX86, reqDataDisk)
|
||||
}
|
||||
@@ -227,6 +225,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.CPUPin = d.Get("cpu_pin").(bool)
|
||||
createReqX86.HPBacked = d.Get("hp_backed").(bool)
|
||||
createReqX86.Chipset = d.Get("chipset").(string)
|
||||
if clock, ok := d.GetOk("clock"); ok {
|
||||
createReqX86.Clock = clock.(string)
|
||||
}
|
||||
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
@@ -527,6 +528,17 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if profileName, ok := d.GetOk("cpu_alignment_profile"); ok {
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName.(string),
|
||||
}
|
||||
_, err := c.CloudBroker().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if ars, ok := d.GetOk("affinity_rules"); ok {
|
||||
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", computeId)
|
||||
addedAR := ars.([]interface{})
|
||||
@@ -872,8 +884,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("boot_disk_blk_discard") {
|
||||
if err := utilityComputeUpdateBootDiskBLKDiscard(ctx, d, m); err != nil {
|
||||
if d.HasChange("boot_disk_discard") {
|
||||
if err := utilityComputeUpdateBootDiskDiscard(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
@@ -893,6 +905,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
if d.HasChanges("description",
|
||||
"name",
|
||||
"clock",
|
||||
"numa_affinity",
|
||||
"cpu_pin",
|
||||
"hp_backed",
|
||||
@@ -1026,6 +1039,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cpu_alignment_profile") {
|
||||
if err := utilityComputeUpdateCPUAlignmentProfile(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceComputeRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
@@ -1057,7 +1076,7 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
func ResourceCompute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 2,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error {
|
||||
if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_node", "auto_start_w_node", "libvirt_settings", "network", "affinity_rules", "anti_affinity_rules",
|
||||
@@ -1100,6 +1119,11 @@ func ResourceCompute() *schema.Resource {
|
||||
Upgrade: resourceCompueteStateUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceComputeResourceV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceComputeStateUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -172,6 +176,26 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -228,8 +252,8 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -1413,6 +1437,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1432,6 +1460,26 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -2177,6 +2225,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -2196,6 +2248,26 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -3430,16 +3502,24 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), // observe case while validating
|
||||
Description: "Type of the emulated system.",
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "default",
|
||||
ValidateFunc: validation.StringInSlice([]string{"default", "linux", "windows", "none"}, false),
|
||||
Description: "Clock synchronization mode.",
|
||||
},
|
||||
"without_boot_disk": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
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.",
|
||||
},
|
||||
"boot_disk_blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
"boot_disk_discard": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "ignore",
|
||||
ValidateFunc: validation.StringInSlice([]string{"unmap", "ignore"}, false),
|
||||
},
|
||||
"create_blank": {
|
||||
Type: schema.TypeBool,
|
||||
@@ -3668,6 +3748,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Set affinity label for compute",
|
||||
},
|
||||
"cpu_alignment_profile": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "CPU alignment profile name",
|
||||
},
|
||||
"affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -3773,10 +3858,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Storage policy id of disk. The rules of the specified storage policy will be used.",
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "ignore",
|
||||
ValidateFunc: validation.StringInSlice([]string{"unmap", "ignore"}, false),
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -18,3 +18,33 @@ func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]int
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
|
||||
|
||||
if v, ok := rawState["boot_disk_blk_discard"].(bool); ok {
|
||||
if v {
|
||||
rawState["boot_disk_discard"] = "unmap"
|
||||
} else {
|
||||
rawState["boot_disk_discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(rawState, "boot_disk_blk_discard")
|
||||
|
||||
if disks, ok := rawState["disks"].([]interface{}); ok {
|
||||
for _, d := range disks {
|
||||
if disk, ok := d.(map[string]interface{}); ok {
|
||||
if v, ok := disk["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
disk["discard"] = "unmap"
|
||||
} else {
|
||||
disk["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(disk, "blk_discard")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
renamedDisks := make([]interface{}, 0)
|
||||
changeStoragePolicyDisks := make([]interface{}, 0)
|
||||
cacheUpdatedDisks := make([]interface{}, 0)
|
||||
blkDiscardUpdatedDisks := make([]interface{}, 0)
|
||||
discardUpdatedDisks := make([]interface{}, 0)
|
||||
blockSizeUpdatedDisks := make([]interface{}, 0)
|
||||
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||
migratedDisks := make([]interface{}, 0)
|
||||
@@ -325,8 +325,8 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
cacheUpdatedDisks = append(cacheUpdatedDisks, el)
|
||||
}
|
||||
|
||||
if isChangeBLKDiscardDisk(oldConv, el) {
|
||||
blkDiscardUpdatedDisks = append(blkDiscardUpdatedDisks, el)
|
||||
if isChangeDiscardDisk(oldConv, el) {
|
||||
discardUpdatedDisks = append(discardUpdatedDisks, el)
|
||||
}
|
||||
|
||||
if isChangeBlockSizeDisk(oldConv, el) {
|
||||
@@ -515,8 +515,8 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
}
|
||||
}
|
||||
|
||||
if len(blkDiscardUpdatedDisks) > 0 {
|
||||
for _, disk := range blkDiscardUpdatedDisks {
|
||||
if len(discardUpdatedDisks) > 0 {
|
||||
for _, disk := range discardUpdatedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if isBootDisk(diskConv, chipset) {
|
||||
continue
|
||||
@@ -528,8 +528,8 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: diskID,
|
||||
BLKDiscard: diskConv["blk_discard"].(bool),
|
||||
DiskID: diskID,
|
||||
Discard: diskConv["discard"].(string),
|
||||
}
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
if err != nil {
|
||||
@@ -672,10 +672,10 @@ func utilityComputeUpdateBootDiskCache(ctx context.Context, d *schema.ResourceDa
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeUpdateBootDiskBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
func utilityComputeUpdateBootDiskDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
newBLKDiscard := d.Get("boot_disk_blk_discard").(bool)
|
||||
newDiscard := d.Get("boot_disk_discard").(string)
|
||||
|
||||
var bootDiskID uint64
|
||||
if v, ok := d.GetOk("boot_disk_id"); ok {
|
||||
@@ -685,12 +685,12 @@ func utilityComputeUpdateBootDiskBLKDiscard(ctx context.Context, d *schema.Resou
|
||||
}
|
||||
|
||||
if bootDiskID == 0 {
|
||||
return fmt.Errorf("cannot update boot_disk_cache: boot disk ID is unknown for compute %s", d.Id())
|
||||
return fmt.Errorf("cannot update boot_disk_discard: boot disk ID is unknown for compute %s", d.Id())
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: bootDiskID,
|
||||
BLKDiscard: newBLKDiscard,
|
||||
DiskID: bootDiskID,
|
||||
Discard: newDiscard,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
@@ -1304,6 +1304,9 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
if d.HasChange("chipset") {
|
||||
req.Chipset = d.Get("chipset").(string)
|
||||
}
|
||||
if d.HasChange("clock") {
|
||||
req.Clock = d.Get("clock").(string)
|
||||
}
|
||||
|
||||
if d.HasChange("loader_type") {
|
||||
req.LoaderType = d.Get("loader_type").(string)
|
||||
@@ -2308,12 +2311,12 @@ func isChangeCacheDisk(els []interface{}, el interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isChangeBLKDiscardDisk(els []interface{}, el interface{}) bool {
|
||||
func isChangeDiscardDisk(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["blk_discard"].(bool) != elConv["blk_discard"].(bool) {
|
||||
elOldConv["discard"].(string) != elConv["discard"].(string) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityComputeUpdateCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
profileName := d.Get("cpu_alignment_profile").(string)
|
||||
if profileName == "" {
|
||||
req := compute.DeleteCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []uint64{computeId},
|
||||
}
|
||||
_, err := c.CloudBroker().Compute().DeleteCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName,
|
||||
}
|
||||
_, err := c.CloudBroker().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeGetCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.CPUAlignmentProfile, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.GetCPUAlignmentProfileRequest{
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
return c.CloudBroker().Compute().GetCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package node
|
||||
|
||||
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/cloudbroker/node"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func dataSourceNodeNetworkInfoRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := node.GetNetworkInfoRequest{
|
||||
NodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
|
||||
info, err := c.CloudBroker().Node().GetNetworkInfo(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("system_networks_info", flattenSystemNetworksInfo(info.SystemNetworksInfo))
|
||||
d.Set("ovs_networks_info", flattenOVSNetworksInfo(info.OVSNetworksInfo))
|
||||
d.Set("libvirt_networks_info", flattenLibvirtNetworksInfo(info.LibvirtNetworksInfo))
|
||||
d.Set("topology", flattenNetworkTopology(info.Topology))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceNodeNetworkInfoSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Node ID",
|
||||
},
|
||||
"system_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "System-level information about all network interfaces on the node",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "MTU value",
|
||||
},
|
||||
"speed": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface link speed",
|
||||
},
|
||||
"bridge_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Linux bridge ID",
|
||||
},
|
||||
"bport_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge port ID",
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"ovs_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Raw OVS ports data",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bridge_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge name",
|
||||
},
|
||||
"bridge_tag": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge tag",
|
||||
},
|
||||
"interface_uuid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface UUID",
|
||||
},
|
||||
"interface_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"interface_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"interface_mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface MTU value",
|
||||
},
|
||||
"interface_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface IP address",
|
||||
},
|
||||
"interface_mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface MAC address",
|
||||
},
|
||||
"interface_peer": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface peer name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"libvirt_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "VM network interface connections",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vm_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "VM name",
|
||||
},
|
||||
"interface": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Host-side interface name used by the VM",
|
||||
},
|
||||
"interface_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"interface_source": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the bridge the VM interface is attached to",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"topology": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Assembled network topology of the node",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Network interfaces and their topology details",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface MTU value",
|
||||
},
|
||||
"speed": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface link speed",
|
||||
},
|
||||
"vlans": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Description: "VLANs associated with the interface",
|
||||
},
|
||||
"bridge_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Linux bridge ID",
|
||||
},
|
||||
"peer": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Peer interface name",
|
||||
},
|
||||
"uuid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "OVS UUID",
|
||||
},
|
||||
"connected_interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true, Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Description: "Names of interfaces attached to this bridge as ports",
|
||||
},
|
||||
"connections": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vms": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"vm_interface": {Type: schema.TypeString, Computed: true},
|
||||
"vm_interface_type": {Type: schema.TypeString, Computed: true},
|
||||
"connection_type": {Type: schema.TypeString, Computed: true},
|
||||
"via_bridge": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridges": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"via": {Type: schema.TypeString, Computed: true},
|
||||
"bport_id": {Type: schema.TypeString, Computed: true},
|
||||
"port_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"mtu": {Type: schema.TypeInt, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
"uuid": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridge_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"ports": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"mtu": {Type: schema.TypeInt, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
"uuid": {Type: schema.TypeString, Computed: true},
|
||||
"ip": {Type: schema.TypeString, Computed: true},
|
||||
"mac": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridge_connections": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"via": {Type: schema.TypeString, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceNodeNetworkInfo() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
ReadContext: dataSourceNodeNetworkInfoRead,
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceNodeNetworkInfoSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
sdknode "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func dataSourceNodePCIDevicesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sdknode.GetPCIDevicesRequest{
|
||||
NodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
if v, ok := d.GetOk("search"); ok {
|
||||
req.Search = v.(string)
|
||||
}
|
||||
if v, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = v.(string)
|
||||
}
|
||||
if v, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(v.(int))
|
||||
}
|
||||
if v, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(v.(int))
|
||||
}
|
||||
|
||||
list, err := c.CloudBroker().Node().GetPCIDevices(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenNodePCIDevices(list.Data))
|
||||
d.Set("entry_count", list.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceNodePCIDevicesSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Node ID",
|
||||
},
|
||||
"search": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Search string",
|
||||
},
|
||||
"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",
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Total number of PCI devices",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of PCI devices",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"hw_path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Hardware path",
|
||||
},
|
||||
"current_driver": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Current driver",
|
||||
},
|
||||
"numa_node": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "NUMA node",
|
||||
},
|
||||
"product_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Product ID",
|
||||
},
|
||||
"product_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Product name",
|
||||
},
|
||||
"vendor_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Vendor ID",
|
||||
},
|
||||
"vendor_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Vendor name",
|
||||
},
|
||||
"iommu_group": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "IOMMU group",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceNodePCIDevices() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
ReadContext: dataSourceNodePCIDevicesRead,
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceNodePCIDevicesSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,7 @@ func flattenNodeList(nodes *node.ListNodes) []map[string]interface{} {
|
||||
"cpu_allocation_ratio": item.CPUAllocationRatio,
|
||||
"mem_allocation_ratio": item.MemAllocationRatio,
|
||||
"packages": flattenPackages(item.Packages),
|
||||
"pci_devices": flattenNodePCIDevices(item.PCIDevices),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -188,9 +189,18 @@ func flattenNumaTopology(info node.NumaTopologyInfo) []map[string]interface{} {
|
||||
for _, item := range info.Nodes {
|
||||
memoryTemp := []map[string]interface{}{
|
||||
{
|
||||
"one_g": item.Memory.OneG,
|
||||
"two_m": item.Memory.TwoM,
|
||||
"total": item.Memory.Total,
|
||||
"one_g": item.Memory.OneG,
|
||||
"one_g_free": item.Memory.OneGFree,
|
||||
"one_g_reserved": item.Memory.OneGReserved,
|
||||
"one_g_available": item.Memory.OneGAvailable,
|
||||
"one_g_used": item.Memory.OneGUsed,
|
||||
"one_g_dpdk_reserved": item.Memory.OneGDPDKReserved,
|
||||
"two_m": item.Memory.TwoM,
|
||||
"two_m_free": item.Memory.TwoMFree,
|
||||
"two_m_reserved": item.Memory.TwoMReserved,
|
||||
"two_m_available": item.Memory.TwoMAvailable,
|
||||
"two_m_used": item.Memory.TwoMUsed,
|
||||
"total": item.Memory.Total,
|
||||
},
|
||||
}
|
||||
temp := map[string]interface{}{
|
||||
@@ -339,3 +349,178 @@ func flattenRole(role node.Role) []map[string]interface{} {
|
||||
res[0] = temp
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSystemNetworksInfo(m map[string]node.SystemNetworkInfo) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(m))
|
||||
for name, info := range m {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": name,
|
||||
"mtu": info.MTU,
|
||||
"speed": info.Speed,
|
||||
"bridge_id": info.BridgeID,
|
||||
"bport_id": info.BPortID,
|
||||
"mac": info.MAC,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenOVSNetworksInfo(items []node.OVSNetworkInfo) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(items))
|
||||
for _, item := range items {
|
||||
res = append(res, map[string]interface{}{
|
||||
"bridge_name": item.BridgeName,
|
||||
"bridge_tag": item.BridgeTag,
|
||||
"interface_uuid": item.InterfaceUUID,
|
||||
"interface_type": item.InterfaceType,
|
||||
"interface_name": item.InterfaceName,
|
||||
"interface_mtu": item.InterfaceMTU,
|
||||
"interface_ip": item.InterfaceIP,
|
||||
"interface_mac": item.InterfaceMAC,
|
||||
"interface_peer": item.InterfacePeer,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLibvirtNetworksInfo(items []node.LibvirtNetworkInfo) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(items))
|
||||
for _, item := range items {
|
||||
res = append(res, map[string]interface{}{
|
||||
"vm_name": item.VMName,
|
||||
"interface": item.Interface,
|
||||
"interface_type": item.InterfaceType,
|
||||
"interface_source": item.InterfaceSource,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNetworkTopology(t node.NetworkTopology) []map[string]interface{} {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"interfaces": flattenTopologyInterfaces(t.Interfaces),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenTopologyInterfaces(m map[string]node.TopologyInterface) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(m))
|
||||
for name, iface := range m {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": name,
|
||||
"type": iface.Type,
|
||||
"mtu": iface.MTU,
|
||||
"speed": iface.Speed,
|
||||
"vlans": iface.VLANs,
|
||||
"bridge_id": iface.BridgeID,
|
||||
"peer": iface.Peer,
|
||||
"uuid": iface.UUID,
|
||||
"connected_interfaces": iface.ConnectedInterfaces,
|
||||
"connections": flattenTopologyConnections(iface.Connections),
|
||||
"bridge_info": flattenTopologyBridgeInfo(iface.BridgeInfo),
|
||||
"bridge_connections": flattenTopologyBridgeRefs(iface.BridgeConnections),
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenTopologyConnections(c node.TopologyInterfaceConnections) []map[string]interface{} {
|
||||
vms := make([]map[string]interface{}, 0, len(c.VMs))
|
||||
for _, vm := range c.VMs {
|
||||
vms = append(vms, map[string]interface{}{
|
||||
"name": vm.Name,
|
||||
"vm_interface": vm.VMInterface,
|
||||
"vm_interface_type": vm.VMInterfaceType,
|
||||
"connection_type": vm.ConnectionType,
|
||||
"via_bridge": vm.ViaBridge,
|
||||
})
|
||||
}
|
||||
|
||||
bridges := make([]map[string]interface{}, 0, len(c.Bridges))
|
||||
for _, b := range c.Bridges {
|
||||
portInfo := flattenTopologyPortInfo(b.PortInfo)
|
||||
bridges = append(bridges, map[string]interface{}{
|
||||
"name": b.Name,
|
||||
"type": b.Type,
|
||||
"via": b.Via,
|
||||
"bport_id": b.BPortID,
|
||||
"port_info": portInfo,
|
||||
})
|
||||
}
|
||||
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"vms": vms,
|
||||
"bridges": bridges,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenTopologyPortInfo(p *node.TopologyPortInfo) []map[string]interface{} {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"name": p.Name,
|
||||
"type": p.Type,
|
||||
"mtu": p.MTU,
|
||||
"vlan": p.VLAN,
|
||||
"uuid": p.UUID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenTopologyBridgeInfo(b *node.TopologyBridgeInfo) []map[string]interface{} {
|
||||
if b == nil {
|
||||
return nil
|
||||
}
|
||||
ports := make([]map[string]interface{}, 0, len(b.Ports))
|
||||
for _, p := range b.Ports {
|
||||
ports = append(ports, map[string]interface{}{
|
||||
"name": p.Name,
|
||||
"type": p.Type,
|
||||
"mtu": p.MTU,
|
||||
"vlan": p.VLAN,
|
||||
"uuid": p.UUID,
|
||||
"ip": p.IP,
|
||||
"mac": p.MAC,
|
||||
})
|
||||
}
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"type": b.Type,
|
||||
"ports": ports,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenTopologyBridgeRefs(refs []node.TopologyBridgeRef) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(refs))
|
||||
for _, r := range refs {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": r.Name,
|
||||
"via": r.Via,
|
||||
"vlan": r.VLAN,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNodePCIDevices(items []node.ItemPCIDevice) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(items))
|
||||
for _, item := range items {
|
||||
res = append(res, map[string]interface{}{
|
||||
"hw_path": item.HWPath,
|
||||
"current_driver": item.CurrentDriver,
|
||||
"numa_node": item.NUMANode,
|
||||
"product_id": item.ProductID,
|
||||
"product_name": item.ProductName,
|
||||
"vendor_id": item.VendorID,
|
||||
"vendor_name": item.VendorName,
|
||||
"iommu_group": item.IOMMUGroup,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -331,10 +331,46 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_dpdk_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -848,10 +884,46 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_dpdk_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -978,6 +1050,46 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"pci_devices": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"hw_path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"current_driver": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"numa_node": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"product_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"product_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"iommu_group": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -667,14 +667,13 @@ func resourceRGSetCPUAllocationParameter(ctx context.Context, d *schema.Resource
|
||||
}
|
||||
|
||||
func resourceRGSetCPUAllocationRatio(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
cpuAllocationRatio := d.Get("cpu_allocation_ratio").(float64)
|
||||
log.Debugf("resourceRGSetCPUAllocationRatio: cpuAllocationRatio %s for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
// log.Debugf("resourceRGSetCPUAllocationRatio: cpuAllocationRatio %s for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := rg.SetCPUAllocationRatioRequest{
|
||||
RGID: uint64(d.Get("rg_id").(int)),
|
||||
Ratio: cpuAllocationRatio,
|
||||
Ratio: uint64(d.Get("cpu_allocation_ratio").(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().RG().SetCPUAllocationRatio(ctx, req)
|
||||
|
||||
@@ -36,19 +36,18 @@ import (
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilitySepConsumptionCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.RecordConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.ConsumptionRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
}
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
// req := sep.ConsumptionRequest{
|
||||
// SEPID: uint64(d.Get("sep_id").(int)),
|
||||
// }
|
||||
|
||||
sepCons, err := c.CloudBroker().SEP().Consumption(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// nil, err := c.CloudBroker().SEP().Consumption(ctx, req)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return sepCons, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ func flattenUserDataSource(d *schema.ResourceData, details *user.ItemUser) {
|
||||
d.Set("guid", details.GUID)
|
||||
d.Set("last_check", details.LastCheck)
|
||||
d.Set("mobile", flattenItemUser(details.Mobile))
|
||||
d.Set("password", details.Password)
|
||||
d.Set("protected", details.Protected)
|
||||
d.Set("roles", flattenItemUser(details.Roles))
|
||||
d.Set("service_account", details.ServiceAccount)
|
||||
@@ -157,7 +156,6 @@ func flattenUserList(users *user.ListUsers) []map[string]interface{} {
|
||||
"user_id": item.ID,
|
||||
"last_check": item.LastCheck,
|
||||
"mobile": flattenItemUser(item.Mobile),
|
||||
"password": item.Password,
|
||||
"protected": item.Protected,
|
||||
"roles": flattenItemUser(item.Roles),
|
||||
"service_account": item.ServiceAccount,
|
||||
|
||||
@@ -26,10 +26,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
EmailAddress: email,
|
||||
}
|
||||
|
||||
if passwd, ok := d.GetOk("password"); ok {
|
||||
|
||||
createReq.Password = passwd.(string)
|
||||
}
|
||||
createReq.Password = d.Get("password").(string)
|
||||
|
||||
if provider, ok := d.GetOk("provider_name"); ok {
|
||||
createReq.Provider = provider.(string)
|
||||
|
||||
@@ -111,11 +111,6 @@ func dataSourceUserSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "mobile",
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "password",
|
||||
},
|
||||
"protected": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -370,11 +365,6 @@ func dataSourceUserListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "mobile",
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "password",
|
||||
},
|
||||
"protected": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -427,8 +417,8 @@ func resourceUserSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Default: "strongpassword",
|
||||
Optional: true,
|
||||
Required: true,
|
||||
Sensitive: true,
|
||||
Description: "password of user",
|
||||
},
|
||||
"provider_name": {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"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 dataSourceZoneCPUAlignmentProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
profiles, err := utilityZoneCPUAlignmentProfileCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId(strconv.Itoa(d.Get("zone_id").(int)))
|
||||
d.Set("profiles", flattenCPUAlignmentProfiles(profiles))
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceZoneCPUAlignmentProfileSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceZoneCPUAlignmentProfile() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceZoneCPUAlignmentProfileRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceZoneCPUAlignmentProfileSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceZoneCPUAlignmentProfileListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
list, err := utilityZoneCPUAlignmentProfileListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenZoneCPUAlignmentProfileList(list))
|
||||
d.Set("entry_count", list.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceZoneCPUAlignmentProfileListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceZoneCPUAlignmentProfileList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceZoneCPUAlignmentProfileListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceZoneCPUAlignmentProfileListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"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 dataSourceZoneCPUAlignmentProfileTestRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
result, err := utilityZoneCPUAlignmentProfileTestCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId(strconv.Itoa(d.Get("zone_id").(int)))
|
||||
d.Set("profiles", flattenCPUAlignmentProfiles(result.Profiles))
|
||||
d.Set("candidates", flattenCPUAlignmentProfileCandidates(result.Candidates))
|
||||
d.Set("supported_cpu_models", flattenSupportedCpuModels(result.SupportedCpuModels))
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceZoneCPUAlignmentProfileTestSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"hypervisor_similarity_in_percentage": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"candidates": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"percentage": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"required_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"supported_cpu_models": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"percentage": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceZoneCPUAlignmentProfileTest() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceZoneCPUAlignmentProfileTestRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceZoneCPUAlignmentProfileTestSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -71,12 +71,64 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
|
||||
d.Set("ssl_skip_verify", item.SSLSkipVerify)
|
||||
d.Set("domain", item.Domain)
|
||||
d.Set("sso_type", item.SSOType)
|
||||
d.Set("cpu_alignment_profiles", flattenCPUAlignmentProfiles(item.CpuAlignmentProfiles))
|
||||
|
||||
log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete",
|
||||
item.Name, item.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenCPUAlignmentProfiles(profiles []zone.CpuAlignmentProfile) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(profiles))
|
||||
for _, p := range profiles {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": p.Name,
|
||||
"vendor": p.Vendor,
|
||||
"model": p.Model,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenCPUAlignmentProfileCandidates(candidates []zone.CpuAlignmentProfileCandidate) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(candidates))
|
||||
for _, c := range candidates {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": c.Name,
|
||||
"vendor": c.Vendor,
|
||||
"model": c.Model,
|
||||
"count": int(c.Count),
|
||||
"percentage": c.Percentage,
|
||||
"required_count": int(c.RequiredCount),
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSupportedCpuModels(models []zone.SupportedCpuModel) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(models))
|
||||
for _, m := range models {
|
||||
res = append(res, map[string]interface{}{
|
||||
"vendor": m.Vendor,
|
||||
"model": m.Model,
|
||||
"count": int(m.Count),
|
||||
"percentage": m.Percentage,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenZoneCPUAlignmentProfileList(list *zone.ListCPUAlignmentProfiles) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(list.Data))
|
||||
for _, item := range list.Data {
|
||||
res = append(res, map[string]interface{}{
|
||||
"zone_id": int(item.ZoneID),
|
||||
"cpu_alignment_profiles": flattenCPUAlignmentProfiles(item.CpuAlignmentProfiles),
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenZoneList(zone *zone.ListZones) []map[string]interface{} {
|
||||
log.Debugf("flattenZoneList start")
|
||||
res := make([]map[string]interface{}, 0, len(zone.Data))
|
||||
|
||||
@@ -97,6 +97,14 @@ func resourceZoneCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
if similarity, ok := d.GetOk("hypervisor_similarity_in_percentage"); ok {
|
||||
if s := similarity.(int); s > 0 {
|
||||
if err := utilityZoneCPUAlignmentProfileUpdate(ctx, d, m, zoneID); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("resourceZoneCreate: create Zone with ID: %d, complete", zoneID)
|
||||
return append(resourceZoneRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
@@ -127,6 +135,12 @@ func resourceZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("hypervisor_similarity_in_percentage") {
|
||||
if err := utilityZoneCPUAlignmentProfileUpdate(ctx, d, m, zoneID); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("resourceZoneUpdate: update Zone with id %d, complete", zoneID)
|
||||
|
||||
return resourceZoneRead(ctx, d, m)
|
||||
@@ -279,6 +293,30 @@ func resourceZoneSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"hypervisor_similarity_in_percentage": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -146,6 +146,33 @@ func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityZoneCPUAlignmentProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
newVal := d.Get("hypervisor_similarity_in_percentage").(int)
|
||||
|
||||
if newVal > 0 {
|
||||
req := zone.AddCPUAlignmentProfileRequest{
|
||||
ZoneID: zoneID,
|
||||
HypervisorSimilarityInPercentage: uint64(newVal),
|
||||
}
|
||||
if _, err := c.CloudBroker().Zone().AddCPUAlignmentProfile(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("utilityZoneCPUAlignmentProfileUpdate: added CPU alignment profile for zone %d with similarity %d%%", zoneID, newVal)
|
||||
} else {
|
||||
req := zone.DeleteCPUAlignmentProfileRequest{
|
||||
ZoneID: zoneID,
|
||||
}
|
||||
if _, err := c.CloudBroker().Zone().DeleteCPUAlignmentProfile(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("utilityZoneCPUAlignmentProfileUpdate: deleted CPU alignment profile for zone %d", zoneID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func containsNodes(set []interface{}, check interface{}) bool {
|
||||
for _, elem := range set {
|
||||
elemConv := elem.(int)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package 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 utilityZoneCPUAlignmentProfileCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]zone.CpuAlignmentProfile, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := zone.GetCPUAlignmentProfileRequest{
|
||||
ZoneID: uint64(d.Get("zone_id").(int)),
|
||||
}
|
||||
|
||||
return c.CloudBroker().Zone().GetCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
|
||||
func utilityZoneCPUAlignmentProfileListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListCPUAlignmentProfiles, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := zone.ListCPUAlignmentProfileRequest{}
|
||||
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
return c.CloudBroker().Zone().ListCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
|
||||
func utilityZoneCPUAlignmentProfileTestCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.TestCPUAlignmentProfileResult, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := zone.TestCPUAlignmentProfileRequest{
|
||||
ZoneID: uint64(d.Get("zone_id").(int)),
|
||||
}
|
||||
|
||||
if similarity, ok := d.GetOk("hypervisor_similarity_in_percentage"); ok {
|
||||
req.HypervisorSimilarityInPercentage = uint64(similarity.(int))
|
||||
}
|
||||
|
||||
return c.CloudBroker().Zone().TestCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
@@ -68,6 +68,7 @@
|
||||
- kvmvm_snapshot_usage
|
||||
- kvmvm_user_list
|
||||
- kvmvm_vgpu_list
|
||||
- kvmvm_cpu_alignment_profile
|
||||
- lb
|
||||
- lb_list
|
||||
- lb_list_deleted
|
||||
@@ -209,11 +210,14 @@
|
||||
- cb_kvmvm_snapshot_usage
|
||||
- cb_kvmvm_user_list
|
||||
- cb_kvmvm_vgpu_list
|
||||
- cb_kvmvm_cpu_alignment_profile
|
||||
- cb_lb
|
||||
- cb_lb_list
|
||||
- cb_lb_list_deleted
|
||||
- cb_node
|
||||
- cb_node_list
|
||||
- cb_node_network_info
|
||||
- cb_node_pci_devices
|
||||
- cb_pcidevice
|
||||
- cb_pcidevice_list
|
||||
- cb_rg
|
||||
@@ -259,6 +263,9 @@
|
||||
- cb_vins_static_route_list
|
||||
- cb_zone
|
||||
- cb_zone_list
|
||||
- cb_zone_cpu_alignment_profile
|
||||
- cb_zone_cpu_alignment_profile_list
|
||||
- cb_zone_cpu_alignment_profile_test
|
||||
- resources:
|
||||
- cb_account
|
||||
- cb_cdrom_image
|
||||
|
||||
@@ -55,8 +55,8 @@ data "decort_image_list" "il" {
|
||||
|
||||
#фильтр по типу образа
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#type_image = "cdrom"
|
||||
#тип - массив строк
|
||||
#type_image = ["linux", "windows"]
|
||||
|
||||
#фильтр по размеру образа
|
||||
#опциональный параметр
|
||||
|
||||
@@ -44,11 +44,10 @@ resource "decort_image_virtual" "iv" {
|
||||
link_to = 123
|
||||
|
||||
#id аккаунта
|
||||
#опциональный параметр
|
||||
#значение по умолчанию - 0
|
||||
#тип - целое число
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
#используется при создании
|
||||
#account_id = 123
|
||||
account_id = 123
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение данных о профиле CPU alignment виртуальной машины
|
||||
*/
|
||||
|
||||
#Раскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_kvmvm_cpu_alignment_profile" "cpu_alignment_profile" {
|
||||
#id виртуальной машины
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
compute_id = 100
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_kvmvm_cpu_alignment_profile.cpu_alignment_profile
|
||||
}
|
||||
@@ -69,6 +69,13 @@ resource "decort_kvmvm" "comp" {
|
||||
#используется при создании и обновлении
|
||||
#chipset = "i440fx"
|
||||
|
||||
#тип часов для ВМ
|
||||
#опциональный параметр
|
||||
#возможные значения: "default", "linux", "windows", "none"
|
||||
#по умолчанию - "default"
|
||||
#используется при создании и обновлении
|
||||
#clock = "linux"
|
||||
|
||||
#размер загрузочного диска
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
@@ -293,6 +300,11 @@ resource "decort_kvmvm" "comp" {
|
||||
#используется при создании и обновлении
|
||||
#affinity_label = "test4"
|
||||
|
||||
#имя профиля CPU alignment
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#используется при создании и обновлении
|
||||
#cpu_alignment_profile = "balanced"
|
||||
|
||||
#id экстра дисков
|
||||
#опциональный параметр
|
||||
|
||||
@@ -134,10 +134,11 @@ resource "decort_cb_disk" "my_disk01" {
|
||||
|
||||
#включение режима unmap для диска
|
||||
#опциональный параметр
|
||||
#тип - булев
|
||||
#по умолчанию - false
|
||||
#тип - строка
|
||||
#по умолчанию - "ignore"
|
||||
#возможные варианты: "ignore" или "unmap"
|
||||
#используется при создании и обновлении
|
||||
#blk_discard = false
|
||||
#discard = "unmap"
|
||||
|
||||
#размер блока диска
|
||||
#опциональный параметр
|
||||
|
||||
@@ -54,8 +54,8 @@ data "decort_cb_image_list" "il" {
|
||||
|
||||
#фильтр по типу образа
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#type_image = "cdrom"
|
||||
#тип - массив строк
|
||||
#type_image = ["linux", "windows"]
|
||||
|
||||
#фильтр по размеру образа
|
||||
#опциональный параметр
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение данных о профиле CPU alignment виртуальной машины
|
||||
*/
|
||||
|
||||
#Раскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_kvmvm_cpu_alignment_profile" "cpu_alignment_profile" {
|
||||
#id виртуальной машины
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
compute_id = 100
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_cb_kvmvm_cpu_alignment_profile.cpu_alignment_profile
|
||||
}
|
||||
@@ -69,6 +69,13 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
#используется при создании и обновлении
|
||||
#chipset = "Q35"
|
||||
|
||||
#тип часов для ВМ
|
||||
#опциональный параметр
|
||||
#возможные значения: "default", "linux", "windows", "none"
|
||||
#по умолчанию - "default"
|
||||
#используется при создании и обновлении
|
||||
#clock = "linux"
|
||||
|
||||
#id образа диска для создания compute
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
@@ -197,7 +204,6 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
#возможные варианты: "none" или "writethrough"
|
||||
#cache = "none"
|
||||
|
||||
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#sep_id = 1
|
||||
@@ -228,9 +234,11 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
|
||||
#включение режима unmap для диска
|
||||
#опциональный параметр
|
||||
#тип - булев
|
||||
#по умолчанию - false
|
||||
#blk_discard = false
|
||||
#тип - строка
|
||||
#по умолчанию - "ignore"
|
||||
#возможные варианты: "ignore" или "unmap"
|
||||
#используется при создании и обновлении
|
||||
#discard = "unmap"
|
||||
|
||||
#размер блока диска
|
||||
#опциональный параметр
|
||||
@@ -336,6 +344,12 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
#используется при создании и обновлении
|
||||
#affinity_label = "test4"
|
||||
|
||||
#имя профиля CPU alignment
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#используется при создании и обновлении
|
||||
#cpu_alignment_profile = "balanced"
|
||||
|
||||
#id экстра дисков
|
||||
#опциональный параметр
|
||||
#тип - список чисел
|
||||
@@ -724,10 +738,11 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
|
||||
#включение режима unmap для boot диска
|
||||
#опциональный параметр
|
||||
#тип - булев
|
||||
#по умолчанию - false
|
||||
#тип - строка
|
||||
#по умолчанию - "ignore"
|
||||
#используется при создании и обновлении
|
||||
#boot_disk_blk_discard = false
|
||||
#возможные варианты: "ignore" или "unmap"
|
||||
#boot_disk_discard = "unmap"
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
38
samples/cloudbroker/node/data_node_network_info/main.tf
Normal file
38
samples/cloudbroker/node/data_node_network_info/main.tf
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение сетевой информации ноды
|
||||
*/
|
||||
|
||||
#Раскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_node_network_info" "network_info" {
|
||||
#id ноды
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
node_id = 100
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_cb_node_network_info.network_info
|
||||
}
|
||||
58
samples/cloudbroker/node/data_node_pci_devices/main.tf
Normal file
58
samples/cloudbroker/node/data_node_pci_devices/main.tf
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение списка PCI-устройств ноды
|
||||
*/
|
||||
|
||||
#Раскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_node_pci_devices" "pci_devices" {
|
||||
#id ноды
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
node_id = 100
|
||||
|
||||
#строка поиска
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#search = "nvidia"
|
||||
|
||||
#сортировка по полю, формат +|-(поле)
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#sort_by = "+product_name"
|
||||
|
||||
#номер страницы
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#size = 10
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_cb_node_pci_devices.pci_devices
|
||||
}
|
||||
@@ -44,11 +44,10 @@ resource "decort_cb_user" "user" {
|
||||
emailaddress = "user1@example.com"
|
||||
|
||||
#пароль пользователя
|
||||
#значение по умолчанию – strongpassword
|
||||
#опциональный параметр
|
||||
#обязательный параметр
|
||||
#тип - строка
|
||||
#используется при создании
|
||||
#password = "user1Password"
|
||||
password = "user1Password"
|
||||
|
||||
#список групп доступа к api, к которым принадлежит этот пользователь
|
||||
#опциональный параметр
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение профиля выравнивания CPU зоны по её id
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_zone_cpu_alignment_profile" "cap" {
|
||||
#идентификатор зоны
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
zone_id = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_cb_zone_cpu_alignment_profile.cap
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение списка профилей выравнивания CPU зон
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_zone_cpu_alignment_profile_list" "cap_list" {
|
||||
#фильтрация по идентификатору зоны
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#zone_id = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_cb_zone_cpu_alignment_profile_list.cap_list
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Пример использования
|
||||
Тестирование профиля выравнивания CPU зоны
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "decs3o"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_cb_zone_cpu_alignment_profile_test" "cap_test" {
|
||||
#идентификатор зоны
|
||||
#обязательный параметр
|
||||
#тип - целое число
|
||||
zone_id = 1
|
||||
|
||||
#схожесть гипервизоров в процентах
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#hypervisor_similarity_in_percentage = 70
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_cb_zone_cpu_alignment_profile_test.cap_test
|
||||
}
|
||||
@@ -63,6 +63,12 @@ resource "decort_cb_zone" "zone" {
|
||||
#значение по умолчанию - false
|
||||
#используется при создании
|
||||
#drs = false
|
||||
|
||||
#профиль выравнивания CPU
|
||||
#опциональный параметр
|
||||
#тип - целое число
|
||||
#используется при создании и обновлении
|
||||
#hypervisor_similarity_in_percentage = 70
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
Reference in New Issue
Block a user