Compare commits

..

5 Commits

Author SHA1 Message Date
e459fcb4c4 4.10.6 2026-06-15 13:23:15 +03:00
6b82f23445 1.10.5 2026-04-23 12:29:28 +03:00
dayterr
754b4e1143 4.10.4 2026-02-27 16:24:31 +03:00
069d63a65c 4.10.3 2026-02-06 17:00:13 +03:00
67830db3eb 4.10.2 2025-12-22 16:34:04 +03:00
56 changed files with 4439 additions and 477 deletions

View File

@@ -1,223 +1,38 @@
## Version 4.10.1 ## Version 4.10.6
### Добавлено ### Добавлено
#### access group
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1109 | Resource `decort_sdn_access_group` и datasources `decort_sdn_access_group`, `decort_sdn_access_group_list`, `decort_sdn_access_group_user_list` в sdn/access_group |
#### account
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1061 | Опциональный блок `storage_policy` в блок `resource_limits` в resource `decort_cb_account` в cloudbroker/account |
| BATF-1061 | Вычисляемое поля `storage_policy` в блок `resource_limits` resource `decort_account` и datasources `decort_account`, `decort_account_resource_consumption_get` в cloudapi/account и resource `decort_cb_account` и datasources `decort_cb_account`, `decort_cb_account_list,` `decort_cb_account_list_deleted` в cloudbroker/account |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_account_list` в cloudapi/account и в datasource `decort_cb_account_list` в cloudbroker/account |
| BATF-1087 | Вычислямый блок `policies` в блоки `consumed` и `reserved` в datasources `decort_account_resource_consumption_get`, `decort_account_resource_consumption_list` в cloudapi/account и в `decort_cb_account_resource_consumption_get`, `decort_cb_account_resource_consumption_list` в cloudbroker/account |
| BATF-1085| Вычисляемое поле `zone_ids` в datasources `decort_account_list` и `decort_account_deleted_list` в cloudapi/account |
#### audit
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1080 | Вычисляемое поле `correlation_id` в datasources `decort_audit` в cloudapi/audit и в`decort_cb_audit_list`, `decort_cb_audit` в cloudbroker/audit |
| BATF-1095 | Опциональные поля `resgroup_id`, `compute_id`, `account_id`, `vins_id`, `service_id`, `k8s_id`, `flipgroup_id`, `lb_id`, `sep_id`, `node_id` и `exclude_audit_lines` в datasource `decort_cb_audit_list` в cloudbroker/audit |
| BATF-1095 | Datasource `decort_audit_list` в cloudapi/audit |
#### bservice
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1065 | Обязательное поле `storage_policy` в resource `decort_bservice_group` в cloudapi/bservice |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_bservice_list` в cloudapi/bservice |
#### default security policy
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1111 | Datasource `decort_sdn_default_security_policy_list` в sdn/default_security_policy |
#### disks
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1063 | Обязательное поле `storage_policy_id` в resources `decort_disk` в cloudapi/disk и `decort_cb_disk` в cloudbroker/disk |
| BATF-1063 | Вычисляемое поле `storage_policy_id` в data_sources `decort_disk`, `decort_disk_list` и `decort_disk_deleted` в cloudapi/disk и `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` в cloudbroker/disk |
| BATF-1079 | Вычисляемое поле `to_clean` в data_sources `decort_disk`, `decort_disk_list` и `decort_disk_deleted` в cloudapi/disk и `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` в cloudbroker/disk |
| BATF-1079 | Вычисляемое поле `to_clean` в resources `decort_disk` в cloudapi/disk и `decort_cb_disk` в cloudbroker/disk |
#### extnet
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_extnet` в cloudbroker/extnet |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_extnet_list` в cloudapi/extnet и в datasource `decort_cb_extnet_list` в cloudbroker/extnet |
#### dpdk
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_dpdknet` в cloudbroker/dpdk |
#### image
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1005 | Опциональный поле `account_id` в resource `decort_image_virtual` в cloudapi/image |
| BATF-1093 | Опциональное поле `storage_policy_id` в datasource `decort_image_list` в cloudapi/image и в datasource `decort_cb_image_list` в cloudbroker/image |
| BATF-1067 | Обязательное поле `storage_policy_id` в resources `decort_image` в cloudapi/image и `decort_cb_image` и `decort_cb_image_cdrom` в cloudbroker/image |
| BATF-1067 | Вычисляемое поле `storage_policy_id` в datasources `decort_image` и `decort_image_list` в cloudapi/image и datasources `decort_cb_image` и `decort_cb_image_list` в cloudbroker/image |
| BATF-1127 | Вычисляемое поле `to_clean` в datasources `decort_image` в cloudapi/image и datasources `decort_cb_image` и `decort_cb_image_list` в cloudbroker/image |
| BATF-1127 | Вычисляемое поле `to_clean` в resources `decort_image`, `decort_image_from_blank_compute`, `decort_image_from_platform_disk`, `decort_image_virtual` в cloudapi/image и resources `decort_cb_image`, `decort_cb_cdrom_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_image_virtual` в cloudbroker/image |
#### k8s
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1066 | Обязательное поле `storage_policy_id`, в resources `decort_k8s`, `decort_k8s_cp`, `decort_k8s_wg` в cloudapi/kvmvm и `decort_cb_k8s_cp`, `decort_cb_k8s_wg`, в cloudbroker/k8s |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_kvmvm_list` в cloudapi/kvmvm и в datasource `decort_cb_kvmvm_list` в cloudbroker/kvmvm |
#### kvmvm #### kvmvm
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-1057 | Опциональные поля `timestamp_at`, `timestamp_to`, `user`, `call`, `sort_by`, `page`, `size`, `min_status_code`, `max_status_code` в datasources `decort_kvmvm_audits` в cloudapi/kvmvm и `decort_cb_kvmvm_audits` в cloudbroker/kvmvm | | BATF-1276 | Добавлено опциональное поле `create_blank` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1064 | Обязательное поле `storage_policy_id` в resources `decort_kvmvmv` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | | BATF-1276 | Опциональное поле `alt_boot_id` в resource `decort_kvmvm` в cloudapi/kvmvm |
| BATF-1064 | Вычисляемое поле `storage_policy_id` в data_sources `decort_kvmvmv` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1073 | Вычисляемые поля `security_groups` и `enable_secgroups` в блоке `interfaces` в data_sources `decort_kvmvmv`, `decort_kvmvmv_list` и `decort_kvmvmv_list_deleted` и resource `decort_kvmvmv` в cloudapi/kvmvm |
| BATF-1073 | Вычисляемые поля `security_groups` и `enable_secgroups` в блоке `interfaces` data_sources `decort_cb_kvmvmv`, `decort_cb_kvmvmv_list` и `decort_cb_kvmvmv_list_deleted` и resource `decort_cb_kvmvmv` в cloudbroker/kvmvm |
| BATF-1073 | Опциональный блок `security_groups` в resource `decort_kvmvmv` в cloudapi/kvmvm и resource `decort_cb_kvmvmv` в cloudbroker/kvmvm |
| BATF-1078 | Опциональное поле `enabled` в блоке `network` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1079 | Вычисляемое поле `to_clean` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1083 | Опциональное поле `os_version` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1083 | Вычисляемое поле `os_version` в datasources `decort_kvmvmv`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` в cloudapi/kvmvm и `decort_cb_kvmvm`, `decort_cb_kvmvm_list`, `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm |
| BATF-1098 | Вычисляемое поле `boot_image_id` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1098 | Вычисляемое поле `boot_image_id` в datasources `decort_kvmvmv`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` в cloudapi/kvmvm и `decort_cb_kvmvm`, `decort_cb_kvmvm_list`, `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm |
| BATF-1088 | Вызов метода `Start` перед методом `pinToStack` в cloudapi/kvmvm |
| BATF-1128 | Перезагрузка виртуальной машины при изменении полей "hot_resize", "cpu" в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm |
#### lb ### Изменено
#### kvmvm
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_lb_list` в cloudapi/lb и в datasource `decort_cb_lb_list` в cloudbroker/lb | | BATF-1276 | Тип поля `disk_type` с опционального на вычисляемый в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
#### logical ports
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1114 | Datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_get_by_unique_identifier` и `decort_sdn_logical_port_list` и resource `decort_sdn_logical_port` в sdn/logicalports |
#### node
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1081 | Вычисляемое поле `vcpu` в блоке `free` в datasource `decort_cb_node` в cloudbroker/node |
#### rg
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1062 | Опциональное поле `storage_policy` в resources `decort_resgroup` в cloudapi/rg и в `decort_cb_rg` в cloudbroker/rg |
| BATF-1062 | Вычисляемое поле `storage_policy_ids` в resources `decort_resgroup` в cloudapi/rg и в `decort_cb_rg` в cloudbroker/rg|
| BATF-1062 | Вычисляемое поле `storage_policy_ids` datasources в cloudapi/rg и в cloudbroker/rg |
#### security group
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1071 | Datasources `decort_security_group` и `decort_security_group_list` в cloudapi/secgroup и datasources `decort_cb_security_group` и `decort_cb_security_group_list` в cloudbroker/secgroup |
| BATF-1072 | Resources `decort_security_group` в cloudapi/secgroup и `decort_cb_security_group` в cloudbroker/secgroup |
#### sdn segment
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1120 | Resource `decort_sdn_segment` и datasources `decort_sdn_segment`, `decort_sdn_segment_get_status` и `decort_sdn_segment_list` в sdn/segments |
#### storage policy
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1058 | Datasources `decort_storage_policy` и `decort_storage_policy_list` в cloudapi/storage_policy и datasources `decort_cb_storage_policy` и `decort_cb_storage_policy_list` в cloudbroker/storage_policy |
| BATF-1059 | Resource `decort_cb_storage_policy` в cloudbroker/storage_policy |
#### vins
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1048 | Вычисляемое поле `routes` в блоках `NAT` и `GW` в datasource `decort_vins`, resource `decort_vins` в cloudapi/vins, datasource `decort_cb_vins`, resource `decort_cb_vins` в cloudbroker/vins |
| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_vins` в cloudbroker/vins |
| BATF-1094 | Вычисляемое поле `zone_id` в блоках `DHCP`, `GW`, `NAT` и `VNFDev` и вычисляемые поля `security_groups` и `enable_secgroups` в блоке `VNFInterface` в datasource `decort_vins` и в resource `decort_vins` в cloudapi/vins и в datasource `decort_cb_vins` и в resource `decort_cb_vins` в cloudbroker/vins |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_vins_list` в cloudapi/vins и в datasource `decort_cb_vins_list` в cloudbroker/vins |
| BATF-1104 | Вычисляемое поле `live_migration_job_id` в блоке `VNFDev` в datasource `decort_vins` и в resource `decort_vins` в cloudapi/vins и в datasource `decort_cb_vins` и в resource `decort_cb_vins` в cloudbroker/vins |
#### zone
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-1076 | Вычисляемые поля `account_ids`, `compute_ids`, `extnet_ids`, `vins_ids`, `lb_ids`, `bservice_ids` и `k8s_ids` в datasource `decort_zone` в cloudapi/zone и в datasource `decort_cb_zone` в cloudbroker/zone |
### Исправлено ### Исправлено
#### общие изменения #### flipgroup
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-1116 | Исправлены уязвимости, обновлена версия go до v1.24.0 | | BATF-1283 | Установка поля `desc` с платформы в ресурсе `decort_cb_flipgroup` в cloudbroker/flipgroup |
#### account
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-894 | Исправлено отображение вычисляемого поля `zone_ids` в resource `decort_account` в cloudapi/account |
| BATF-894 | Исправлено некорректное поведение метода `resourceAccountUpdate` resource `decort_cb_account` в cloudbroker/account |
#### bservice
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1060 | Изменен тип поля `driver` с required на optional в resource `decort_bservice_group` в cloudapi/bservice |
#### extnet
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-893 | Исправлено отображение вычисляемого поля `network_ids` в datasource `decort_cb_extnet_list` в cloudbroker/extnet |
| BATF-972 | Возможность изменения поля `mtu` в resource `decort_cb_extnet` в cloudbroker/extnet |
#### image
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1005 | Опциональный `account_id` теперь может быть использован при создании resource `decort_cb_virtual_image` в cloudbroker/image |
| BATF-1007 | Изменен тип поля `drivers` с required на computed в resources `decort_image`, `decort_image_from_platform_disk` в cloudapi/image и в `decort_cb_image`, `decort_cb_image_from_platform_disk`, `decort_cb_cdrom_image` в cloudbroker/image |
#### kvmvm #### kvmvm
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-1049 | Перезагрузка виртуальной машины при изменении полей `ram` и `cpu` в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | | BATF-1276 | Ошибка при старте ВМ с указанием поля `alt_boot_id` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
| BATF-1122 | Перезагрузка виртуальной машины при изменении поля "disks" в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm |
| BATF-888 | Исправлено получение вычисляемого поля `zone_ids` в datasources `decort_kvmvm_list` и `decort_kvmvm_list_deleted` в cloudapi/kvmvm |
#### trunk #### trunk
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-1012 | Изменен тип поля `status` с computed на optional в datasource `decort_trunk_list` в cloudapi/trunk и в datasource `decort_cb_trunk_list` в cloudbroker/trunk | | BATF-1285 | Установка полей `account_ids`, `ovs_bridge`, `native_vlan_id`, `trunk_tags` с платформы в ресурсе `decort_cb_trunk ` в cloudbroker/trunk |
#### zone #### vfpool
| Идентификатор<br>задачи | Описание | | Идентификатор<br>задачи | Описание |
| --- | --- | | --- | --- |
| BATF-887 | Исправлена ошибка при изменении поля `name` в resource `decort_cb_zone` в cloudbroker/zone | | 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 |
### Удалено
#### account
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1086 | Вычисляемые поля `ckey`, `meta` и `service_account` в datasource `decort_account` в cloudapi/account и в datasources `decort_cb_account`, `decort_cb_account_list` и `decort_cb_account_list_deleted` в cloudbroker/account |
| BATF-1086 | Вычисляемые поля `ckey`, `meta` и `service_account` в resource `decort_account` в cloudapi/account и в resource `decort_cb_account` в cloudbroker/account |
#### audit
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1095 | Поле `tags` в datasource `decort_cb_audit_list` в cloudbroker/audit |
#### disks
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1096 | Опциональное поле `iops` в resource `decort_cb_disk` в cloudbroker/disks |
| BATF-1089 | Опциональное поле `storage_policy_id` в datasources `decort_disk_list`, `decort_disk_list_unattached` в cloudapi/disks и `decort_cb_disk_list`, `decort_cb_disk_list_unattached` в cloudbroker/disks |
#### image
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1084 | Поле `enabled_stacks` в resources `decort_cb_cdrom_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_image` в cloudbroker/image |
#### k8ci
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1007 | Поля `worker_driver`, `master_driver` в resource `decort_cb_k8ci` и datasources `decort_cb_k8ci_list`, `decort_cb_k8ci_list_deleted` в cloudbroker/k8ci |
#### kvmvm
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1091 | Опциональное поле `image_id` в datasources `decort_cb_kvmvm_list` в cloudbroker/kvmvm |

