Compare commits

..

4 Commits

Author SHA1 Message Date
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
50 changed files with 4197 additions and 399 deletions

View File

@@ -1,223 +1,8 @@
## Version 4.10.1
### Добавлено
#### 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
| Идентификатор<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-1064 | Обязательное поле `storage_policy_id` в resources `decort_kvmvmv` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/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
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_lb_list` в cloudapi/lb и в datasource `decort_cb_lb_list` в cloudbroker/lb |
#### 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 |
## Version 4.10.5
### Исправлено
#### общие изменения
#### kvmvmm
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1116 | Исправлены уязвимости, обновлена версия go до v1.24.0 |
#### 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
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1049 | Перезагрузка виртуальной машины при изменении полей `ram` и `cpu` в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/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
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-1012 | Изменен тип поля `status` с computed на optional в datasource `decort_trunk_list` в cloudapi/trunk и в datasource `decort_cb_trunk_list` в cloudbroker/trunk |
#### zone
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BATF-887 | Исправлена ошибка при изменении поля `name` в resource `decort_cb_zone` в cloudbroker/zone |
### Удалено
#### 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 |
| BATF-1270 | Опциональное поле `iotune` в блоке `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |

View File

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

View File

@@ -64,6 +64,7 @@ description: |-
- `image_name` (String)
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `live_migration_job_id` (Number)
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `loader_type` (String)
- `lock_status` (String)
- `manager_id` (Number)
@@ -170,10 +171,13 @@ Read-Only:
- `boot_partition` (Number)
- `bus_number` (Number)
- `ckey` (String)
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `desc` (String)
- `destruction_time` (Number)
- `devicename` (String)
- `disk_id` (Number)
- `disk_path` (String)
- `gid` (Number)
@@ -211,6 +215,7 @@ Read-Only:
- `tech_status` (String)
- `to_clean` (Boolean)
- `type` (String)
- `updated_time` (Number)
<a id="nestedobjatt--disks--iotune"></a>
### 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>
### 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_types` (List of String)
- `rg_id` (Number)
- `sdn_access_group_id` (String)
- `secret` (String)
- `status` (String)
- `storage_policy_ids` (List of Number)

View File

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

View File