View File

@@ -7,7 +7,7 @@ ZIPDIR = ./zip
BINARY=${NAME} BINARY=${NAME}
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/ MAINPATH = ./cmd/decort/
VERSION=4.10.1 VERSION=4.10.6
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
FILES = ${BINARY}_${VERSION}_darwin_amd64\ FILES = ${BINARY}_${VERSION}_darwin_amd64\

View File

@@ -64,6 +64,7 @@ description: |-
- `image_name` (String) - `image_name` (String)
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces)) - `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `live_migration_job_id` (Number) - `live_migration_job_id` (Number)
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `loader_type` (String) - `loader_type` (String)
- `lock_status` (String) - `lock_status` (String)
- `manager_id` (Number) - `manager_id` (Number)
@@ -170,10 +171,13 @@ Read-Only:
- `boot_partition` (Number) - `boot_partition` (Number)
- `bus_number` (Number) - `bus_number` (Number)
- `ckey` (String) - `ckey` (String)
- `created_by` (String)
- `created_time` (Number) - `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number) - `deleted_time` (Number)
- `desc` (String) - `desc` (String)
- `destruction_time` (Number) - `destruction_time` (Number)
- `devicename` (String)
- `disk_id` (Number) - `disk_id` (Number)
- `disk_path` (String) - `disk_path` (String)
- `gid` (Number) - `gid` (Number)
@@ -211,6 +215,7 @@ Read-Only:
- `tech_status` (String) - `tech_status` (String)
- `to_clean` (Boolean) - `to_clean` (Boolean)
- `type` (String) - `type` (String)
- `updated_time` (Number)
<a id="nestedobjatt--disks--iotune"></a> <a id="nestedobjatt--disks--iotune"></a>
### Nested Schema for `disks.iotune` ### Nested Schema for `disks.iotune`
@@ -317,6 +322,15 @@ Read-Only:
<a id="nestedatt--loader_meta_iso"></a>
### Nested Schema for `loader_meta_iso`
Read-Only:
- `device_name` (String)
- `path` (String)
<a id="nestedatt--os_users"></a> <a id="nestedatt--os_users"></a>
### Nested Schema for `os_users` ### Nested Schema for `os_users`

View File

@@ -71,6 +71,7 @@ Read-Only:
- `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits)) - `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits))
- `resource_types` (List of String) - `resource_types` (List of String)
- `rg_id` (Number) - `rg_id` (Number)
- `sdn_access_group_id` (String)
- `secret` (String) - `secret` (String)
- `status` (String) - `status` (String)
- `storage_policy_ids` (List of Number) - `storage_policy_ids` (List of Number)

View File

@@ -67,6 +67,7 @@ Read-Only:
- `pool_names` (List of String) - `pool_names` (List of String)
- `sep_id` (Number) - `sep_id` (Number)
- `sep_name` (String)
<a id="nestedobjatt--items--usage"></a> <a id="nestedobjatt--items--usage"></a>

View File

@@ -62,6 +62,7 @@ description: |-
- `image_id` (Number) - `image_id` (Number)
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces)) - `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `live_migration_job_id` (Number) - `live_migration_job_id` (Number)
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `loader_type` (String) - `loader_type` (String)
- `lock_status` (String) - `lock_status` (String)
- `manager_id` (Number) - `manager_id` (Number)
@@ -201,10 +202,13 @@ Read-Only:
- `acl` (String) - `acl` (String)
- `boot_partition` (Number) - `boot_partition` (Number)
- `bus_number` (Number) - `bus_number` (Number)
- `created_by` (String)
- `created_time` (Number) - `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number) - `deleted_time` (Number)
- `description` (String) - `description` (String)
- `destruction_time` (Number) - `destruction_time` (Number)
- `devicename` (String)
- `disk_id` (Number) - `disk_id` (Number)
- `disk_path` (String) - `disk_path` (String)
- `gid` (Number) - `gid` (Number)
@@ -239,6 +243,7 @@ Read-Only:
- `tech_status` (String) - `tech_status` (String)
- `to_clean` (Boolean) - `to_clean` (Boolean)
- `type` (String) - `type` (String)
- `updated_time` (Number)
<a id="nestedobjatt--disks--iotune"></a> <a id="nestedobjatt--disks--iotune"></a>
### Nested Schema for `disks.iotune` ### Nested Schema for `disks.iotune`
@@ -346,6 +351,15 @@ Read-Only:
<a id="nestedatt--loader_meta_iso"></a>
### Nested Schema for `loader_meta_iso`
Read-Only:
- `device_name` (String)
- `path` (String)
<a id="nestedatt--os_users"></a> <a id="nestedatt--os_users"></a>
### Nested Schema for `os_users` ### Nested Schema for `os_users`

View File

@@ -71,6 +71,7 @@ Read-Only:
- `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits)) - `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits))
- `resource_types` (List of String) - `resource_types` (List of String)
- `rg_id` (Number) - `rg_id` (Number)
- `sdn_access_group_id` (String)
- `secret` (String) - `secret` (String)
- `status` (String) - `status` (String)
- `storage_policy_ids` (List of Number) - `storage_policy_ids` (List of Number)

View File

@@ -67,6 +67,7 @@ Read-Only:
- `pool_names` (List of String) - `pool_names` (List of String)
- `sep_id` (Number) - `sep_id` (Number)
- `sep_name` (String)
<a id="nestedobjatt--items--usage"></a> <a id="nestedobjatt--items--usage"></a>

View File