@@ -62,6 +62,7 @@ description: |-
- `image_id` (Number)
- `interfaces` (List of Object) (see [below for nested schema](#nestedatt--interfaces))
- `live_migration_job_id` (Number)
- `loader_meta_iso` (List of Object) (see [below for nested schema](#nestedatt--loader_meta_iso))
- `loader_type` (String)
- `lock_status` (String)
- `manager_id` (Number)
@@ -201,10 +202,13 @@ Read-Only:
- `acl` (String)
- `boot_partition` (Number)
- `bus_number` (Number)
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `description` (String)
- `destruction_time` (Number)
- `devicename` (String)
- `disk_id` (Number)
- `disk_path` (String)
- `gid` (Number)
@@ -239,6 +243,7 @@ Read-Only:
- `tech_status` (String)
- `to_clean` (Boolean)
- `type` (String)
- `updated_time` (Number)
<a id="nestedobjatt--disks--iotune"></a>
### 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>
### 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_types` (List of String)
- `rg_id` (Number)
- `sdn_access_group_id` (String)
- `secret` (String)
- `status` (String)
- `storage_policy_ids` (List of Number)

View File

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

View File

@@ -104,6 +104,7 @@ description: |-
- `id` (String) The ID of this resource.
- `image_name` (String)
- `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)
- `manager_id` (Number)
- `manager_type` (String)
@@ -189,6 +190,7 @@ Optional:
- `desc` (String) Optional description
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `image_id` (Number) Specify image id for create disk from template
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
- `node_ids` (Set of Number)
- `permanently` (Boolean) Disk deletion status
- `pool` (String) Pool name; by default will be chosen automatically
@@ -196,12 +198,38 @@ Optional:
Read-Only:
- `create_by` (String)
- `create_time` (Number)
- `delete_by` (String)
- `delete_time` (Number)
- `devicename` (String)
- `disk_id` (Number) Disk ID
- `present_to` (Map of Number)
- `shareable` (Boolean)
- `size_max` (Number)
- `size_used` (Number)
- `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>
@@ -389,6 +417,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>
### Nested Schema for `os_users`

View File

@@ -99,6 +99,7 @@ description: |-
- `guid` (Number)
- `id` (String) The ID of this resource.
- `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)
- `manager_id` (Number)
- `manager_type` (String)
@@ -183,18 +184,45 @@ Optional:
- `desc` (String) Optional description
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
- `image_id` (Number) Specify image id for create disk from template
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
- `permanently` (Boolean) Disk deletion status
- `pool` (String) Pool name; by default will be chosen automatically
- `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk
Read-Only:
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `devicename` (String)
- `disk_id` (Number) Disk ID
- `present_to` (Map of Number)
- `shareable` (Boolean)
- `size_max` (Number)
- `size_used` (Number)
- `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>
@@ -294,11 +322,17 @@ Required:
Read-Only:
- `created_by` (String)
- `created_time` (Number)
- `deleted_by` (String)
- `deleted_time` (Number)
- `desc` (String)
- `devicename` (String)
- `disk_id` (Number)
- `disk_name` (String)
- `disk_type` (String)
- `image_id` (Number)
- `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--boot_disk--iotune))
- `permanently` (Boolean)
- `pool` (String)
- `present_to` (Map of Number)
@@ -309,6 +343,27 @@ Read-Only:
- `size_used` (Number)
- `storage_policy_id` (Number)
- `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>
@@ -369,6 +424,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>
### 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/sirupsen/logrus v1.9.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.11
)
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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 h1:7RLk2Vjl6evKo4dLxlxiQCrRJSSlUwLztO3ZE/uBt+8=
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.11 h1:Y5meH2uCSsH7QOsQqqyRxSObRIGtmXB9pKbJZDCKzsw=
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.11/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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceDiskCreate,
ReadContext: resourceDiskRead,
@@ -825,5 +825,12 @@ func ResourceDisk() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageCreate,
ReadContext: resourceImageRead,
@@ -292,5 +292,12 @@ func ResourceImage() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageFromBlankComputeCreate,
ReadContext: resourceImageFromBlankComputeRead,
@@ -275,6 +275,13 @@ func ResourceImageFromBlankCompute() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageFromPlatformDiskCreate,
ReadContext: resourceImageFromPlatformDiskRead,
@@ -258,6 +258,13 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead,
@@ -128,5 +128,12 @@ func ResourceImageVirtual() *schema.Resource {
},
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,
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,
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": {
Type: schema.TypeString,
Computed: true,

View File

@@ -225,7 +225,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"numa_affinity": compute.NumaAffinity,
"numa_node_id": compute.NumaNodeId,
"os_version": compute.OSVersion,
// "pinned": compute.Pinned,
"pinned": compute.PinnedToStack,
"preferred_cpu": compute.PreferredCPU,
"qemu_guest": flattenQemuQuest(compute.QemuQuest),
"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{} {
res := make([]map[string]interface{}, 0, len(disksList))
if len(disksBlocks) == 0 {
return res
}
sort.Slice(disksList, func(i, j int) bool {
return disksList[i].ID < disksList[j].ID
})
@@ -304,9 +300,19 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
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{}{
"devicename": disk.DeviceName,
"disk_name": disk.Name,
"disk_id": disk.ID,
"disk_type": disk.Type,
@@ -318,9 +324,16 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"desc": disk.Description,
"image_id": disk.ImageID,
"size": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo,
"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)
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 {
return err
}
// d.Set("pinned", computeRec.Pinned)
d.Set("pinned", computeRec.PinnedToStack)
d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
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("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("enabled", false)
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("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
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{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
@@ -565,7 +593,10 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber,
"created_time": disk.CreatedTime,
"created_by": disk.CreatedBy,
"deleted_time": disk.DeletedTime,
"deleted_by": disk.DeletedBy,
"devicename": disk.DeviceName,
"description": disk.Description,
"destruction_time": disk.DestructionTime,
"disk_path": disk.DiskPath,
@@ -601,6 +632,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"tech_status": disk.TechStatus,
"type": disk.Type,
"to_clean": disk.ToClean,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
}
@@ -726,6 +758,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("os_version", computeRec.OSVersion)
}

View File

@@ -384,6 +384,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 enabled, ok := d.GetOk("enabled"); ok {
@@ -944,41 +950,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.
var isStopRequired bool
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) {
@@ -1153,6 +1124,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0)
changeStoragePolicyDisks := make([]interface{}, 0)
iotuneUpdatedDisks := make([]interface{}, 0)
oldDisks, newDisks := d.GetChange("disks")
oldConv := oldDisks.([]interface{})
@@ -1193,6 +1165,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if isChangeStoragePolicy(oldConv, el) {
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
}
if isChangeIOTuneDisk(oldConv, el) {
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
}
}
if len(deletedDisks) > 0 {
@@ -1245,10 +1220,33 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["image_id"].(int) != 0 {
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 {
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 +1300,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") {
@@ -1810,7 +1861,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}
}
} else {
req := compute.StopRequest{
ComputeID: computeRec.ID,
@@ -1821,6 +1871,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
// between Compute resource and Compute data source schemas
@@ -1874,6 +1952,40 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
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 {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
@@ -1900,32 +2012,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
c := m.(*controller.ControllerCfg)
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{
ComputeID: computeId,
Permanently: d.Get("permanently").(bool),
@@ -1994,6 +2080,81 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Optional: true,
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": {
Type: schema.TypeInt,
Computed: true,
@@ -2022,6 +2183,30 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
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
}
@@ -2154,6 +2339,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Computed: true,
},
"chipset": {
Type: schema.TypeString,
Optional: true,
@@ -2841,6 +3027,22 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
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
}
@@ -2867,6 +3069,10 @@ func ResourceCompute() *schema.Resource {
if diff.HasChanges("pin_to_stack") {
diff.SetNewComputed("pinned")
}
if diff.HasChanges("image_id") {
diff.SetNewComputed("boot_disk")
diff.SetNewComputed("boot_image_id")
}
return nil
},

View File

@@ -43,6 +43,7 @@ import (
"github.com/hashicorp/go-cty/cty"
log "github.com/sirupsen/logrus"
"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"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -622,3 +623,94 @@ func enabledNetwork(rawNetworkConfig cty.Value, netID uint64, netType string) bo
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,
},
},
"cpu_allocation_parameter": {
Type: schema.TypeString,
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
@@ -243,6 +235,14 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
},
},
"cpu_allocation_parameter": {
Type: schema.TypeString,
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Computed: true,
},
"uniq_pools": {
Type: schema.TypeList,
Computed: true,
@@ -250,6 +250,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
},
},
"sdn_access_group_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_ids": {
Type: schema.TypeList,
Computed: true,

View File

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

View File

@@ -170,6 +170,10 @@ func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
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("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("storage_policy_ids", acc.StoragePolicyIDs)
d.Set("uniq_pools", acc.UniqPools)
d.Set("zone_ids", flattenZones(acc.ZoneIDs))
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceDiskCreate,
ReadContext: resourceDiskRead,
@@ -438,5 +438,12 @@ func ResourceDisk() *schema.Resource {
},
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
}

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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceCDROMImageCreate,
ReadContext: resourceCDROMImageRead,
@@ -227,5 +227,12 @@ func ResourceCDROMImage() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageCreate,
ReadContext: resourceImageRead,
@@ -376,5 +376,12 @@ func ResourceImage() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageFromBlankComputeCreate,
ReadContext: resourceImageFromBlankComputeRead,
@@ -274,5 +274,12 @@ func ResourceImageFromBlankCompute() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceImageFromPlatformDiskCreate,
ReadContext: resourceImageFromPlatformDiskRead,
@@ -276,5 +276,12 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
},
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 {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceVirtualImageCreate,
ReadContext: resourceVirtualImageRead,
@@ -203,5 +203,12 @@ func ResourceVirtualImage() *schema.Resource {
},
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("clones", computeRec.Clones)
d.Set("computeci_id", computeRec.ComputeCIID)
d.Set("cpu", computeRec.CPUs)
d.Set("created_by", computeRec.CreatedBy)
d.Set("created_time", computeRec.CreatedTime)
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("interfaces", flattenInterfaces(computeRec.Interfaces))
d.Set("lock_status", computeRec.LockStatus)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("manager_id", computeRec.ManagerID)
d.Set("manager_type", computeRec.ManagerType)
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("pinned", computeRec.PinnedToStack)
d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID)
d.Set("registered", computeRec.Registered)
d.Set("res_name", computeRec.ResName)
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
d.Set("rg_name", computeRec.RGName)
d.Set("rg_id", computeRec.RGID)
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
d.Set("stack_id", computeRec.StackID)
d.Set("stack_name", computeRec.StackName)
d.Set("started", computeRec.TechStatus == "STARTED")
d.Set("stateless_sep_id", computeRec.StatelessSEPID)
d.Set("stateless_sep_type", computeRec.StatelessSEPType)
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("zone_id", computeRec.ZoneID)
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
}
@@ -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{} {
res := make([]map[string]interface{}, 0, len(disksList))
if len(disksBlocks) == 0 {
return res
}
sort.Slice(disksList, func(i, j int) bool {
return disksList[i].ID < disksList[j].ID
})
@@ -242,8 +246,25 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
continue
}
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
nodeIds := disksBlocks[indexDataDisks].(map[string]interface{})["node_ids"].(*schema.Set)
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
}
}
}
}
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{}{
"disk_name": disk.Name,
@@ -258,10 +279,17 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
"shareable": disk.Shareable,
"size_used": disk.SizeUsed,
"size_max": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo,
"storage_policy_id": disk.StoragePolicyID,
"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)
indexDataDisks++
@@ -556,6 +584,16 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
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{} {
res := make([]map[string]interface{}, 0, len(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("network_interface_naming", compFacts.NetworkInterfaceNaming)
d.Set("zone_id", compFacts.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(compFacts.LoaderMetaIso))
d.Set("os_version", compFacts.OSVersion)
//extra fields setting
bootDisk := findBootDisk(compFacts.Disks)
@@ -868,7 +907,10 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber,
"created_time": disk.CreatedTime,
"created_by": disk.CreatedBy,
"deleted_time": disk.DeletedTime,
"deleted_by": disk.DeletedBy,
"devicename": disk.DeviceName,
"desc": disk.Description,
"destruction_time": disk.DestructionTime,
"disk_path": disk.DiskPath,
@@ -907,6 +949,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus,
"type": disk.Type,
"to_clean": disk.ToClean,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
}

View File

@@ -344,26 +344,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.(*schema.Set).Len() > 0 {
lvs := libvirtSettings.(*schema.Set).List()
@@ -456,6 +436,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 {
req := compute.AffinityLabelSetRequest{
ComputeIDs: []uint64{
@@ -646,6 +656,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if err != nil {
warnings.Add(err)
}
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
warnings.Add(err)
}
}
}
@@ -950,33 +963,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
c := m.(*controller.ControllerCfg)
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{
ComputeID: computeId,
Permanently: d.Get("permanently").(bool),

View File

@@ -530,6 +530,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
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,
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": {
Type: schema.TypeString,
Computed: true,
@@ -3732,6 +3764,81 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
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": {
Type: schema.TypeInt,
Computed: true,
@@ -3760,6 +3867,30 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"create_by": {
Type: schema.TypeString,
Computed: true,
},
"create_time": {
Type: schema.TypeInt,
Computed: true,
},
"delete_by": {
Type: schema.TypeString,
Computed: true,
},
"delete_time": {
Type: schema.TypeInt,
Computed: true,
},
"update_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -4561,5 +4692,21 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
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

@@ -235,6 +235,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0)
changeStoragePolicyDisks := make([]interface{}, 0)
iotuneUpdatedDisks := make([]interface{}, 0)
presentNewDisks := make([]interface{}, 0)
presentOldDisks := make([]interface{}, 0)
@@ -283,6 +284,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if isChangeStoragePolicy(oldConv, el) {
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
}
if isChangeIOTuneDisk(oldConv, el) {
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
}
}
if len(deletedDisks) > 0 {
@@ -353,10 +357,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 {
return err
}
}
}
}
if len(resizedDisks) > 0 {
@@ -409,6 +437,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 {
newDisk := presentNewDisks[i].(map[string]interface{})
oldDisk := presentOldDisks[i].(map[string]interface{})
@@ -1618,6 +1684,13 @@ func utilityComputePinToStack(ctx context.Context, d *schema.ResourceData, m int
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")
if oldPin.(bool) && !newPin.(bool) {
req := compute.UnpinFromStackRequest{
@@ -1921,6 +1994,100 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
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,
// 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{}) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -189,6 +189,25 @@ resource "decort_kvmvm" "comp" {
#опциональный параметр
#тип - булев
#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
@@ -347,7 +366,7 @@ resource "decort_kvmvm" "comp" {
#опциональный параметр
#тип - блок
#используется при создании и обновлении
#security groups {
#security_groups {
#тип сети
#обязательный параметр
#тип - строка

View File

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

View File

@@ -198,6 +198,25 @@ resource "decort_cb_kvmvm" "comp" {
#опциональный параметр
#тип - булев
#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
@@ -361,7 +380,7 @@ resource "decort_cb_kvmvm" "comp" {
#опциональный параметр
#тип - блок
#используется при создании и обновлении
#security groups {
#security_groups {
#тип сети
#обязательный параметр
#тип - строка