@@ -36,6 +36,7 @@ description: |-
- `chipset` (String) Type of the emulated system. - `chipset` (String) Type of the emulated system.
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases. - `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node. - `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.
- `custom_fields` (String) - `custom_fields` (String)
- `description` (String) Optional text description of this compute instance. - `description` (String) Optional text description of this compute instance.
- `detach_disks` (Boolean) - `detach_disks` (Boolean)
@@ -104,6 +105,7 @@ description: |-
- `id` (String) The ID of this resource. - `id` (String) The ID of this resource.
- `image_name` (String) - `image_name` (String)
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces)) - `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `lock_status` (String) - `lock_status` (String)
- `manager_id` (Number) - `manager_id` (Number)
- `manager_type` (String) - `manager_type` (String)
@@ -187,8 +189,8 @@ Required:
Optional: Optional:
- `desc` (String) Optional description - `desc` (String) Optional description
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `image_id` (Number) Specify image id for create disk from template - `image_id` (Number) Specify image id for create disk from template
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
- `node_ids` (Set of Number) - `node_ids` (Set of Number)
- `permanently` (Boolean) Disk deletion status - `permanently` (Boolean) Disk deletion status
- `pool` (String) Pool name; by default will be chosen automatically - `pool` (String) Pool name; by default will be chosen automatically
@@ -196,12 +198,39 @@ Optional:
Read-Only: Read-Only:
- `create_by` (String)
- `create_time` (Number)
- `delete_by` (String)
- `delete_time` (Number)
- `devicename` (String)
- `disk_id` (Number) Disk ID - `disk_id` (Number) Disk ID
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `present_to` (Map of Number) - `present_to` (Map of Number)
- `shareable` (Boolean) - `shareable` (Boolean)
- `size_max` (Number) - `size_max` (Number)
- `size_used` (Number) - `size_used` (Number)
- `to_clean` (Boolean) - `to_clean` (Boolean)
- `update_time` (Number)
<a id="nestedblock--disks--iotune"></a>
### Nested Schema for `disks.iotune`
Optional:
- `read_bytes_sec` (Number)
- `read_bytes_sec_max` (Number)
- `read_iops_sec` (Number)
- `read_iops_sec_max` (Number)
- `size_iops_sec` (Number)
- `total_bytes_sec` (Number)
- `total_bytes_sec_max` (Number)
- `total_iops_sec` (Number)
- `total_iops_sec_max` (Number)
- `write_bytes_sec` (Number)
- `write_bytes_sec_max` (Number)
- `write_iops_sec` (Number)
- `write_iops_sec_max` (Number)
<a id="nestedblock--libvirt_settings"></a> <a id="nestedblock--libvirt_settings"></a>
@@ -389,6 +418,15 @@ Read-Only:
<a id="nestedatt--loader_meta_iso"></a>
### Nested Schema for `loader_meta_iso`
Read-Only:
- `device_name` (String)
- `path` (String)
<a id="nestedatt--os_users"></a> <a id="nestedatt--os_users"></a>
### Nested Schema for `os_users` ### Nested Schema for `os_users`

View File

@@ -27,6 +27,7 @@ description: |-
- `affinity_label` (String) Set affinity label for compute - `affinity_label` (String) Set affinity label for compute
- `affinity_rules` (Block List) (see [below for nested schema](#nestedblock--affinity_rules)) - `affinity_rules` (Block List) (see [below for nested schema](#nestedblock--affinity_rules))
- `alt_boot_id` (Number) ID of CD-ROM live image to boot
- `anti_affinity_rules` (Block List) (see [below for nested schema](#nestedblock--anti_affinity_rules)) - `anti_affinity_rules` (Block List) (see [below for nested schema](#nestedblock--anti_affinity_rules))
- `auto_start_w_node` (Boolean) Flag for start compute after node exits from MAINTENANCE state - `auto_start_w_node` (Boolean) Flag for start compute after node exits from MAINTENANCE state
- `boot_disk_size` (Number) This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image. - `boot_disk_size` (Number) This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.
@@ -35,6 +36,7 @@ description: |-
- `chipset` (String) Type of the emulated system. - `chipset` (String) Type of the emulated system.
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases. - `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node. - `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.
- `custom_fields` (String) - `custom_fields` (String)
- `description` (String) Optional text description of this compute instance. - `description` (String) Optional text description of this compute instance.
- `detach_disks` (Boolean) - `detach_disks` (Boolean)
@@ -99,6 +101,7 @@ description: |-
- `guid` (Number) - `guid` (Number)
- `id` (String) The ID of this resource. - `id` (String) The ID of this resource.
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces)) - `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `lock_status` (String) - `lock_status` (String)
- `manager_id` (Number) - `manager_id` (Number)
- `manager_type` (String) - `manager_type` (String)
@@ -181,20 +184,47 @@ Required:
Optional: Optional:
- `desc` (String) Optional description - `desc` (String) Optional description
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `image_id` (Number) Specify image id for create disk from template - `image_id` (Number) Specify image id for create disk from template
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
- `permanently` (Boolean) Disk deletion status - `permanently` (Boolean) Disk deletion status
- `pool` (String) Pool name; by default will be chosen automatically - `pool` (String) Pool name; by default will be chosen automatically
- `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk - `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk
Read-Only: Read-Only:
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `devicename` (String)
- `disk_id` (Number) Disk ID - `disk_id` (Number) Disk ID
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `present_to` (Map of Number) - `present_to` (Map of Number)
- `shareable` (Boolean) - `shareable` (Boolean)
- `size_max` (Number) - `size_max` (Number)
- `size_used` (Number) - `size_used` (Number)
- `to_clean` (Boolean) - `to_clean` (Boolean)
- `updated_time` (Number)
<a id="nestedblock--disks--iotune"></a>
### Nested Schema for `disks.iotune`
Optional:
- `read_bytes_sec` (Number)
- `read_bytes_sec_max` (Number)
- `read_iops_sec` (Number)
- `read_iops_sec_max` (Number)
- `size_iops_sec` (Number)
- `total_bytes_sec` (Number)
- `total_bytes_sec_max` (Number)
- `total_iops_sec` (Number)
- `total_iops_sec_max` (Number)
- `write_bytes_sec` (Number)
- `write_bytes_sec_max` (Number)
- `write_iops_sec` (Number)
- `write_iops_sec_max` (Number)
<a id="nestedblock--network"></a> <a id="nestedblock--network"></a>
@@ -294,11 +324,17 @@ Required:
Read-Only: Read-Only:
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `desc` (String) - `desc` (String)
- `devicename` (String)
- `disk_id` (Number) - `disk_id` (Number)
- `disk_name` (String) - `disk_name` (String)
- `disk_type` (String) - `disk_type` (String)
- `image_id` (Number) - `image_id` (Number)
- `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--boot_disk--iotune))
- `permanently` (Boolean) - `permanently` (Boolean)
- `pool` (String) - `pool` (String)
- `present_to` (Map of Number) - `present_to` (Map of Number)
@@ -309,6 +345,27 @@ Read-Only:
- `size_used` (Number) - `size_used` (Number)
- `storage_policy_id` (Number) - `storage_policy_id` (Number)
- `to_clean` (Boolean) - `to_clean` (Boolean)
- `updated_time` (Number)
<a id="nestedobjatt--boot_disk--iotune"></a>
### Nested Schema for `boot_disk.iotune`
Read-Only:
- `read_bytes_sec` (Number)
- `read_bytes_sec_max` (Number)
- `read_iops_sec` (Number)
- `read_iops_sec_max` (Number)
- `size_iops_sec` (Number)
- `total_bytes_sec` (Number)
- `total_bytes_sec_max` (Number)
- `total_iops_sec` (Number)
- `total_iops_sec_max` (Number)
- `write_bytes_sec` (Number)
- `write_bytes_sec_max` (Number)
- `write_iops_sec` (Number)
- `write_iops_sec_max` (Number)
<a id="nestedatt--interfaces"></a> <a id="nestedatt--interfaces"></a>
@@ -369,6 +426,15 @@ Read-Only:
<a id="nestedatt--loader_meta_iso"></a>
### Nested Schema for `loader_meta_iso`
Read-Only:
- `device_name` (String)
- `path` (String)
<a id="nestedatt--os_users"></a> <a id="nestedatt--os_users"></a>
### Nested Schema for `os_users` ### Nested Schema for `os_users`

2
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
github.com/sirupsen/logrus v1.9.0 github.com/sirupsen/logrus v1.9.0
golang.org/x/net v0.44.0 golang.org/x/net v0.44.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12
) )
require ( require (

4
go.sum
View File

@@ -318,5 +318,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 h1:7RLk2Vjl6evKo4dLxlxiQCrRJSSlUwLztO3ZE/uBt+8= repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12 h1:dkLPikeIh9un93zDB2FMtF5E0hJnp8kEKBrC9YbSki8=
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM= repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM=

View File

@@ -0,0 +1,421 @@
package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceDiskV1() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
Description: "The unique ID of the subscriber-owner of the disk",
},
"disk_name": {
Type: schema.TypeString,
Required: true,
Description: "Name of disk",
},
"size_max": {
Type: schema.TypeInt,
Required: true,
Description: "Size in GB",
},
"gid": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
Description: "ID of the grid (platform)",
},
"pool": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Pool for disk location",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Storage endpoint provider ID to create disk",
},
"desc": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Description of disk",
},
"type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"detach": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Detaching the disk from compute",
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to completely delete the disk, works only with non attached disks",
},
"shareable": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"read_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Number of bytes to read per second",
},
"read_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum number of bytes to read",
},
"read_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Number of io read operations per second",
},
"read_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum number of io read operations",
},
"size_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Size of io operations",
},
"total_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Total size bytes per second",
},
"total_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum total size of bytes per second",
},
"total_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Total number of io operations per second",
},
"total_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum total number of io operations per second",
},
"write_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Number of bytes to write per second",
},
"write_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum number of bytes to write per second",
},
"write_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Number of write operations per second",
},
"write_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Maximum number of write operations per second",
},
},
},
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk ID. Duplicates the value of the ID parameter",
},
"account_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the subscriber '(account') to whom this disk belongs",
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
// "boot_partition": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Number of disk partitions",
// },
"computes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeString,
Computed: true,
},
"compute_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Created time",
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Deleted time",
},
"destruction_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Time of final deletion",
},
"devicename": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the device",
},
// "disk_path": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Disk path",
// },
// "guid": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Disk ID on the storage side",
// },
"image_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image ID",
},
"images": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "IDs of images using the disk",
},
// "iqn": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Disk IQN",
// },
// "login": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Login to access the disk",
// },
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"order": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk order",
},
"params": {
Type: schema.TypeString,
Computed: true,
Description: "Disk params",
},
"parent_id": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the parent disk",
},
// "passwd": {
// Type: schema.TypeString,
// Computed: true,
// Description: "Password to access the disk",
// },
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the pci slot to which the disk is connected",
},
// "purge_attempts": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Number of deletion attempts",
// },
"purge_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Time of the last deletion attempt",
},
"replication": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
Description: "Replication status",
},
// "reality_device_number": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Reality device number",
// },
// "reference_id": {
// Type: schema.TypeString,
// Computed: true,
// Description: "ID of the reference to the disk",
// },
"res_id": {
Type: schema.TypeString,
Computed: true,
Description: "Resource ID",
},
"res_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the resource",
},
"role": {
Type: schema.TypeString,
Computed: true,
Description: "Disk role",
},
"sep_type": {
Type: schema.TypeString,
Computed: true,
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
},
"size_used": {
Type: schema.TypeFloat,
Computed: true,
Description: "Number of used space, in GB",
},
"snapshots": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the snapshot",
},
"label": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the snapshot",
},
"res_id": {
Type: schema.TypeString,
Computed: true,
Description: "Reference to the snapshot",
},
"snap_set_guid": {
Type: schema.TypeString,
Computed: true,
Description: "The set snapshot ID",
},
"snap_set_time": {
Type: schema.TypeInt,
Computed: true,
Description: "The set time of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "Snapshot time",
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Disk status",
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
Description: "Technical status of the disk",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
},
}
}

View File

@@ -805,7 +805,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
func ResourceDisk() *schema.Resource { func ResourceDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceDiskCreate, CreateContext: resourceDiskCreate,
ReadContext: resourceDiskRead, ReadContext: resourceDiskRead,
@@ -825,5 +825,12 @@ func ResourceDisk() *schema.Resource {
}, },
Schema: resourceDiskSchemaMake(), Schema: resourceDiskSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceDiskV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourceDiskUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -0,0 +1,14 @@
package disks
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceDiskUpgradeV1: upgrading state")
rawState["present_to"] = make(map[string]uint64)
return rawState, nil
}

View File

@@ -0,0 +1,782 @@
package image
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
)
func resourceImageFromBlankComputeSchemaV1() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
Description: "Compute Id",
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Name of the rescue disk",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
Description: "Boot type of image BIOS or UEFI",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
},
"username": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional username for the image",
},
"password": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional password for the image",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "AccountId to make the image exclusive",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
"pool_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "pool for image create",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Does this machine supports hot resize",
},
"async_mode": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "create an image in async/sync mode",
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"unc_path": {
Type: schema.TypeString,
Computed: true,
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
"architecture": {
Type: schema.TypeString,
Computed: true,
},
"bootable": {
Type: schema.TypeBool,
Computed: true,
},
"compute_ci_id": {
Type: schema.TypeInt,
Computed: true,
},
"cd_presented_to": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"history": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"image_name": {
Type: schema.TypeString,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
"provider_name": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"res_id": {
Type: schema.TypeString,
Computed: true,
},
"rescuecd": {
Type: schema.TypeBool,
Computed: true,
},
"shared_with": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func resourceImageFromBlankDiskSchemaV1() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Required: true,
Description: "Disk Id",
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Name of the rescue disk",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
Description: "Boot type of image BIOS or UEFI",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
},
"architecture": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"X86_64"}, true),
Description: "binary architecture of this image, one of X86_64",
},
"username": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional username for the image",
},
"password": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional password for the image",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "AccountId to make the image exclusive",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
"pool_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "pool for image create",
},
"drivers": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{
StateFunc: statefuncs.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating
Type: schema.TypeString,
},
Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]",
},
"bootable": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "bootable image",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Does this machine supports hot resize",
},
"async_mode": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "create an image in async/sync mode",
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"unc_path": {
Type: schema.TypeString,
Computed: true,
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
"compute_ci_id": {
Type: schema.TypeInt,
Computed: true,
},
"cd_presented_to": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"history": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"image_name": {
Type: schema.TypeString,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
"provider_name": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"res_id": {
Type: schema.TypeString,
Computed: true,
},
"rescuecd": {
Type: schema.TypeBool,
Computed: true,
},
"shared_with": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func dataSourceImageExtendSchemaV1() map[string]*schema.Schema {
return map[string]*schema.Schema{
"image_id": {
Type: schema.TypeInt,
Required: true,
},
"show_all": {
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"unc_path": {
Type: schema.TypeString,
Computed: true,
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
"architecture": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"bootable": {
Type: schema.TypeBool,
Computed: true,
},
"compute_ci_id": {
Type: schema.TypeInt,
Computed: true,
},
"cd_presented_to": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"history": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"image_name": {
Type: schema.TypeString,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
"password": {
Type: schema.TypeString,
Computed: true,
},
"pool_name": {
Type: schema.TypeString,
Computed: true,
},
"provider_name": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"res_id": {
Type: schema.TypeString,
Computed: true,
},
"rescuecd": {
Type: schema.TypeBool,
Computed: true,
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
},
"shared_with": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"username": {
Type: schema.TypeString,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,
},
}
}
func resourceMainImageSchemaV1(sch map[string]*schema.Schema) map[string]*schema.Schema {
delete(sch, "show_all")
sch["name"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Name of the rescue disk",
}
sch["url"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "URL where to download media from",
}
sch["image_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "image id",
}
sch["boot_type"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true),
Description: "Boot type of image bios or uefi",
}
sch["type"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
}
sch["hot_resize"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Does this machine supports hot resize",
}
sch["username"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional username for the image",
}
sch["password"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Optional password for the image",
}
sch["account_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
Description: "AccountId to make the image exclusive",
}
sch["username_dl"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "username for upload binary media",
}
sch["password_dl"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "password for upload binary media",
}
sch["pool_name"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "pool for image create",
}
sch["sep_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
}
sch["architecture"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"X86_64"}, true),
Description: "binary architecture of this image, one of X86_64",
}
sch["drivers"] = &schema.Schema{
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
}
sch["network_interface_naming"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true),
Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming",
}
return sch
}
func resourceImageSchemaV1() *schema.Resource {
return &schema.Resource{Schema: resourceMainImageSchemaV1(dataSourceImageExtendSchemaV1())}
}
func resourceMainImageVirtualSchemaV1(sch map[string]*schema.Schema) map[string]*schema.Schema {
delete(sch, "show_all")
sch["name"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Name of the rescue disk",
}
sch["link_to"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
Description: "ID of real image to link this virtual image to upon creation",
}
sch["image_id"] = &schema.Schema{
Type: schema.TypeInt,
Computed: true,
Description: "Image id",
}
return sch
}
func resourceImageVirtualSchemaV1() *schema.Resource {
return &schema.Resource{Schema: resourceMainImageVirtualSchemaV1(dataSourceImageExtendSchemaV1())}
}

View File

@@ -272,7 +272,7 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
func ResourceImage() *schema.Resource { func ResourceImage() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageCreate, CreateContext: resourceImageCreate,
ReadContext: resourceImageRead, ReadContext: resourceImageRead,
@@ -292,5 +292,12 @@ func ResourceImage() *schema.Resource {
}, },
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()), Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -255,7 +255,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource
func ResourceImageFromBlankCompute() *schema.Resource { func ResourceImageFromBlankCompute() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageFromBlankComputeCreate, CreateContext: resourceImageFromBlankComputeCreate,
ReadContext: resourceImageFromBlankComputeRead, ReadContext: resourceImageFromBlankComputeRead,
@@ -275,6 +275,13 @@ func ResourceImageFromBlankCompute() *schema.Resource {
}, },
Schema: resourceImageFromBlankComputeSchemaMake(), Schema: resourceImageFromBlankComputeSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageFromBlankComputeSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -238,7 +238,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource
func ResourceImageFromPlatformDisk() *schema.Resource { func ResourceImageFromPlatformDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageFromPlatformDiskCreate, CreateContext: resourceImageFromPlatformDiskCreate,
ReadContext: resourceImageFromPlatformDiskRead, ReadContext: resourceImageFromPlatformDiskRead,
@@ -258,6 +258,13 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
}, },
Schema: resourceImageFromPlatformDiskSchemaMake(), Schema: resourceImageFromPlatformDiskSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageFromBlankDiskSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -108,7 +108,7 @@ func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m int
func ResourceImageVirtual() *schema.Resource { func ResourceImageVirtual() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate, CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead, ReadContext: resourceImageRead,
@@ -128,5 +128,12 @@ func ResourceImageVirtual() *schema.Resource {
}, },
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()), Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -0,0 +1,14 @@
package image
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourcePresentToUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourcePresentToUpgradeV1: upgrading state")
rawState["present_to"] = make(map[string]uint64)
return rawState, nil
}

View File

@@ -457,6 +457,22 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool, Type: schema.TypeBool,
Computed: true, Computed: true,
}, },
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
} }
} }
@@ -1148,6 +1164,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"loader_meta_iso": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"device_name": {
Type: schema.TypeString,
Computed: true,
},
"path": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"os_version": { "os_version": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,

View File

@@ -225,7 +225,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"numa_affinity": compute.NumaAffinity, "numa_affinity": compute.NumaAffinity,
"numa_node_id": compute.NumaNodeId, "numa_node_id": compute.NumaNodeId,
"os_version": compute.OSVersion, "os_version": compute.OSVersion,
// "pinned": compute.Pinned, "pinned": compute.PinnedToStack,
"preferred_cpu": compute.PreferredCPU, "preferred_cpu": compute.PreferredCPU,
"qemu_guest": flattenQemuQuest(compute.QemuQuest), "qemu_guest": flattenQemuQuest(compute.QemuQuest),
"ram": compute.RAM, "ram": compute.RAM,
@@ -289,10 +289,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} { func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(disksList)) res := make([]map[string]interface{}, 0, len(disksList))
if len(disksBlocks) == 0 {
return res
}
sort.Slice(disksList, func(i, j int) bool { sort.Slice(disksList, func(i, j int) bool {
return disksList[i].ID < disksList[j].ID return disksList[i].ID < disksList[j].ID
}) })
@@ -304,9 +300,19 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
continue continue
} }
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool) var pernamentlyValue bool
if indexDataDisks < len(disksBlocks) {
if diskBlock, ok := disksBlocks[indexDataDisks].(map[string]interface{}); ok {
if perm, exists := diskBlock["permanently"]; exists {
if permBool, ok := perm.(bool); ok {
pernamentlyValue = permBool
}
}
}
}
temp := map[string]interface{}{ temp := map[string]interface{}{
"devicename": disk.DeviceName,
"disk_name": disk.Name, "disk_name": disk.Name,
"disk_id": disk.ID, "disk_id": disk.ID,
"disk_type": disk.Type, "disk_type": disk.Type,
@@ -318,9 +324,16 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"desc": disk.Description, "desc": disk.Description,
"image_id": disk.ImageID, "image_id": disk.ImageID,
"size": disk.SizeMax, "size": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo, "present_to": disk.PresentTo,
"storage_policy_id": disk.StoragePolicyID, "storage_policy_id": disk.StoragePolicyID,
"to_clean": disk.ToClean,
"created_by": disk.CreatedBy,
"created_time": disk.CreatedTime,
"deleted_by": disk.DeletedBy,
"deleted_time": disk.DeletedTime,
"updated_time": disk.UpdatedTime,
"permanently": pernamentlyValue,
"iotune": flattenIotune(disk.IOTune),
} }
res = append(res, temp) res = append(res, temp)
indexDataDisks++ indexDataDisks++
@@ -439,7 +452,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
if err := d.Set("os_users", parseOsUsers(computeRec.OSUsers)); err != nil { if err := d.Set("os_users", parseOsUsers(computeRec.OSUsers)); err != nil {
return err return err
} }
// d.Set("pinned", computeRec.Pinned) d.Set("pinned", computeRec.PinnedToStack)
d.Set("preferred_cpu", computeRec.PreferredCPU) d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM) d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID) d.Set("reference_id", computeRec.ReferenceID)
@@ -467,6 +480,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("hot_resize", computeRec.HotResize) d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming) d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID) d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("enabled", false) d.Set("enabled", false)
if computeRec.Status == status.Enabled { if computeRec.Status == status.Enabled {
@@ -483,9 +497,23 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("os_version", computeRec.OSVersion) d.Set("os_version", computeRec.OSVersion)
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
return nil return nil
} }
func flattenLoaderMetaIso(loaderMetaIso compute.LoaderMetaIso) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"device_name": loaderMetaIso.DeviceName,
"path": loaderMetaIso.Path,
}
res = append(res, temp)
return res
}
func flattenACL(acl compute.RecordACL) []map[string]interface{} { func flattenACL(acl compute.RecordACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ temp := map[string]interface{}{
@@ -565,7 +593,10 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"boot_partition": disk.BootPartition, "boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber, "bus_number": disk.BusNumber,
"created_time": disk.CreatedTime, "created_time": disk.CreatedTime,
"created_by": disk.CreatedBy,
"deleted_time": disk.DeletedTime, "deleted_time": disk.DeletedTime,
"deleted_by": disk.DeletedBy,
"devicename": disk.DeviceName,
"description": disk.Description, "description": disk.Description,
"destruction_time": disk.DestructionTime, "destruction_time": disk.DestructionTime,
"disk_path": disk.DiskPath, "disk_path": disk.DiskPath,
@@ -601,6 +632,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"tech_status": disk.TechStatus, "tech_status": disk.TechStatus,
"type": disk.Type, "type": disk.Type,
"to_clean": disk.ToClean, "to_clean": disk.ToClean,
"updated_time": disk.UpdatedTime,
} }
res = append(res, temp) res = append(res, temp)
} }
@@ -726,6 +758,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("hot_resize", computeRec.HotResize) d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming) d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID) d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("os_version", computeRec.OSVersion) d.Set("os_version", computeRec.OSVersion)
} }

View File

@@ -71,6 +71,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int)) return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int))
} }
if !d.Get("create_blank").(bool) {
hasImage, err := existImageId(ctx, d, m) hasImage, err := existImageId(ctx, d, m)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
@@ -79,6 +80,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if !hasImage { if !hasImage {
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int)) return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
} }
}
if zoneID, ok := d.GetOk("zone_id"); ok { if zoneID, ok := d.GetOk("zone_id"); ok {
createReqX86.ZoneID = uint64(zoneID.(int)) createReqX86.ZoneID = uint64(zoneID.(int))
@@ -288,7 +290,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86) var apiResp uint64
if d.Get("create_blank").(bool) {
log.Debugf("resourceComputeCreate: using createBlank endpoint")
createBlankReq := kvmx86.CreateBlankRequest{
RGID: createReqX86.RGID,
Name: createReqX86.Name,
CPU: createReqX86.CPU,
RAM: createReqX86.RAM,
StoragePolicyID: createReqX86.StoragePolicyID,
WithoutBootDisk: createReqX86.WithoutBootDisk,
BootDisk: createReqX86.BootDisk,
SEPID: createReqX86.SepID,
Pool: createReqX86.Pool,
DataDisks: createReqX86.DataDisks,
Interfaces: createReqX86.Interfaces,
Description: createReqX86.Description,
Chipset: createReqX86.Chipset,
PreferredCPU: createReqX86.PreferredCPU,
ZoneID: createReqX86.ZoneID,
OSVersion: createReqX86.OSVersion,
}
apiResp, err = c.CloudAPI().KVMX86().CreateBlank(ctx, createBlankReq)
} else {
apiResp, err = c.CloudAPI().KVMX86().Create(ctx, createReqX86)
}
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -384,6 +410,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
if _, ok := d.GetOk("disks"); ok {
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
warnings.Add(err)
}
}
if !cleanup { if !cleanup {
if enabled, ok := d.GetOk("enabled"); ok { if enabled, ok := d.GetOk("enabled"); ok {
@@ -446,6 +478,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if start, ok := d.GetOk("started"); ok { if start, ok := d.GetOk("started"); ok {
if start.(bool) { if start.(bool) {
req := compute.StartRequest{ComputeID: computeId} req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId) log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
warnings.Add(err) warnings.Add(err)
@@ -757,6 +792,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int)) return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int))
} }
if !d.Get("create_blank").(bool) {
hasImage, err := existImageId(ctx, d, m) hasImage, err := existImageId(ctx, d, m)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
@@ -765,6 +801,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if !hasImage { if !hasImage {
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int)) return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
} }
}
if d.HasChange("zone_id") { if d.HasChange("zone_id") {
if err := utilityComputeUpdateZoneID(ctx, d, m); err != nil { if err := utilityComputeUpdateZoneID(ctx, d, m); err != nil {
@@ -851,6 +888,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if start, ok := d.GetOk("started"); ok { if start, ok := d.GetOk("started"); ok {
if start.(bool) { if start.(bool) {
req := compute.StartRequest{ComputeID: computeRec.ID} req := compute.StartRequest{ComputeID: computeRec.ID}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err) return diag.FromErr(err)
@@ -944,41 +984,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
if d.HasChange("pin_to_stack") {
oldPin, newPin := d.GetChange("pin_to_stack")
if !newPin.(bool) {
req := compute.UnpinFromStackRequest{
ComputeID: computeRec.ID,
}
_, err := c.CloudAPI().Compute().UnpinFromStack(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
if !oldPin.(bool) {
if !d.Get("started").(bool) {
return diag.Errorf("Cannot pin to stack a VM, that is not started")
}
reqToStart := compute.StartRequest{
ComputeID: computeRec.ID,
}
_, err := c.CloudAPI().Compute().Start(ctx, reqToStart)
if err != nil {
return diag.FromErr(err)
}
req := compute.PinToStackRequest{
ComputeID: computeRec.ID,
}
req.AutoStart = d.Get("auto_start_w_node").(bool)
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status. // Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
var isStopRequired bool var isStopRequired bool
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) { if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) {
@@ -1128,7 +1133,11 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
// If used to be STARTED, we need to start it after update // If used to be STARTED, we need to start it after update
if isStopRequired { if isStopRequired {
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil { req := compute.StartRequest{ComputeID: computeRec.ID}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
} }
@@ -1153,6 +1162,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
resizedDisks := make([]interface{}, 0) resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0) renamedDisks := make([]interface{}, 0)
changeStoragePolicyDisks := make([]interface{}, 0) changeStoragePolicyDisks := make([]interface{}, 0)
iotuneUpdatedDisks := make([]interface{}, 0)
oldDisks, newDisks := d.GetChange("disks") oldDisks, newDisks := d.GetChange("disks")
oldConv := oldDisks.([]interface{}) oldConv := oldDisks.([]interface{})
@@ -1193,6 +1203,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if isChangeStoragePolicy(oldConv, el) { if isChangeStoragePolicy(oldConv, el) {
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el) changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
} }
if isChangeIOTuneDisk(oldConv, el) {
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
}
} }
if len(deletedDisks) > 0 { if len(deletedDisks) > 0 {
@@ -1233,9 +1246,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["sep_id"].(int) != 0 { if diskConv["sep_id"].(int) != 0 {
req.SepID = uint64(diskConv["sep_id"].(int)) req.SepID = uint64(diskConv["sep_id"].(int))
} }
if diskConv["disk_type"].(string) != "" {
req.DiskType = diskConv["disk_type"].(string)
}
if diskConv["pool"].(string) != "" { if diskConv["pool"].(string) != "" {
req.Pool = diskConv["pool"].(string) req.Pool = diskConv["pool"].(string)
} }
@@ -1245,10 +1255,33 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["image_id"].(int) != 0 { if diskConv["image_id"].(int) != 0 {
req.ImageID = uint64(diskConv["image_id"].(int)) req.ImageID = uint64(diskConv["image_id"].(int))
} }
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req) diskID, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
iotuneMap := iotuneRaw[0].(map[string]interface{})
limitReq := disks.LimitIORequest{
DiskID: diskID,
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
if err != nil {
return diag.FromErr(err)
}
}
} }
} }
@@ -1302,6 +1335,59 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
} }
if len(iotuneUpdatedDisks) > 0 {
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
allDisks := computeRec.Disks
bootDisk := findBootDisk(allDisks)
diskIDs := getComputeDiskIDs(d, allDisks)
for i, disk := range iotuneUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
continue
}
if bootDisk != nil && diskConv["disk_id"].(int) == int(bootDisk.ID) {
continue
}
var diskID uint64
if id := diskConv["disk_id"].(int); id != 0 {
diskID = uint64(id)
} else if i < len(diskIDs) {
diskID = diskIDs[i]
}
if diskID == 0 {
continue
}
iotuneRaw, ok := diskConv["iotune"].([]interface{})
if !ok || len(iotuneRaw) == 0 {
continue
}
iotuneMap := iotuneRaw[0].(map[string]interface{})
limitReq := disks.LimitIORequest{
DiskID: diskID,
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
if err != nil {
return diag.FromErr(err)
}
}
}
} }
if d.HasChange("affinity_label") { if d.HasChange("affinity_label") {
@@ -1805,12 +1891,14 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.StartRequest{ req := compute.StartRequest{
ComputeID: computeRec.ID, ComputeID: computeRec.ID,
} }
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if !isStopRequired { if !isStopRequired {
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil { if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
} }
} else { } else {
req := compute.StopRequest{ req := compute.StopRequest{
ComputeID: computeRec.ID, ComputeID: computeRec.ID,
@@ -1821,6 +1909,34 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
if d.HasChange("pin_to_stack") || d.HasChange("started") {
newPin := d.Get("pin_to_stack")
if !newPin.(bool) && d.HasChange("pin_to_stack") {
req := compute.UnpinFromStackRequest{
ComputeID: computeRec.ID,
}
_, err := c.CloudAPI().Compute().UnpinFromStack(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
if newPin.(bool) {
if !d.Get("started").(bool) {
return diag.Errorf("Cannot pin to stack a VM, that is not started")
}
req := compute.PinToStackRequest{
ComputeID: computeRec.ID,
}
req.AutoStart = d.Get("auto_start_w_node").(bool)
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
// we may reuse dataSourceComputeRead here as we maintain similarity // we may reuse dataSourceComputeRead here as we maintain similarity
// between Compute resource and Compute data source schemas // between Compute resource and Compute data source schemas
@@ -1874,6 +1990,40 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
return false return false
} }
func isChangeIOTuneDisk(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) {
continue
}
oldIOTune := elOldConv["iotune"].([]interface{})
newIOTune := elConv["iotune"].([]interface{})
if len(oldIOTune) == 0 && len(newIOTune) == 0 {
return false
}
if len(oldIOTune) == 0 || len(newIOTune) == 0 {
return true
}
oldMap := oldIOTune[0].(map[string]interface{})
newMap := newIOTune[0].(map[string]interface{})
return oldMap["read_bytes_sec"].(int) != newMap["read_bytes_sec"].(int) ||
oldMap["read_bytes_sec_max"].(int) != newMap["read_bytes_sec_max"].(int) ||
oldMap["read_iops_sec"].(int) != newMap["read_iops_sec"].(int) ||
oldMap["read_iops_sec_max"].(int) != newMap["read_iops_sec_max"].(int) ||
oldMap["size_iops_sec"].(int) != newMap["size_iops_sec"].(int) ||
oldMap["total_bytes_sec"].(int) != newMap["total_bytes_sec"].(int) ||
oldMap["total_bytes_sec_max"].(int) != newMap["total_bytes_sec_max"].(int) ||
oldMap["total_iops_sec"].(int) != newMap["total_iops_sec"].(int) ||
oldMap["total_iops_sec_max"].(int) != newMap["total_iops_sec_max"].(int) ||
oldMap["write_bytes_sec"].(int) != newMap["write_bytes_sec"].(int) ||
oldMap["write_bytes_sec_max"].(int) != newMap["write_bytes_sec_max"].(int) ||
oldMap["write_iops_sec"].(int) != newMap["write_iops_sec"].(int) ||
oldMap["write_iops_sec_max"].(int) != newMap["write_iops_sec_max"].(int)
}
return false
}
func isContainsAR(els []interface{}, el interface{}) bool { func isContainsAR(els []interface{}, el interface{}) bool {
for _, elOld := range els { for _, elOld := range els {
elOldConv := elOld.(map[string]interface{}) elOldConv := elOld.(map[string]interface{})
@@ -1900,32 +2050,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
computeId, _ := strconv.ParseUint(d.Id(), 10, 64) computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if start, ok := d.GetOk("started"); ok {
if start.(bool) {
req := compute.StopRequest{ComputeID: computeId}
log.Debugf("resourceComputeDelete: stoping Compute ID %d", computeId)
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
diag.FromErr(err)
}
}
}
pciList, ok := d.GetOk("pci_devices")
if d.Get("permanently").(bool) && ok {
pciDevices := pciList.(*schema.Set).List()
for _, v := range pciDevices {
pciID := v.(int)
req := compute.DetachPCIDeviceRequest{
ComputeID: computeId,
DeviceID: uint64(pciID),
}
_, err := c.CloudAPI().Compute().DetachPCIDevice(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
req := compute.DeleteRequest{ req := compute.DeleteRequest{
ComputeID: computeId, ComputeID: computeId,
Permanently: d.Get("permanently").(bool), Permanently: d.Get("permanently").(bool),
@@ -1967,8 +2091,6 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
"disk_type": { "disk_type": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'", Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
}, },
"pool": { "pool": {
@@ -1994,6 +2116,81 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Optional: true, Optional: true,
Description: "Disk deletion status", Description: "Disk deletion status",
}, },
"iotune": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"read_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"size_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
},
},
"disk_id": { "disk_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -2022,6 +2219,30 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool, Type: schema.TypeBool,
Computed: true, Computed: true,
}, },
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
} }
return rets return rets
} }
@@ -2154,6 +2375,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true, Optional: true,
Computed: true, Computed: true,
}, },
"chipset": { "chipset": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
@@ -2167,6 +2389,12 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Default: false, 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.", Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
}, },
"create_blank": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
},
"boot_disk_size": { "boot_disk_size": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
@@ -2421,6 +2649,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Default: false, Default: false,
Description: "Flag for resize compute", Description: "Flag for resize compute",
}, },
"alt_boot_id": {
Type: schema.TypeInt,
Optional: true,
Description: "ID of CD-ROM live image to boot",
},
"started": { "started": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
@@ -2841,6 +3074,22 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"loader_meta_iso": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"device_name": {
Type: schema.TypeString,
Computed: true,
},
"path": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
} }
return rets return rets
} }
@@ -2867,6 +3116,10 @@ func ResourceCompute() *schema.Resource {
if diff.HasChanges("pin_to_stack") { if diff.HasChanges("pin_to_stack") {
diff.SetNewComputed("pinned") diff.SetNewComputed("pinned")
} }
if diff.HasChanges("image_id") {
diff.SetNewComputed("boot_disk")
diff.SetNewComputed("boot_image_id")
}
return nil return nil
}, },

View File

@@ -43,6 +43,7 @@ import (
"github.com/hashicorp/go-cty/cty" "github.com/hashicorp/go-cty/cty"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -292,7 +293,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
if needStart { if needStart {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64) computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil { var altBootID uint64
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
altBootID = uint64(altBootIDRaw)
} else {
altBootID = 0
}
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
apiErrCount += numErr apiErrCount += numErr
lastSavedError = err lastSavedError = err
} }
@@ -455,10 +462,14 @@ func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) er
return nil return nil
} }
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) { func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
startReq := compute.StartRequest{ComputeID: computeID} startReq := compute.StartRequest{ComputeID: computeID}
if altBootID > 0 {
startReq.AltBootID = altBootID
}
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID) log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
_, err := c.CloudAPI().Compute().Start(ctx, startReq) _, err := c.CloudAPI().Compute().Start(ctx, startReq)
if err != nil { if err != nil {
@@ -622,3 +633,94 @@ func enabledNetwork(rawNetworkConfig cty.Value, netID uint64, netType string) bo
return false return false
} }
func getComputeDiskIDs(d *schema.ResourceData, disksList compute.ListComputeDisks) []uint64 {
diskList := d.Get("disks").([]interface{})
ids := make([]uint64, 0, len(diskList))
for _, item := range diskList {
diskConv := item.(map[string]interface{})
diskName := diskConv["disk_name"].(string)
for _, disk := range disksList {
if disk.Name == diskName {
ids = append(ids, disk.ID)
break
}
}
}
return ids
}
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
diskList, ok := d.GetOk("disks")
if !ok {
return nil
}
disksSlice := diskList.([]interface{})
hasIotune := false
for _, item := range disksSlice {
diskConv := item.(map[string]interface{})
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
hasIotune = true
break
}
}
if !hasIotune {
return nil
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return err
}
allDisks := computeRec.Disks
bootDisk := findBootDisk(allDisks)
diskIDs := getComputeDiskIDs(d, allDisks)
c := m.(*controller.ControllerCfg)
for i, item := range disksSlice {
diskConv := item.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
continue
}
if bootDisk != nil && diskConv["disk_id"].(int) == int(bootDisk.ID) {
continue
}
iotuneRaw, ok := diskConv["iotune"].([]interface{})
if !ok || len(iotuneRaw) == 0 {
continue
}
var diskID uint64
if id := diskConv["disk_id"].(int); id != 0 {
diskID = uint64(id)
} else if i < len(diskIDs) {
diskID = diskIDs[i]
}
if diskID == 0 {
continue
}
iotuneMap := iotuneRaw[0].(map[string]interface{})
limitReq := disks.LimitIORequest{
DiskID: diskID,
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
if err != nil {
return err
}
}
return nil
}

View File

@@ -135,14 +135,6 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"cpu_allocation_parameter": {
Type: schema.TypeString,
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Computed: true,
},
"created_by": { "created_by": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -243,6 +235,14 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"cpu_allocation_parameter": {
Type: schema.TypeString,
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Computed: true,
},
"uniq_pools": { "uniq_pools": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
@@ -250,6 +250,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"sdn_access_group_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_ids": { "storage_policy_ids": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,

View File

@@ -21,8 +21,7 @@ func flattenAccessSEPPools(accessSEPPools stpolicy.ListAccessSEPPools) []map[str
for _, asp := range accessSEPPools { for _, asp := range accessSEPPools {
temp := map[string]interface{}{ temp := map[string]interface{}{
"sep_id": asp.SEPID, "sep_id": asp.SEPID,
//TODO "sep_name": asp.Name,
//"name": asp.Name,
"pool_names": asp.PoolNames, "pool_names": asp.PoolNames,
} }

View File

@@ -170,6 +170,10 @@ func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
}, },
}, },
}, },

View File

@@ -58,6 +58,7 @@ func flattenDataAccount(d *schema.ResourceData, acc *account.RecordAccount) {
d.Set("resource_types", acc.ResTypes) d.Set("resource_types", acc.ResTypes)
d.Set("send_access_emails", acc.SendAccessEmails) d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status) d.Set("status", acc.Status)
d.Set("storage_policy_ids", acc.StoragePolicyIDs)
d.Set("uniq_pools", acc.UniqPools) d.Set("uniq_pools", acc.UniqPools)
d.Set("zone_ids", flattenZones(acc.ZoneIDs)) d.Set("zone_ids", flattenZones(acc.ZoneIDs))
d.Set("updated_time", acc.UpdatedTime) d.Set("updated_time", acc.UpdatedTime)

View File

@@ -0,0 +1,391 @@
package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceDiskV1() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
},
"gid": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
},
"disk_name": {
Type: schema.TypeString,
Required: true,
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"desc": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Required: true,
},
"ssd_size": {
Type: schema.TypeInt,
Optional: true,
},
"iops": {
Type: schema.TypeInt,
Optional: true,
Description: "max IOPS disk can perform",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"pool": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"node_ids": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"detach": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "detach disk from machine first",
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "whether to completely delete the disk, works only with non attached disks",
},
"shareable": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"restore": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "restore deleting disk",
},
"account_name": {
Type: schema.TypeString,
Computed: true,
},
"acl": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
},
"computes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeString,
Computed: true,
},
"compute_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"destruction_time": {
Type: schema.TypeInt,
Computed: true,
},
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"disk_path": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"images": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"iotune": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"read_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"size_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
},
},
"iqn": {
Type: schema.TypeString,
Computed: true,
},
"login": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Computed: true,
},
"params": {
Type: schema.TypeString,
Computed: true,
},
"parent_id": {
Type: schema.TypeInt,
Computed: true,
},
"passwd": {
Type: schema.TypeString,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
},
"purge_time": {
Type: schema.TypeInt,
Computed: true,
},
"replication": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
Description: "Replication status",
},
"reality_device_number": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"res_id": {
Type: schema.TypeString,
Computed: true,
},
"res_name": {
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Computed: true,
},
"sep_type": {
Type: schema.TypeString,
Computed: true,
},
"size_used": {
Type: schema.TypeFloat,
Computed: true,
},
"snapshots": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"label": {
Type: schema.TypeString,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"res_id": {
Type: schema.TypeString,
Computed: true,
},
"snap_set_guid": {
Type: schema.TypeString,
Computed: true,
},
"snap_set_time": {
Type: schema.TypeInt,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
},
}
}

View File

@@ -418,7 +418,7 @@ func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m inte
func ResourceDisk() *schema.Resource { func ResourceDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceDiskCreate, CreateContext: resourceDiskCreate,
ReadContext: resourceDiskRead, ReadContext: resourceDiskRead,
@@ -438,5 +438,12 @@ func ResourceDisk() *schema.Resource {
}, },
Schema: resourceDiskSchemaMake(), Schema: resourceDiskSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceDiskV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourceDiskUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -0,0 +1,14 @@
package disks
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceDiskUpgradeV1: upgrading state")
rawState["present_to"] = make(map[string]uint64)
return rawState, nil
}

View File

@@ -70,6 +70,36 @@ func flattenFlipgroup(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
d.Set("updated_time", flip.UpdatedTime) d.Set("updated_time", flip.UpdatedTime)
} }
func flattenFlipgroupResource(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
d.Set("flipgroup_id", flip.ID)
d.Set("account_id", flip.AccountID)
d.Set("account_name", flip.AccountName)
d.Set("client_ids", flip.ClientIDs)
d.Set("client_names", flip.ClientNames)
d.Set("client_type", flip.ClientType)
d.Set("conn_id", flip.ConnID)
d.Set("conn_type", flip.ConnType)
d.Set("created_by", flip.CreatedBy)
d.Set("created_time", flip.CreatedTime)
d.Set("default_gw", flip.DefaultGW)
d.Set("deleted_by", flip.DeletedBy)
d.Set("deleted_time", flip.DeletedTime)
d.Set("desc", flip.Description)
d.Set("gid", flip.GID)
d.Set("guid", flip.GUID)
d.Set("ip", flip.IP)
d.Set("milestones", flip.Milestones)
d.Set("name", flip.Name)
d.Set("net_id", flip.NetID)
d.Set("net_type", flip.NetType)
d.Set("network", flip.Network)
d.Set("rg_id", flip.RGID)
d.Set("rg_name", flip.RGName)
d.Set("status", flip.Status)
d.Set("updated_by", flip.UpdatedBy)
d.Set("updated_time", flip.UpdatedTime)
}
func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} { func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(fg.Data)) res := make([]map[string]interface{}, 0, len(fg.Data))
for _, flip := range fg.Data { for _, flip := range fg.Data {

View File

@@ -110,7 +110,7 @@ func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("The flipgroup status is destroyed and cannot be read.") return diag.Errorf("The flipgroup status is destroyed and cannot be read.")
} }
flattenFlipgroup(d, fg) flattenFlipgroupResource(d, fg)
log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s", log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s",
d.Id(), d.Get("name").(string)) d.Id(), d.Get("name").(string))

File diff suppressed because it is too large Load Diff

View File

@@ -207,7 +207,7 @@ func resourceImageCDROMEdit(ctx context.Context, d *schema.ResourceData, m inter
func ResourceCDROMImage() *schema.Resource { func ResourceCDROMImage() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceCDROMImageCreate, CreateContext: resourceCDROMImageCreate,
ReadContext: resourceCDROMImageRead, ReadContext: resourceCDROMImageRead,
@@ -227,5 +227,12 @@ func ResourceCDROMImage() *schema.Resource {
}, },
Schema: resourceCDROMImageSchemaMake(), Schema: resourceCDROMImageSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceCDROMImageV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentTOUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -356,7 +356,7 @@ func resourceImageEdit(ctx context.Context, d *schema.ResourceData, m interface{
func ResourceImage() *schema.Resource { func ResourceImage() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageCreate, CreateContext: resourceImageCreate,
ReadContext: resourceImageRead, ReadContext: resourceImageRead,
@@ -376,5 +376,12 @@ func ResourceImage() *schema.Resource {
}, },
Schema: resourceImageSchemaMake(), Schema: resourceImageSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentTOUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -254,7 +254,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource
func ResourceImageFromBlankCompute() *schema.Resource { func ResourceImageFromBlankCompute() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageFromBlankComputeCreate, CreateContext: resourceImageFromBlankComputeCreate,
ReadContext: resourceImageFromBlankComputeRead, ReadContext: resourceImageFromBlankComputeRead,
@@ -274,5 +274,12 @@ func ResourceImageFromBlankCompute() *schema.Resource {
}, },
Schema: resourceImageFromBlankComputeSchemaMake(), Schema: resourceImageFromBlankComputeSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageFromBlankComputeV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentTOUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -256,7 +256,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource
func ResourceImageFromPlatformDisk() *schema.Resource { func ResourceImageFromPlatformDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceImageFromPlatformDiskCreate, CreateContext: resourceImageFromPlatformDiskCreate,
ReadContext: resourceImageFromPlatformDiskRead, ReadContext: resourceImageFromPlatformDiskRead,
@@ -276,5 +276,12 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
}, },
Schema: resourceImageFromPlatformDiskSchemaMake(), Schema: resourceImageFromPlatformDiskSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageFromPlatformDiskV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentTOUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -183,7 +183,7 @@ func resourceImageLink(ctx context.Context, d *schema.ResourceData, m interface{
func ResourceVirtualImage() *schema.Resource { func ResourceVirtualImage() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 2,
CreateContext: resourceVirtualImageCreate, CreateContext: resourceVirtualImageCreate,
ReadContext: resourceVirtualImageRead, ReadContext: resourceVirtualImageRead,
@@ -203,5 +203,12 @@ func ResourceVirtualImage() *schema.Resource {
}, },
Schema: resourceVirtualImageSchemaMake(), Schema: resourceVirtualImageSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceVirtualImageV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentTOUpgradeV1,
Version: 1,
},
},
} }
} }

View File

@@ -0,0 +1,14 @@
package image
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourcePresentTOUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourcePresentTOUpgradeV1: upgrading state")
rawState["present_to"] = make(map[string]uint64)
return rawState, nil
}

View File

@@ -45,6 +45,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("clone_reference", computeRec.CloneReference) d.Set("clone_reference", computeRec.CloneReference)
d.Set("clones", computeRec.Clones) d.Set("clones", computeRec.Clones)
d.Set("computeci_id", computeRec.ComputeCIID) d.Set("computeci_id", computeRec.ComputeCIID)
d.Set("cpu", computeRec.CPUs)
d.Set("created_by", computeRec.CreatedBy) d.Set("created_by", computeRec.CreatedBy)
d.Set("created_time", computeRec.CreatedTime) d.Set("created_time", computeRec.CreatedTime)
d.Set("custom_fields", string(customFields)) d.Set("custom_fields", string(customFields))
@@ -64,6 +65,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("image_name", computeRec.ImageName) d.Set("image_name", computeRec.ImageName)
d.Set("interfaces", flattenInterfaces(computeRec.Interfaces)) d.Set("interfaces", flattenInterfaces(computeRec.Interfaces))
d.Set("lock_status", computeRec.LockStatus) d.Set("lock_status", computeRec.LockStatus)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("manager_id", computeRec.ManagerID) d.Set("manager_id", computeRec.ManagerID)
d.Set("manager_type", computeRec.ManagerType) d.Set("manager_type", computeRec.ManagerType)
d.Set("migrationjob", computeRec.MigrationJob) d.Set("migrationjob", computeRec.MigrationJob)
@@ -78,14 +80,17 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("os_users", flattenOSUsers(computeRec.OSUsers)) d.Set("os_users", flattenOSUsers(computeRec.OSUsers))
d.Set("pinned", computeRec.PinnedToStack) d.Set("pinned", computeRec.PinnedToStack)
d.Set("preferred_cpu", computeRec.PreferredCPU) d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID) d.Set("reference_id", computeRec.ReferenceID)
d.Set("registered", computeRec.Registered) d.Set("registered", computeRec.Registered)
d.Set("res_name", computeRec.ResName) d.Set("res_name", computeRec.ResName)
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus) d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
d.Set("rg_name", computeRec.RGName) d.Set("rg_name", computeRec.RGName)
d.Set("rg_id", computeRec.RGID)
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets)) d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
d.Set("stack_id", computeRec.StackID) d.Set("stack_id", computeRec.StackID)
d.Set("stack_name", computeRec.StackName) d.Set("stack_name", computeRec.StackName)
d.Set("started", computeRec.TechStatus == "STARTED")
d.Set("stateless_sep_id", computeRec.StatelessSEPID) d.Set("stateless_sep_id", computeRec.StatelessSEPID)
d.Set("stateless_sep_type", computeRec.StatelessSEPType) d.Set("stateless_sep_type", computeRec.StatelessSEPType)
d.Set("status", computeRec.Status) d.Set("status", computeRec.Status)
@@ -107,6 +112,9 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming) d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID) d.Set("zone_id", computeRec.ZoneID)
d.Set("os_version", computeRec.OSVersion) d.Set("os_version", computeRec.OSVersion)
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
return nil return nil
} }
@@ -227,10 +235,6 @@ func flattenQOS(qos compute.QOS) []map[string]interface{} {
func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} { func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(disksList)) res := make([]map[string]interface{}, 0, len(disksList))
if len(disksBlocks) == 0 {
return res
}
sort.Slice(disksList, func(i, j int) bool { sort.Slice(disksList, func(i, j int) bool {
return disksList[i].ID < disksList[j].ID return disksList[i].ID < disksList[j].ID
}) })
@@ -242,8 +246,25 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
continue continue
} }
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool) var pernamentlyValue bool
nodeIds := disksBlocks[indexDataDisks].(map[string]interface{})["node_ids"].(*schema.Set) if indexDataDisks < len(disksBlocks) {
if diskBlock, ok := disksBlocks[indexDataDisks].(map[string]interface{}); ok {
if perm, exists := diskBlock["permanently"]; exists {
if permBool, ok := perm.(bool); ok {
pernamentlyValue = permBool
}
}
}
}
var nodeIds *schema.Set
if indexDataDisks < len(disksBlocks) {
if diskBlock, ok := disksBlocks[indexDataDisks].(map[string]interface{}); ok {
if nodeIds, exists := diskBlock["node_ids"]; exists {
nodeIds = nodeIds.(*schema.Set)
}
}
}
temp := map[string]interface{}{ temp := map[string]interface{}{
"disk_name": disk.Name, "disk_name": disk.Name,
@@ -258,10 +279,17 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
"shareable": disk.Shareable, "shareable": disk.Shareable,
"size_used": disk.SizeUsed, "size_used": disk.SizeUsed,
"size_max": disk.SizeMax, "size_max": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo, "present_to": disk.PresentTo,
"storage_policy_id": disk.StoragePolicyID, "storage_policy_id": disk.StoragePolicyID,
"to_clean": disk.ToClean, "to_clean": disk.ToClean,
"permanently": pernamentlyValue,
"devicename": disk.DeviceName,
"create_by": disk.CreatedBy,
"create_time": disk.CreatedTime,
"delete_by": disk.DeletedBy,
"delete_time": disk.DeletedTime,
"update_time": disk.UpdatedTime,
"iotune": flattenIOTune(disk.IOTune),
} }
res = append(res, temp) res = append(res, temp)
indexDataDisks++ indexDataDisks++
@@ -556,6 +584,16 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
return res return res
} }
func flattenLoaderMetaIso(loaderMetaIso compute.LoaderMetaIso) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"device_name": loaderMetaIso.DeviceName,
"path": loaderMetaIso.Path,
}
res = append(res, temp)
return res
}
func flattenComputeAudits(computeAudits compute.ListDetailedAudits) []map[string]interface{} { func flattenComputeAudits(computeAudits compute.ListDetailedAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(computeAudits.Data)) res := make([]map[string]interface{}, 0, len(computeAudits.Data))
for _, computeAudit := range computeAudits.Data { for _, computeAudit := range computeAudits.Data {
@@ -808,6 +846,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
d.Set("hot_resize", compFacts.HotResize) d.Set("hot_resize", compFacts.HotResize)
d.Set("network_interface_naming", compFacts.NetworkInterfaceNaming) d.Set("network_interface_naming", compFacts.NetworkInterfaceNaming)
d.Set("zone_id", compFacts.ZoneID) d.Set("zone_id", compFacts.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(compFacts.LoaderMetaIso))
d.Set("os_version", compFacts.OSVersion) d.Set("os_version", compFacts.OSVersion)
//extra fields setting //extra fields setting
bootDisk := findBootDisk(compFacts.Disks) bootDisk := findBootDisk(compFacts.Disks)
@@ -868,7 +907,10 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"boot_partition": disk.BootPartition, "boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber, "bus_number": disk.BusNumber,
"created_time": disk.CreatedTime, "created_time": disk.CreatedTime,
"created_by": disk.CreatedBy,
"deleted_time": disk.DeletedTime, "deleted_time": disk.DeletedTime,
"deleted_by": disk.DeletedBy,
"devicename": disk.DeviceName,
"desc": disk.Description, "desc": disk.Description,
"destruction_time": disk.DestructionTime, "destruction_time": disk.DestructionTime,
"disk_path": disk.DiskPath, "disk_path": disk.DiskPath,
@@ -907,6 +949,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus, "tech_status": disk.TechStatus,
"type": disk.Type, "type": disk.Type,
"to_clean": disk.ToClean, "to_clean": disk.ToClean,
"updated_time": disk.UpdatedTime,
} }
res = append(res, temp) res = append(res, temp)
} }

View File

@@ -17,9 +17,11 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
errs = append(errs, err) errs = append(errs, err)
} }
if !d.Get("create_blank").(bool) {
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil { if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
errs = append(errs, err) errs = append(errs, err)
} }
}
if netErrs := existNetworks(ctx, d, c); errs != nil { if netErrs := existNetworks(ctx, d, c); errs != nil {
errs = append(errs, netErrs...) errs = append(errs, netErrs...)

View File

@@ -231,7 +231,32 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86) var apiResp uint64
var err error
if d.Get("create_blank").(bool) {
log.Debugf("resourceComputeCreate: using createBlank endpoint")
createBlankReq := kvmx86.CreateBlankRequest{
RGID: createReqX86.RGID,
Name: createReqX86.Name,
CPU: createReqX86.CPU,
RAM: createReqX86.RAM,
StoragePolicyID: createReqX86.StoragePolicyID,
WithoutBootDisk: createReqX86.WithoutBootDisk,
BootDisk: createReqX86.BootDisk,
SEPID: createReqX86.SEPID,
Pool: createReqX86.Pool,
DataDisks: createReqX86.DataDisks,
Interfaces: createReqX86.Interfaces,
Description: createReqX86.Description,
Chipset: createReqX86.Chipset,
PreferredCPU: createReqX86.PreferredCPU,
ZoneID: createReqX86.ZoneID,
OSVersion: createReqX86.OSVersion,
}
apiResp, err = c.CloudBroker().KVMX86().CreateBlank(ctx, createBlankReq)
} else {
apiResp, err = c.CloudBroker().KVMX86().Create(ctx, createReqX86)
}
if err != nil { if err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
@@ -344,26 +369,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
if pin, ok := d.GetOk("pin_to_stack"); ok && pin.(bool) {
req := compute.PinToStackRequest{
ComputeID: computeId,
TargetStackID: uint64(d.Get("stack_id").(int)),
}
if force, ok := d.Get("force_pin").(bool); ok {
req.Force = force
}
if autoStart, ok := d.Get("auto_start_w_node").(bool); ok {
req.AutoStart = autoStart
}
_, err := c.CloudBroker().Compute().PinToStack(ctx, req)
if err != nil {
warnings.Add(err)
}
}
if libvirtSettings, ok := d.GetOk("libvirt_settings"); ok { if libvirtSettings, ok := d.GetOk("libvirt_settings"); ok {
if libvirtSettings.(*schema.Set).Len() > 0 { if libvirtSettings.(*schema.Set).Len() > 0 {
lvs := libvirtSettings.(*schema.Set).List() lvs := libvirtSettings.(*schema.Set).List()
@@ -444,6 +449,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if start, ok := d.GetOk("started"); ok && start.(bool) { if start, ok := d.GetOk("started"); ok && start.(bool) {
req := compute.StartRequest{ComputeID: computeId} req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId) log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil { if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
warnings.Add(err) warnings.Add(err)
@@ -456,6 +464,36 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
} }
if pin, ok := d.GetOk("pin_to_stack"); ok && pin.(bool) {
start, _ := d.GetOk("started")
_, stackOk := d.GetOk("stack_id")
if !start.(bool) && !stackOk {
warnings.Add(errors.New("cannot pin to stack a VM, that is not started and stack_id is not set"))
} else {
req := compute.PinToStackRequest{
ComputeID: computeId,
}
if stackID, ok := d.Get("stack_id").(int); ok {
req.TargetStackID = uint64(stackID)
}
if force, ok := d.Get("force_pin").(bool); ok {
req.Force = force
}
if autoStart, ok := d.Get("auto_start_w_node").(bool); ok {
req.AutoStart = autoStart
}
_, err := c.CloudBroker().Compute().PinToStack(ctx, req)
if err != nil {
warnings.Add(err)
}
}
}
if affinityLabel, ok := d.GetOk("affinity_label"); ok { if affinityLabel, ok := d.GetOk("affinity_label"); ok {
req := compute.AffinityLabelSetRequest{ req := compute.AffinityLabelSetRequest{
ComputeIDs: []uint64{ ComputeIDs: []uint64{
@@ -646,6 +684,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if err != nil { if err != nil {
warnings.Add(err) warnings.Add(err)
} }
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
warnings.Add(err)
}
} }
} }
@@ -950,33 +991,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
computeId, _ := strconv.ParseUint(d.Id(), 10, 64) computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if start, ok := d.GetOk("started"); ok {
if start.(bool) {
req := compute.StopRequest{ComputeID: computeId}
log.Debugf("resourceComputeDelete: stoping Compute ID %d", computeId)
if _, err := c.CloudBroker().Compute().Stop(ctx, req); err != nil {
diag.FromErr(err)
}
}
}
pciList, ok := d.GetOk("pci_devices")
if d.Get("permanently").(bool) && ok {
pciDevices := pciList.(*schema.Set).List()
for _, v := range pciDevices {
pciID := v.(int)
req := compute.DetachPCIDeviceRequest{
ComputeID: computeId,
DeviceID: uint64(pciID),
}
_, err := c.CloudBroker().Compute().DetachPciDevice(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
req := compute.DeleteRequest{ req := compute.DeleteRequest{
ComputeID: computeId, ComputeID: computeId,
Permanently: d.Get("permanently").(bool), Permanently: d.Get("permanently").(bool),

View File

@@ -530,6 +530,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool, Type: schema.TypeBool,
Computed: true, Computed: true,
}, },
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}, },
}, },
}, },
@@ -971,6 +987,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"loader_meta_iso": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"device_name": {
Type: schema.TypeString,
Computed: true,
},
"path": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"user_data": { "user_data": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@@ -3374,6 +3406,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Default: false, 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.", Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
}, },
"create_blank": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
},
"boot_disk_size": { "boot_disk_size": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
@@ -3698,8 +3736,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
"disk_type": { "disk_type": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'", Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
}, },
"pool": { "pool": {
@@ -3732,6 +3768,81 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true, Optional: true,
Description: "Disk deletion status", Description: "Disk deletion status",
}, },
"iotune": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"read_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"read_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"size_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"total_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_bytes_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"write_iops_sec_max": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
},
},
"disk_id": { "disk_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
@@ -3760,6 +3871,30 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool, Type: schema.TypeBool,
Computed: true, Computed: true,
}, },
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"create_by": {
Type: schema.TypeString,
Computed: true,
},
"create_time": {
Type: schema.TypeInt,
Computed: true,
},
"delete_by": {
Type: schema.TypeString,
Computed: true,
},
"delete_time": {
Type: schema.TypeInt,
Computed: true,
},
"update_time": {
Type: schema.TypeInt,
Computed: true,
},
}, },
}, },
}, },
@@ -4561,5 +4696,21 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"loader_meta_iso": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"device_name": {
Type: schema.TypeString,
Computed: true,
},
"path": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
} }
} }

View File

@@ -184,7 +184,11 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
} }
if isStopRequired { if isStopRequired {
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
return err return err
} }
} }
@@ -235,6 +239,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
resizedDisks := make([]interface{}, 0) resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0) renamedDisks := make([]interface{}, 0)
changeStoragePolicyDisks := make([]interface{}, 0) changeStoragePolicyDisks := make([]interface{}, 0)
iotuneUpdatedDisks := make([]interface{}, 0)
presentNewDisks := make([]interface{}, 0) presentNewDisks := make([]interface{}, 0)
presentOldDisks := make([]interface{}, 0) presentOldDisks := make([]interface{}, 0)
@@ -283,6 +288,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if isChangeStoragePolicy(oldConv, el) { if isChangeStoragePolicy(oldConv, el) {
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el) changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
} }
if isChangeIOTuneDisk(oldConv, el) {
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
}
} }
if len(deletedDisks) > 0 { if len(deletedDisks) > 0 {
@@ -320,9 +328,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if diskConv["sep_id"].(int) != 0 { if diskConv["sep_id"].(int) != 0 {
req.SepID = uint64(diskConv["sep_id"].(int)) req.SepID = uint64(diskConv["sep_id"].(int))
} }
if diskConv["disk_type"].(string) != "" {
req.DiskType = diskConv["disk_type"].(string)
}
if diskConv["pool"].(string) != "" { if diskConv["pool"].(string) != "" {
req.Pool = diskConv["pool"].(string) req.Pool = diskConv["pool"].(string)
} }
@@ -353,10 +358,34 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
} }
} }
} }
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
if diskConv["disk_type"].(string) == "B" {
continue
}
iotuneMap := iotuneRaw[0].(map[string]interface{})
limitReq := disks.LimitIORequest{
DiskID: diskID,
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, limitReq)
if err != nil { if err != nil {
return err return err
} }
} }
}
} }
if len(resizedDisks) > 0 { if len(resizedDisks) > 0 {
@@ -409,6 +438,44 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
} }
} }
if len(iotuneUpdatedDisks) > 0 {
for _, disk := range iotuneUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
continue
}
diskID := uint64(diskConv["disk_id"].(int))
if diskID == 0 {
continue
}
iotuneRaw, ok := diskConv["iotune"].([]interface{})
if !ok || len(iotuneRaw) == 0 {
continue
}
iotuneMap := iotuneRaw[0].(map[string]interface{})
req := disks.LimitIORequest{
DiskID: diskID,
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
if err != nil {
return err
}
}
}
for i := range presentNewDisks { for i := range presentNewDisks {
newDisk := presentNewDisks[i].(map[string]interface{}) newDisk := presentNewDisks[i].(map[string]interface{})
oldDisk := presentOldDisks[i].(map[string]interface{}) oldDisk := presentOldDisks[i].(map[string]interface{})
@@ -769,7 +836,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
if needStart { if needStart {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64) computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil { var altBootID uint64
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
altBootID = uint64(altBootIDRaw)
} else {
altBootID = 0
}
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
apiErrCount += numErr apiErrCount += numErr
lastSavedError = err lastSavedError = err
} }
@@ -1096,7 +1169,11 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
// If used to be STARTED, we need to start it after update // If used to be STARTED, we need to start it after update
if isStopRequired { if isStopRequired {
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
return err return err
} }
} }
@@ -1567,6 +1644,9 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter
} }
startReq := compute.StartRequest{ComputeID: computeId} startReq := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
startReq.AltBootID = uint64(altBootID)
}
log.Debugf("utilityComputeRollback: starting compute %d", computeId) log.Debugf("utilityComputeRollback: starting compute %d", computeId)
@@ -1618,6 +1698,13 @@ func utilityComputePinToStack(ctx context.Context, d *schema.ResourceData, m int
computeId, _ := strconv.ParseUint(d.Id(), 10, 64) computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
start, _ := d.GetOk("started")
_, stackOk := d.GetOk("stack_id")
if !start.(bool) && !stackOk {
errors.New("cannot pin to stack a VM, that is not started and stack_id is not set")
}
oldPin, newPin := d.GetChange("pin_to_stack") oldPin, newPin := d.GetChange("pin_to_stack")
if oldPin.(bool) && !newPin.(bool) { if oldPin.(bool) && !newPin.(bool) {
req := compute.UnpinFromStackRequest{ req := compute.UnpinFromStackRequest{
@@ -1817,10 +1904,14 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface
return nil return nil
} }
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) { func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
startReq := compute.StartRequest{ComputeID: computeID} startReq := compute.StartRequest{ComputeID: computeID}
if altBootID > 0 {
startReq.AltBootID = altBootID
}
log.Debugf("utilityComputeStart: starting compute %d", computeID) log.Debugf("utilityComputeStart: starting compute %d", computeID)
_, err := c.CloudBroker().Compute().Start(ctx, startReq) _, err := c.CloudBroker().Compute().Start(ctx, startReq)
if err != nil { if err != nil {
@@ -1921,6 +2012,100 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
return false return false
} }
func isChangeIOTuneDisk(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) {
continue
}
oldIOTune := elOldConv["iotune"].([]interface{})
newIOTune := elConv["iotune"].([]interface{})
if len(oldIOTune) == 0 && len(newIOTune) == 0 {
return false
}
if len(oldIOTune) == 0 || len(newIOTune) == 0 {
return true
}
oldMap := oldIOTune[0].(map[string]interface{})
newMap := newIOTune[0].(map[string]interface{})
return oldMap["read_bytes_sec"].(int) != newMap["read_bytes_sec"].(int) ||
oldMap["read_bytes_sec_max"].(int) != newMap["read_bytes_sec_max"].(int) ||
oldMap["read_iops_sec"].(int) != newMap["read_iops_sec"].(int) ||
oldMap["read_iops_sec_max"].(int) != newMap["read_iops_sec_max"].(int) ||
oldMap["size_iops_sec"].(int) != newMap["size_iops_sec"].(int) ||
oldMap["total_bytes_sec"].(int) != newMap["total_bytes_sec"].(int) ||
oldMap["total_bytes_sec_max"].(int) != newMap["total_bytes_sec_max"].(int) ||
oldMap["total_iops_sec"].(int) != newMap["total_iops_sec"].(int) ||
oldMap["total_iops_sec_max"].(int) != newMap["total_iops_sec_max"].(int) ||
oldMap["write_bytes_sec"].(int) != newMap["write_bytes_sec"].(int) ||
oldMap["write_bytes_sec_max"].(int) != newMap["write_bytes_sec_max"].(int) ||
oldMap["write_iops_sec"].(int) != newMap["write_iops_sec"].(int) ||
oldMap["write_iops_sec_max"].(int) != newMap["write_iops_sec_max"].(int)
}
return false
}
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
diskList := d.Get("disks").([]interface{})
iotuneArr := make([]interface{}, 0, len(diskList))
hasAny := false
for _, elem := range diskList {
diskVal := elem.(map[string]interface{})
iotune := diskVal["iotune"].([]interface{})
iotuneArr = append(iotuneArr, iotune)
if len(iotune) > 0 {
hasAny = true
}
}
if !hasAny {
return nil
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return err
}
bootDisk := findBootDisk(computeRec.Disks)
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
for i, diskID := range computeDisksIDs {
if i >= len(iotuneArr) {
continue
}
iotune, ok := iotuneArr[i].([]interface{})
if !ok || len(iotune) == 0 {
continue
}
iotuneMap := iotune[0].(map[string]interface{})
req := disks.LimitIORequest{
DiskID: diskID.(uint64),
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
if err != nil {
return err
}
}
return nil
}
// isChangeNodesDisk get slice of new disks values and current value disk, // isChangeNodesDisk get slice of new disks values and current value disk,
// if need change nodes on disk returns true and new disk value, else return false and nil // if need change nodes on disk returns true and new disk value, else return false and nil
func isChangeNodesDisk(els []interface{}, elOld interface{}) (bool, interface{}) { func isChangeNodesDisk(els []interface{}, elOld interface{}) (bool, interface{}) {

View File

@@ -1741,6 +1741,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
}, },
}, },
"sdn_access_group_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_ids": { "storage_policy_ids": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,

View File

@@ -21,8 +21,7 @@ func flattenAccessSEPPools(accessSEPPools stpolicy.ListAccessSEPPools) []map[str
for _, asp := range accessSEPPools { for _, asp := range accessSEPPools {
temp := map[string]interface{}{ temp := map[string]interface{}{
"sep_id": asp.SEPID, "sep_id": asp.SEPID,
//TODO "sep_name": asp.Name,
//"name": asp.Name,
"pool_names": asp.PoolNames, "pool_names": asp.PoolNames,
} }

View File

@@ -244,6 +244,10 @@ func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
}, },
}, },
}, },

View File

@@ -15,11 +15,11 @@ func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) {
d.Set("name", details.Name) d.Set("name", details.Name)
d.Set("mac", details.MAC) d.Set("mac", details.MAC)
d.Set("description", details.Description) d.Set("description", details.Description)
d.Set("accountIds", details.AccountIDs) d.Set("account_ids", details.AccountIDs)
d.Set("ovsBridge", details.OVSBridge) d.Set("ovs_bridge", details.OVSBridge)
d.Set("nativeVlanId", details.NativeVLANID) d.Set("native_vlan_id", details.NativeVLANID)
d.Set("status", details.Status) d.Set("status", details.Status)
d.Set("trunkTags", details.TrunkTags) d.Set("trunk_tags", details.TrunkTags)
d.Set("created_at", details.CreatedAt) d.Set("created_at", details.CreatedAt)
d.Set("created_by", details.CreatedBy) d.Set("created_by", details.CreatedBy)
d.Set("updated_at", details.UpdatedAt) d.Set("updated_at", details.UpdatedAt)

View File

@@ -33,6 +33,7 @@ package vfpool
import ( import (
"context" "context"
"fmt"
"strconv" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -85,6 +86,12 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
} }
config, configOk := d.GetOk("config") config, configOk := d.GetOk("config")
enableVal := d.Get("enable").(bool)
if enableVal && !configOk {
return diag.FromErr(fmt.Errorf("enable requires config to be set"))
}
if configOk { if configOk {
configArray := config.(*schema.Set).List() configArray := config.(*schema.Set).List()
req.Config = make([]vfpool.Config, 0, len(configArray)) req.Config = make([]vfpool.Config, 0, len(configArray))
@@ -117,11 +124,9 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
warnings := dc.Warnings{} warnings := dc.Warnings{}
if enable, ok := d.GetOk("enable"); ok { if err := utilityVFPoolEnabled(ctx, m, enableVal, vfPoolID); err != nil {
if err := utilityVFPoolEnabled(ctx, m, enable.(bool), vfPoolID, configOk); err != nil {
warnings.Add(err) warnings.Add(err)
} }
}
log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID) log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID)
return append(resourceVFPoolRead(ctx, d, m), warnings.Get()...) return append(resourceVFPoolRead(ctx, d, m), warnings.Get()...)
@@ -147,20 +152,12 @@ func resourceVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID) log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID)
_, ok := d.GetOk("config") if d.HasChanges("name", "description", "account_access", "rg_access", "config", "enable") {
if d.HasChanges("name,", "description", "account_access", "rg_access,", "config") {
if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil { if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil {
return diag.FromErr(err) return diag.FromErr(err)
} }
} }
if d.HasChange("enable") {
if err := utilityVFPoolEnabled(ctx, m, d.Get("enable").(bool), vfPoolID, ok); err != nil {
return diag.FromErr(err)
}
}
log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID) log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID)
return resourceVFPoolRead(ctx, d, m) return resourceVFPoolRead(ctx, d, m)

View File

@@ -64,37 +64,26 @@ func utilityVFpoolCheckPresence(ctx context.Context, d *schema.ResourceData, m i
return vfpoolData, nil return vfpoolData, nil
} }
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64, configOk bool) error { func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64) error {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
if enable && configOk { var err error
req := vfpool.EnableRequest{
VFPoolID: vfPoolID, if enable {
} _, err = c.CloudBroker().VFPool().Enable(ctx, vfpool.EnableRequest{VFPoolID: vfPoolID})
_, err := c.CloudBroker().VFPool().Enable(ctx, req) } else {
if err != nil { _, err = c.CloudBroker().VFPool().Disable(ctx, vfpool.DisableRequest{VFPoolID: vfPoolID})
return err
}
}
if enable && !configOk {
return fmt.Errorf("you must provide configuration for this resource, after enabling it")
}
if !enable {
req := vfpool.DisableRequest{
VFPoolID: vfPoolID,
}
_, err := c.CloudBroker().VFPool().Disable(ctx, req)
if err != nil {
return err
}
} }
log.Debugf("utilityVFPoolEnabled: enable=%v vfPool ID %d after completing its resource configuration", enable, vfPoolID) return err
return nil
} }
func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error { func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error {
hasConfig := len(d.Get("config").(*schema.Set).List()) > 0
if d.Get("enable").(bool) && !hasConfig {
return fmt.Errorf("enable requires config to be set")
}
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
vfPool, err := utilityVFpoolCheckPresence(ctx, d, m) vfPool, err := utilityVFpoolCheckPresence(ctx, d, m)
@@ -190,7 +179,7 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
} }
log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req) log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req)
if len(d.Get("config").(*schema.Set).List()) > 0 && d.Get("enable").(bool) { if hasConfig && d.Get("enable").(bool) {
reqEnable := vfpool.EnableRequest{ reqEnable := vfpool.EnableRequest{
VFPoolID: vfPoolID, VFPoolID: vfPoolID,
} }
@@ -201,8 +190,6 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return err return err
} }
log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID) log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID)
} else {
return (fmt.Errorf("the vfPool is not enabled after update, you must provide configuration for this resource, after enabling it"))
} }
return nil return nil

View File

@@ -65,7 +65,7 @@ resource "decort_bservice_group" "bsg" {
#обязательный параметр #обязательный параметр
#тип - целое число #тип - целое число
#используется при создании и обновлении #используется при создании и обновлении
ram = 256 ram = 512
#размер диска для выч. ресурса, в ГБ #размер диска для выч. ресурса, в ГБ
#обязательный параметр #обязательный параметр

View File

@@ -112,6 +112,18 @@ resource "decort_kvmvm" "comp" {
#используется при создании #используется при создании
#without_boot_disk = true #without_boot_disk = true
#создание без образа ОС
#опциональный параметр
#тип - булев
#используется при создании
#create_blank = false
#id образа CD-ROM для загрузки
#опциональный параметр
#тип - целое число
#используется при создании и обновлении
#alt_boot_id = 1
#необходимость выравнивать ВМ по NUMA #необходимость выравнивать ВМ по NUMA
#опциональный параметр #опциональный параметр
#возможные значения - "none, "strict", "loose" #возможные значения - "none, "strict", "loose"
@@ -160,11 +172,6 @@ resource "decort_kvmvm" "comp" {
#тип - целое число #тип - целое число
#size = 5 #size = 5
#тип диска
#опциональный параметр
#тип - строка
#disk_type = "D"
#id сепа #id сепа
#опциональный параметр #опциональный параметр
#тип - целое число #тип - целое число
@@ -189,6 +196,25 @@ resource "decort_kvmvm" "comp" {
#опциональный параметр #опциональный параметр
#тип - булев #тип - булев
#permanently = false #permanently = false
#ограничения ввода-вывода для диска
#опциональный параметр
#тип - блок
#iotune {
#read_bytes_sec = 0
#read_bytes_sec_max = 0
#read_iops_sec = 0
#read_iops_sec_max = 0
#size_iops_sec = 0
#total_bytes_sec = 0
#total_bytes_sec_max = 0
#total_iops_sec = 0
#total_iops_sec_max = 0
#write_bytes_sec = 0
#write_bytes_sec_max = 0
#write_iops_sec = 0
#write_iops_sec_max = 0
#}
#} #}
#правила affinity #правила affinity
@@ -347,7 +373,7 @@ resource "decort_kvmvm" "comp" {
#опциональный параметр #опциональный параметр
#тип - блок #тип - блок
#используется при создании и обновлении #используется при создании и обновлении
#security groups { #security_groups {
#тип сети #тип сети
#обязательный параметр #обязательный параметр
#тип - строка #тип - строка

View File

@@ -125,7 +125,7 @@ resource "decort_cb_account" "acc" {
#id политики хранения #id политики хранения
#обязательный параметр #обязательный параметр
#тип - целое число #тип - целое число
#storage_policy_id = 111 #id = 111
#лимит ресурсов хранения в ГБ #лимит ресурсов хранения в ГБ
#опциональный параметр #опциональный параметр

View File

@@ -82,6 +82,12 @@ resource "decort_cb_kvmvm" "comp" {
#используется при создании #используется при создании
#without_boot_disk = true #without_boot_disk = true
#создание без образа ОС
#опциональный параметр
#тип - булев
#используется при создании
#create_blank = false
#размер загрузочного диска #размер загрузочного диска
#опциональный параметр #опциональный параметр
#тип - целое число #тип - целое число
@@ -121,7 +127,7 @@ resource "decort_cb_kvmvm" "comp" {
#id образа CD-ROM для загрузки #id образа CD-ROM для загрузки
#опциональный параметр #опциональный параметр
#тип - целое число #тип - целое число
#используется при обновлении, при повторном старте вм #используется при создании и обновлении
#alt_boot_id = 1 #alt_boot_id = 1
#необходимость выравнивать ВМ по NUMA #необходимость выравнивать ВМ по NUMA
@@ -166,11 +172,6 @@ resource "decort_cb_kvmvm" "comp" {
#тип - целое число #тип - целое число
#storage_policy_id = 1 #storage_policy_id = 1
#тип диска
#опциональный параметр
#тип - строка
#disk_type = "D"
#опциональный параметр #опциональный параметр
#тип - целое число #тип - целое число
#sep_id = 1 #sep_id = 1
@@ -198,6 +199,25 @@ resource "decort_cb_kvmvm" "comp" {
#опциональный параметр #опциональный параметр
#тип - булев #тип - булев
#permanently = false #permanently = false
#ограничения ввода-вывода для диска
#опциональный параметр
#тип - блок
#iotune {
#read_bytes_sec = 0
#read_bytes_sec_max = 0
#read_iops_sec = 0
#read_iops_sec_max = 0
#size_iops_sec = 0
#total_bytes_sec = 0
#total_bytes_sec_max = 0
#total_iops_sec = 0
#total_iops_sec_max = 0
#write_bytes_sec = 0
#write_bytes_sec_max = 0
#write_iops_sec = 0
#write_iops_sec_max = 0
#}
#} #}
#правила affinity #правила affinity
@@ -361,7 +381,7 @@ resource "decort_cb_kvmvm" "comp" {
#опциональный параметр #опциональный параметр
#тип - блок #тип - блок
#используется при создании и обновлении #используется при создании и обновлении
#security groups { #security_groups {
#тип сети #тип сети
#обязательный параметр #обязательный параметр
#тип - строка #тип - строка