Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e459fcb4c4 | |||
| 6b82f23445 | |||
|
|
754b4e1143 | ||
| 069d63a65c |
50
CHANGELOG.md
50
CHANGELOG.md
@@ -1,30 +1,38 @@
|
|||||||
## Version 4.10.2
|
## Version 4.10.6
|
||||||
|
|
||||||
### Добавлено
|
### Добавлено
|
||||||
|
|
||||||
#### storage policy
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-1090 | Отображение вычисляемых полей `sep_name` в блоке `access_seps_pools` datasource `decort_storage_policy_list` в cloudapi/stpolicy и в datasource `decort_cb_storage_policy_list` в cloudbroker/stpolicy |
|
|
||||||
|
|
||||||
### Исправлено
|
|
||||||
|
|
||||||
#### account
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-1061 | Исправлен sample resource `decort_cb_account` в cloudbroker/account |
|
|
||||||
| BATF-1061 | Вывод значения поле `storage_policy_ids` в data_sourse`decort_cb_account` в cloudbroker/account |
|
|
||||||
|
|
||||||
#### kvmvm
|
#### kvmvm
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BATF-1079 | Отображение поля `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm при импорте |
|
| BATF-1276 | Добавлено опциональное поле `create_blank` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||||
| BATF-1083 | Отображение поля `boot_disk` в resource `decort_kvmvm` в cloudapi/kvmvm при обновлении поля `image_id` |
|
| BATF-1276 | Опциональное поле `alt_boot_id` в resource `decort_kvmvm` в cloudapi/kvmvm |
|
||||||
| BATF-1088 | Исправлена логика работы поля `pin_to_stack` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
|
||||||
| BATF-1092 | Отображение вычисляемых полей `devicename`,`created_by`, `deleted_by`, `updated_time` в блоке `disks` и блока `loader_meta_iso` в resource `decort_kvmvm`, datasource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm`, datasource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
|
||||||
| BATF-1144 | Остановка виртуальной машины перед удалением в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm |
|
|
||||||
|
|
||||||
#### rg
|
### Изменено
|
||||||
|
#### kvmvm
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BATF-1062 | Отображение datasourses `decort_rg_list_deleted` в cloudapi/rg и `decort_cb_rg_list_deleted` в cloudbroker/rg |
|
| BATF-1276 | Тип поля `disk_type` с опционального на вычисляемый в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||||
|
|
||||||
|
### Исправлено
|
||||||
|
|
||||||
|
#### flipgroup
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BATF-1283 | Установка поля `desc` с платформы в ресурсе `decort_cb_flipgroup` в cloudbroker/flipgroup |
|
||||||
|
|
||||||
|
#### kvmvm
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BATF-1276 | Ошибка при старте ВМ с указанием поля `alt_boot_id` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||||
|
|
||||||
|
#### trunk
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BATF-1285 | Установка полей `account_ids`, `ovs_bridge`, `native_vlan_id`, `trunk_tags` с платформы в ресурсе `decort_cb_trunk ` в cloudbroker/trunk |
|
||||||
|
|
||||||
|
#### vfpool
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BATF-1289 | Разрешено создавать пул виртуальных функций с блоком `config` при значении поля `enable` равным `false` в resource `decort_cb_vfpool` в cloudbroker/vfpool |
|
||||||
|
| BATF-1289 | Разрешено обновлять поля `name`, `description`, `account_access` и `rg_access` без блока `config` в resource `decort_cb_vfpool` в cloudbroker/vfpool |
|
||||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
|||||||
BINARY=${NAME}
|
BINARY=${NAME}
|
||||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=4.10.2
|
VERSION=4.10.6
|
||||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||||
|
|
||||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ description: |-
|
|||||||
- `chipset` (String) Type of the emulated system.
|
- `chipset` (String) Type of the emulated system.
|
||||||
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
||||||
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
|
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
|
||||||
|
- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.
|
||||||
- `custom_fields` (String)
|
- `custom_fields` (String)
|
||||||
- `description` (String) Optional text description of this compute instance.
|
- `description` (String) Optional text description of this compute instance.
|
||||||
- `detach_disks` (Boolean)
|
- `detach_disks` (Boolean)
|
||||||
@@ -188,8 +189,8 @@ Required:
|
|||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
- `desc` (String) Optional description
|
- `desc` (String) Optional description
|
||||||
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
|
||||||
- `image_id` (Number) Specify image id for create disk from template
|
- `image_id` (Number) Specify image id for create disk from template
|
||||||
|
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
|
||||||
- `node_ids` (Set of Number)
|
- `node_ids` (Set of Number)
|
||||||
- `permanently` (Boolean) Disk deletion status
|
- `permanently` (Boolean) Disk deletion status
|
||||||
- `pool` (String) Pool name; by default will be chosen automatically
|
- `pool` (String) Pool name; by default will be chosen automatically
|
||||||
@@ -203,6 +204,7 @@ Read-Only:
|
|||||||
- `delete_time` (Number)
|
- `delete_time` (Number)
|
||||||
- `devicename` (String)
|
- `devicename` (String)
|
||||||
- `disk_id` (Number) Disk ID
|
- `disk_id` (Number) Disk ID
|
||||||
|
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
||||||
- `present_to` (Map of Number)
|
- `present_to` (Map of Number)
|
||||||
- `shareable` (Boolean)
|
- `shareable` (Boolean)
|
||||||
- `size_max` (Number)
|
- `size_max` (Number)
|
||||||
@@ -210,6 +212,26 @@ Read-Only:
|
|||||||
- `to_clean` (Boolean)
|
- `to_clean` (Boolean)
|
||||||
- `update_time` (Number)
|
- `update_time` (Number)
|
||||||
|
|
||||||
|
<a id="nestedblock--disks--iotune"></a>
|
||||||
|
### Nested Schema for `disks.iotune`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `read_bytes_sec` (Number)
|
||||||
|
- `read_bytes_sec_max` (Number)
|
||||||
|
- `read_iops_sec` (Number)
|
||||||
|
- `read_iops_sec_max` (Number)
|
||||||
|
- `size_iops_sec` (Number)
|
||||||
|
- `total_bytes_sec` (Number)
|
||||||
|
- `total_bytes_sec_max` (Number)
|
||||||
|
- `total_iops_sec` (Number)
|
||||||
|
- `total_iops_sec_max` (Number)
|
||||||
|
- `write_bytes_sec` (Number)
|
||||||
|
- `write_bytes_sec_max` (Number)
|
||||||
|
- `write_iops_sec` (Number)
|
||||||
|
- `write_iops_sec_max` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedblock--libvirt_settings"></a>
|
<a id="nestedblock--libvirt_settings"></a>
|
||||||
### Nested Schema for `libvirt_settings`
|
### Nested Schema for `libvirt_settings`
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ description: |-
|
|||||||
|
|
||||||
- `affinity_label` (String) Set affinity label for compute
|
- `affinity_label` (String) Set affinity label for compute
|
||||||
- `affinity_rules` (Block List) (see [below for nested schema](#nestedblock--affinity_rules))
|
- `affinity_rules` (Block List) (see [below for nested schema](#nestedblock--affinity_rules))
|
||||||
|
- `alt_boot_id` (Number) ID of CD-ROM live image to boot
|
||||||
- `anti_affinity_rules` (Block List) (see [below for nested schema](#nestedblock--anti_affinity_rules))
|
- `anti_affinity_rules` (Block List) (see [below for nested schema](#nestedblock--anti_affinity_rules))
|
||||||
- `auto_start_w_node` (Boolean) Flag for start compute after node exits from MAINTENANCE state
|
- `auto_start_w_node` (Boolean) Flag for start compute after node exits from MAINTENANCE state
|
||||||
- `boot_disk_size` (Number) This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.
|
- `boot_disk_size` (Number) This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.
|
||||||
@@ -35,6 +36,7 @@ description: |-
|
|||||||
- `chipset` (String) Type of the emulated system.
|
- `chipset` (String) Type of the emulated system.
|
||||||
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
- `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.
|
||||||
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
|
- `cpu_pin` (Boolean) Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.
|
||||||
|
- `create_blank` (Boolean) If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.
|
||||||
- `custom_fields` (String)
|
- `custom_fields` (String)
|
||||||
- `description` (String) Optional text description of this compute instance.
|
- `description` (String) Optional text description of this compute instance.
|
||||||
- `detach_disks` (Boolean)
|
- `detach_disks` (Boolean)
|
||||||
@@ -182,8 +184,8 @@ Required:
|
|||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
- `desc` (String) Optional description
|
- `desc` (String) Optional description
|
||||||
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
|
||||||
- `image_id` (Number) Specify image id for create disk from template
|
- `image_id` (Number) Specify image id for create disk from template
|
||||||
|
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
|
||||||
- `permanently` (Boolean) Disk deletion status
|
- `permanently` (Boolean) Disk deletion status
|
||||||
- `pool` (String) Pool name; by default will be chosen automatically
|
- `pool` (String) Pool name; by default will be chosen automatically
|
||||||
- `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk
|
- `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk
|
||||||
@@ -196,6 +198,7 @@ Read-Only:
|
|||||||
- `deleted_time` (Number)
|
- `deleted_time` (Number)
|
||||||
- `devicename` (String)
|
- `devicename` (String)
|
||||||
- `disk_id` (Number) Disk ID
|
- `disk_id` (Number) Disk ID
|
||||||
|
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
||||||
- `present_to` (Map of Number)
|
- `present_to` (Map of Number)
|
||||||
- `shareable` (Boolean)
|
- `shareable` (Boolean)
|
||||||
- `size_max` (Number)
|
- `size_max` (Number)
|
||||||
@@ -203,6 +206,26 @@ Read-Only:
|
|||||||
- `to_clean` (Boolean)
|
- `to_clean` (Boolean)
|
||||||
- `updated_time` (Number)
|
- `updated_time` (Number)
|
||||||
|
|
||||||
|
<a id="nestedblock--disks--iotune"></a>
|
||||||
|
### Nested Schema for `disks.iotune`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `read_bytes_sec` (Number)
|
||||||
|
- `read_bytes_sec_max` (Number)
|
||||||
|
- `read_iops_sec` (Number)
|
||||||
|
- `read_iops_sec_max` (Number)
|
||||||
|
- `size_iops_sec` (Number)
|
||||||
|
- `total_bytes_sec` (Number)
|
||||||
|
- `total_bytes_sec_max` (Number)
|
||||||
|
- `total_iops_sec` (Number)
|
||||||
|
- `total_iops_sec_max` (Number)
|
||||||
|
- `write_bytes_sec` (Number)
|
||||||
|
- `write_bytes_sec_max` (Number)
|
||||||
|
- `write_iops_sec` (Number)
|
||||||
|
- `write_iops_sec_max` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedblock--network"></a>
|
<a id="nestedblock--network"></a>
|
||||||
### Nested Schema for `network`
|
### Nested Schema for `network`
|
||||||
@@ -311,6 +334,7 @@ Read-Only:
|
|||||||
- `disk_name` (String)
|
- `disk_name` (String)
|
||||||
- `disk_type` (String)
|
- `disk_type` (String)
|
||||||
- `image_id` (Number)
|
- `image_id` (Number)
|
||||||
|
- `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--boot_disk--iotune))
|
||||||
- `permanently` (Boolean)
|
- `permanently` (Boolean)
|
||||||
- `pool` (String)
|
- `pool` (String)
|
||||||
- `present_to` (Map of Number)
|
- `present_to` (Map of Number)
|
||||||
@@ -323,6 +347,26 @@ Read-Only:
|
|||||||
- `to_clean` (Boolean)
|
- `to_clean` (Boolean)
|
||||||
- `updated_time` (Number)
|
- `updated_time` (Number)
|
||||||
|
|
||||||
|
<a id="nestedobjatt--boot_disk--iotune"></a>
|
||||||
|
### Nested Schema for `boot_disk.iotune`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `read_bytes_sec` (Number)
|
||||||
|
- `read_bytes_sec_max` (Number)
|
||||||
|
- `read_iops_sec` (Number)
|
||||||
|
- `read_iops_sec_max` (Number)
|
||||||
|
- `size_iops_sec` (Number)
|
||||||
|
- `total_bytes_sec` (Number)
|
||||||
|
- `total_bytes_sec_max` (Number)
|
||||||
|
- `total_iops_sec` (Number)
|
||||||
|
- `total_iops_sec_max` (Number)
|
||||||
|
- `write_bytes_sec` (Number)
|
||||||
|
- `write_bytes_sec_max` (Number)
|
||||||
|
- `write_iops_sec` (Number)
|
||||||
|
- `write_iops_sec_max` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedatt--interfaces"></a>
|
<a id="nestedatt--interfaces"></a>
|
||||||
### Nested Schema for `interfaces`
|
### Nested Schema for `interfaces`
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -9,7 +9,7 @@ require (
|
|||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
golang.org/x/net v0.44.0
|
golang.org/x/net v0.44.0
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -318,5 +318,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 h1:7RLk2Vjl6evKo4dLxlxiQCrRJSSlUwLztO3ZE/uBt+8=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12 h1:dkLPikeIh9un93zDB2FMtF5E0hJnp8kEKBrC9YbSki8=
|
||||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM=
|
repository.basistech.ru/BASIS/decort-golang-sdk v1.12.12/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM=
|
||||||
|
|||||||
421
internal/service/cloudapi/disks/old_schemas.go
Normal file
421
internal/service/cloudapi/disks/old_schemas.go
Normal 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)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -805,7 +805,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
|
|
||||||
func ResourceDisk() *schema.Resource {
|
func ResourceDisk() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceDiskCreate,
|
CreateContext: resourceDiskCreate,
|
||||||
ReadContext: resourceDiskRead,
|
ReadContext: resourceDiskRead,
|
||||||
@@ -825,5 +825,12 @@ func ResourceDisk() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceDiskSchemaMake(),
|
Schema: resourceDiskSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceDiskV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourceDiskUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
internal/service/cloudapi/disks/state_upgraders.go
Normal file
14
internal/service/cloudapi/disks/state_upgraders.go
Normal 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
|
||||||
|
}
|
||||||
782
internal/service/cloudapi/image/old_schemas.go
Normal file
782
internal/service/cloudapi/image/old_schemas.go
Normal 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())}
|
||||||
|
}
|
||||||
@@ -272,7 +272,7 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
|
|
||||||
func ResourceImage() *schema.Resource {
|
func ResourceImage() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageCreate,
|
CreateContext: resourceImageCreate,
|
||||||
ReadContext: resourceImageRead,
|
ReadContext: resourceImageRead,
|
||||||
@@ -292,5 +292,12 @@ func ResourceImage() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
|
Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageSchemaV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentToUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
func ResourceImageFromBlankCompute() *schema.Resource {
|
func ResourceImageFromBlankCompute() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageFromBlankComputeCreate,
|
CreateContext: resourceImageFromBlankComputeCreate,
|
||||||
ReadContext: resourceImageFromBlankComputeRead,
|
ReadContext: resourceImageFromBlankComputeRead,
|
||||||
@@ -275,6 +275,13 @@ func ResourceImageFromBlankCompute() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageFromBlankComputeSchemaMake(),
|
Schema: resourceImageFromBlankComputeSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageFromBlankComputeSchemaV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentToUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
func ResourceImageFromPlatformDisk() *schema.Resource {
|
func ResourceImageFromPlatformDisk() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageFromPlatformDiskCreate,
|
CreateContext: resourceImageFromPlatformDiskCreate,
|
||||||
ReadContext: resourceImageFromPlatformDiskRead,
|
ReadContext: resourceImageFromPlatformDiskRead,
|
||||||
@@ -258,6 +258,13 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageFromPlatformDiskSchemaMake(),
|
Schema: resourceImageFromPlatformDiskSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageFromBlankDiskSchemaV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentToUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m int
|
|||||||
|
|
||||||
func ResourceImageVirtual() *schema.Resource {
|
func ResourceImageVirtual() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageVirtualCreate,
|
CreateContext: resourceImageVirtualCreate,
|
||||||
ReadContext: resourceImageRead,
|
ReadContext: resourceImageRead,
|
||||||
@@ -128,5 +128,12 @@ func ResourceImageVirtual() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
|
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentToUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
internal/service/cloudapi/image/state_upgraders.go
Normal file
14
internal/service/cloudapi/image/state_upgraders.go
Normal 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
|
||||||
|
}
|
||||||
@@ -333,6 +333,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
|||||||
"deleted_time": disk.DeletedTime,
|
"deleted_time": disk.DeletedTime,
|
||||||
"updated_time": disk.UpdatedTime,
|
"updated_time": disk.UpdatedTime,
|
||||||
"permanently": pernamentlyValue,
|
"permanently": pernamentlyValue,
|
||||||
|
"iotune": flattenIotune(disk.IOTune),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
indexDataDisks++
|
indexDataDisks++
|
||||||
@@ -496,6 +497,10 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
|||||||
|
|
||||||
d.Set("os_version", computeRec.OSVersion)
|
d.Set("os_version", computeRec.OSVersion)
|
||||||
|
|
||||||
|
d.Set("cpu_pin", computeRec.CPUPin)
|
||||||
|
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||||
|
d.Set("hp_backed", computeRec.HPBacked)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.Get("create_blank").(bool) {
|
||||||
hasImage, err := existImageId(ctx, d, m)
|
hasImage, err := existImageId(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -79,6 +80,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if !hasImage {
|
if !hasImage {
|
||||||
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
|
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||||
createReqX86.ZoneID = uint64(zoneID.(int))
|
createReqX86.ZoneID = uint64(zoneID.(int))
|
||||||
@@ -288,7 +290,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||||
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
var apiResp uint64
|
||||||
|
if d.Get("create_blank").(bool) {
|
||||||
|
log.Debugf("resourceComputeCreate: using createBlank endpoint")
|
||||||
|
createBlankReq := kvmx86.CreateBlankRequest{
|
||||||
|
RGID: createReqX86.RGID,
|
||||||
|
Name: createReqX86.Name,
|
||||||
|
CPU: createReqX86.CPU,
|
||||||
|
RAM: createReqX86.RAM,
|
||||||
|
StoragePolicyID: createReqX86.StoragePolicyID,
|
||||||
|
WithoutBootDisk: createReqX86.WithoutBootDisk,
|
||||||
|
BootDisk: createReqX86.BootDisk,
|
||||||
|
SEPID: createReqX86.SepID,
|
||||||
|
Pool: createReqX86.Pool,
|
||||||
|
DataDisks: createReqX86.DataDisks,
|
||||||
|
Interfaces: createReqX86.Interfaces,
|
||||||
|
Description: createReqX86.Description,
|
||||||
|
Chipset: createReqX86.Chipset,
|
||||||
|
PreferredCPU: createReqX86.PreferredCPU,
|
||||||
|
ZoneID: createReqX86.ZoneID,
|
||||||
|
OSVersion: createReqX86.OSVersion,
|
||||||
|
}
|
||||||
|
apiResp, err = c.CloudAPI().KVMX86().CreateBlank(ctx, createBlankReq)
|
||||||
|
} else {
|
||||||
|
apiResp, err = c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -384,6 +410,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := d.GetOk("disks"); ok {
|
||||||
|
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !cleanup {
|
if !cleanup {
|
||||||
|
|
||||||
if enabled, ok := d.GetOk("enabled"); ok {
|
if enabled, ok := d.GetOk("enabled"); ok {
|
||||||
@@ -446,6 +478,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if start, ok := d.GetOk("started"); ok {
|
if start, ok := d.GetOk("started"); ok {
|
||||||
if start.(bool) {
|
if start.(bool) {
|
||||||
req := compute.StartRequest{ComputeID: computeId}
|
req := compute.StartRequest{ComputeID: computeId}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
@@ -757,6 +792,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int))
|
return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.Get("create_blank").(bool) {
|
||||||
hasImage, err := existImageId(ctx, d, m)
|
hasImage, err := existImageId(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -765,6 +801,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if !hasImage {
|
if !hasImage {
|
||||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
|
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if d.HasChange("zone_id") {
|
if d.HasChange("zone_id") {
|
||||||
if err := utilityComputeUpdateZoneID(ctx, d, m); err != nil {
|
if err := utilityComputeUpdateZoneID(ctx, d, m); err != nil {
|
||||||
@@ -851,6 +888,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if start, ok := d.GetOk("started"); ok {
|
if start, ok := d.GetOk("started"); ok {
|
||||||
if start.(bool) {
|
if start.(bool) {
|
||||||
req := compute.StartRequest{ComputeID: computeRec.ID}
|
req := compute.StartRequest{ComputeID: computeRec.ID}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -1093,7 +1133,11 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
// If used to be STARTED, we need to start it after update
|
// If used to be STARTED, we need to start it after update
|
||||||
if isStopRequired {
|
if isStopRequired {
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
|
req := compute.StartRequest{ComputeID: computeRec.ID}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
|
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1118,6 +1162,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
resizedDisks := make([]interface{}, 0)
|
resizedDisks := make([]interface{}, 0)
|
||||||
renamedDisks := make([]interface{}, 0)
|
renamedDisks := make([]interface{}, 0)
|
||||||
changeStoragePolicyDisks := make([]interface{}, 0)
|
changeStoragePolicyDisks := make([]interface{}, 0)
|
||||||
|
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||||
|
|
||||||
oldDisks, newDisks := d.GetChange("disks")
|
oldDisks, newDisks := d.GetChange("disks")
|
||||||
oldConv := oldDisks.([]interface{})
|
oldConv := oldDisks.([]interface{})
|
||||||
@@ -1158,6 +1203,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if isChangeStoragePolicy(oldConv, el) {
|
if isChangeStoragePolicy(oldConv, el) {
|
||||||
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
|
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
|
||||||
}
|
}
|
||||||
|
if isChangeIOTuneDisk(oldConv, el) {
|
||||||
|
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deletedDisks) > 0 {
|
if len(deletedDisks) > 0 {
|
||||||
@@ -1198,9 +1246,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if diskConv["sep_id"].(int) != 0 {
|
if diskConv["sep_id"].(int) != 0 {
|
||||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
req.SepID = uint64(diskConv["sep_id"].(int))
|
||||||
}
|
}
|
||||||
if diskConv["disk_type"].(string) != "" {
|
|
||||||
req.DiskType = diskConv["disk_type"].(string)
|
|
||||||
}
|
|
||||||
if diskConv["pool"].(string) != "" {
|
if diskConv["pool"].(string) != "" {
|
||||||
req.Pool = diskConv["pool"].(string)
|
req.Pool = diskConv["pool"].(string)
|
||||||
}
|
}
|
||||||
@@ -1210,10 +1255,33 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if diskConv["image_id"].(int) != 0 {
|
if diskConv["image_id"].(int) != 0 {
|
||||||
req.ImageID = uint64(diskConv["image_id"].(int))
|
req.ImageID = uint64(diskConv["image_id"].(int))
|
||||||
}
|
}
|
||||||
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
diskID, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
limitReq := disks.LimitIORequest{
|
||||||
|
DiskID: diskID,
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,6 +1335,59 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(iotuneUpdatedDisks) > 0 {
|
||||||
|
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
allDisks := computeRec.Disks
|
||||||
|
bootDisk := findBootDisk(allDisks)
|
||||||
|
diskIDs := getComputeDiskIDs(d, allDisks)
|
||||||
|
for i, disk := range iotuneUpdatedDisks {
|
||||||
|
diskConv := disk.(map[string]interface{})
|
||||||
|
if diskConv["disk_type"].(string) == "B" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if bootDisk != nil && diskConv["disk_id"].(int) == int(bootDisk.ID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var diskID uint64
|
||||||
|
if id := diskConv["disk_id"].(int); id != 0 {
|
||||||
|
diskID = uint64(id)
|
||||||
|
} else if i < len(diskIDs) {
|
||||||
|
diskID = diskIDs[i]
|
||||||
|
}
|
||||||
|
if diskID == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneRaw, ok := diskConv["iotune"].([]interface{})
|
||||||
|
if !ok || len(iotuneRaw) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
limitReq := disks.LimitIORequest{
|
||||||
|
DiskID: diskID,
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("affinity_label") {
|
if d.HasChange("affinity_label") {
|
||||||
@@ -1770,6 +1891,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
req := compute.StartRequest{
|
req := compute.StartRequest{
|
||||||
ComputeID: computeRec.ID,
|
ComputeID: computeRec.ID,
|
||||||
}
|
}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
if !isStopRequired {
|
if !isStopRequired {
|
||||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -1866,6 +1990,40 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isChangeIOTuneDisk(els []interface{}, el interface{}) bool {
|
||||||
|
for _, elOld := range els {
|
||||||
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
elConv := el.(map[string]interface{})
|
||||||
|
if elOldConv["disk_id"].(int) != elConv["disk_id"].(int) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
oldIOTune := elOldConv["iotune"].([]interface{})
|
||||||
|
newIOTune := elConv["iotune"].([]interface{})
|
||||||
|
if len(oldIOTune) == 0 && len(newIOTune) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(oldIOTune) == 0 || len(newIOTune) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
oldMap := oldIOTune[0].(map[string]interface{})
|
||||||
|
newMap := newIOTune[0].(map[string]interface{})
|
||||||
|
return oldMap["read_bytes_sec"].(int) != newMap["read_bytes_sec"].(int) ||
|
||||||
|
oldMap["read_bytes_sec_max"].(int) != newMap["read_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["read_iops_sec"].(int) != newMap["read_iops_sec"].(int) ||
|
||||||
|
oldMap["read_iops_sec_max"].(int) != newMap["read_iops_sec_max"].(int) ||
|
||||||
|
oldMap["size_iops_sec"].(int) != newMap["size_iops_sec"].(int) ||
|
||||||
|
oldMap["total_bytes_sec"].(int) != newMap["total_bytes_sec"].(int) ||
|
||||||
|
oldMap["total_bytes_sec_max"].(int) != newMap["total_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["total_iops_sec"].(int) != newMap["total_iops_sec"].(int) ||
|
||||||
|
oldMap["total_iops_sec_max"].(int) != newMap["total_iops_sec_max"].(int) ||
|
||||||
|
oldMap["write_bytes_sec"].(int) != newMap["write_bytes_sec"].(int) ||
|
||||||
|
oldMap["write_bytes_sec_max"].(int) != newMap["write_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["write_iops_sec"].(int) != newMap["write_iops_sec"].(int) ||
|
||||||
|
oldMap["write_iops_sec_max"].(int) != newMap["write_iops_sec_max"].(int)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func isContainsAR(els []interface{}, el interface{}) bool {
|
func isContainsAR(els []interface{}, el interface{}) bool {
|
||||||
for _, elOld := range els {
|
for _, elOld := range els {
|
||||||
elOldConv := elOld.(map[string]interface{})
|
elOldConv := elOld.(map[string]interface{})
|
||||||
@@ -1933,8 +2091,6 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
"disk_type": {
|
"disk_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Optional: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
|
||||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||||
},
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
@@ -1960,6 +2116,81 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Disk deletion status",
|
Description: "Disk deletion status",
|
||||||
},
|
},
|
||||||
|
"iotune": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
MaxItems: 1,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"read_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -2158,6 +2389,12 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
|
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
|
||||||
},
|
},
|
||||||
|
"create_blank": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
|
||||||
|
},
|
||||||
"boot_disk_size": {
|
"boot_disk_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -2412,6 +2649,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "Flag for resize compute",
|
Description: "Flag for resize compute",
|
||||||
},
|
},
|
||||||
|
"alt_boot_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "ID of CD-ROM live image to boot",
|
||||||
|
},
|
||||||
"started": {
|
"started": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import (
|
|||||||
"github.com/hashicorp/go-cty/cty"
|
"github.com/hashicorp/go-cty/cty"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
@@ -292,7 +293,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
|
|
||||||
if needStart {
|
if needStart {
|
||||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
|
var altBootID uint64
|
||||||
|
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
altBootID = uint64(altBootIDRaw)
|
||||||
|
} else {
|
||||||
|
altBootID = 0
|
||||||
|
}
|
||||||
|
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
|
||||||
apiErrCount += numErr
|
apiErrCount += numErr
|
||||||
lastSavedError = err
|
lastSavedError = err
|
||||||
}
|
}
|
||||||
@@ -455,10 +462,14 @@ func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
|
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
startReq := compute.StartRequest{ComputeID: computeID}
|
startReq := compute.StartRequest{ComputeID: computeID}
|
||||||
|
|
||||||
|
if altBootID > 0 {
|
||||||
|
startReq.AltBootID = altBootID
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
|
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
|
||||||
_, err := c.CloudAPI().Compute().Start(ctx, startReq)
|
_, err := c.CloudAPI().Compute().Start(ctx, startReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -622,3 +633,94 @@ func enabledNetwork(rawNetworkConfig cty.Value, netID uint64, netType string) bo
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getComputeDiskIDs(d *schema.ResourceData, disksList compute.ListComputeDisks) []uint64 {
|
||||||
|
diskList := d.Get("disks").([]interface{})
|
||||||
|
ids := make([]uint64, 0, len(diskList))
|
||||||
|
for _, item := range diskList {
|
||||||
|
diskConv := item.(map[string]interface{})
|
||||||
|
diskName := diskConv["disk_name"].(string)
|
||||||
|
for _, disk := range disksList {
|
||||||
|
if disk.Name == diskName {
|
||||||
|
ids = append(ids, disk.ID)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
|
diskList, ok := d.GetOk("disks")
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
disksSlice := diskList.([]interface{})
|
||||||
|
|
||||||
|
hasIotune := false
|
||||||
|
for _, item := range disksSlice {
|
||||||
|
diskConv := item.(map[string]interface{})
|
||||||
|
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
|
||||||
|
hasIotune = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasIotune {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allDisks := computeRec.Disks
|
||||||
|
bootDisk := findBootDisk(allDisks)
|
||||||
|
diskIDs := getComputeDiskIDs(d, allDisks)
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
for i, item := range disksSlice {
|
||||||
|
diskConv := item.(map[string]interface{})
|
||||||
|
if diskConv["disk_type"].(string) == "B" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if bootDisk != nil && diskConv["disk_id"].(int) == int(bootDisk.ID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneRaw, ok := diskConv["iotune"].([]interface{})
|
||||||
|
if !ok || len(iotuneRaw) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var diskID uint64
|
||||||
|
if id := diskConv["disk_id"].(int); id != 0 {
|
||||||
|
diskID = uint64(id)
|
||||||
|
} else if i < len(diskIDs) {
|
||||||
|
diskID = diskIDs[i]
|
||||||
|
}
|
||||||
|
if diskID == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
limitReq := disks.LimitIORequest{
|
||||||
|
DiskID: diskID,
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
391
internal/service/cloudbroker/disks/old_schemas.go
Normal file
391
internal/service/cloudbroker/disks/old_schemas.go
Normal 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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -418,7 +418,7 @@ func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
|
|
||||||
func ResourceDisk() *schema.Resource {
|
func ResourceDisk() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceDiskCreate,
|
CreateContext: resourceDiskCreate,
|
||||||
ReadContext: resourceDiskRead,
|
ReadContext: resourceDiskRead,
|
||||||
@@ -438,5 +438,12 @@ func ResourceDisk() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceDiskSchemaMake(),
|
Schema: resourceDiskSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceDiskV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourceDiskUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
internal/service/cloudbroker/disks/state_upgrader.go
Normal file
14
internal/service/cloudbroker/disks/state_upgrader.go
Normal 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
|
||||||
|
}
|
||||||
@@ -70,6 +70,36 @@ func flattenFlipgroup(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
|
|||||||
d.Set("updated_time", flip.UpdatedTime)
|
d.Set("updated_time", flip.UpdatedTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenFlipgroupResource(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
|
||||||
|
d.Set("flipgroup_id", flip.ID)
|
||||||
|
d.Set("account_id", flip.AccountID)
|
||||||
|
d.Set("account_name", flip.AccountName)
|
||||||
|
d.Set("client_ids", flip.ClientIDs)
|
||||||
|
d.Set("client_names", flip.ClientNames)
|
||||||
|
d.Set("client_type", flip.ClientType)
|
||||||
|
d.Set("conn_id", flip.ConnID)
|
||||||
|
d.Set("conn_type", flip.ConnType)
|
||||||
|
d.Set("created_by", flip.CreatedBy)
|
||||||
|
d.Set("created_time", flip.CreatedTime)
|
||||||
|
d.Set("default_gw", flip.DefaultGW)
|
||||||
|
d.Set("deleted_by", flip.DeletedBy)
|
||||||
|
d.Set("deleted_time", flip.DeletedTime)
|
||||||
|
d.Set("desc", flip.Description)
|
||||||
|
d.Set("gid", flip.GID)
|
||||||
|
d.Set("guid", flip.GUID)
|
||||||
|
d.Set("ip", flip.IP)
|
||||||
|
d.Set("milestones", flip.Milestones)
|
||||||
|
d.Set("name", flip.Name)
|
||||||
|
d.Set("net_id", flip.NetID)
|
||||||
|
d.Set("net_type", flip.NetType)
|
||||||
|
d.Set("network", flip.Network)
|
||||||
|
d.Set("rg_id", flip.RGID)
|
||||||
|
d.Set("rg_name", flip.RGName)
|
||||||
|
d.Set("status", flip.Status)
|
||||||
|
d.Set("updated_by", flip.UpdatedBy)
|
||||||
|
d.Set("updated_time", flip.UpdatedTime)
|
||||||
|
}
|
||||||
|
|
||||||
func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(fg.Data))
|
res := make([]map[string]interface{}, 0, len(fg.Data))
|
||||||
for _, flip := range fg.Data {
|
for _, flip := range fg.Data {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.Errorf("The flipgroup status is destroyed and cannot be read.")
|
return diag.Errorf("The flipgroup status is destroyed and cannot be read.")
|
||||||
}
|
}
|
||||||
|
|
||||||
flattenFlipgroup(d, fg)
|
flattenFlipgroupResource(d, fg)
|
||||||
|
|
||||||
log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s",
|
log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s",
|
||||||
d.Id(), d.Get("name").(string))
|
d.Id(), d.Get("name").(string))
|
||||||
|
|||||||
1394
internal/service/cloudbroker/image/old_schemas.go
Normal file
1394
internal/service/cloudbroker/image/old_schemas.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -207,7 +207,7 @@ func resourceImageCDROMEdit(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
|
|
||||||
func ResourceCDROMImage() *schema.Resource {
|
func ResourceCDROMImage() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceCDROMImageCreate,
|
CreateContext: resourceCDROMImageCreate,
|
||||||
ReadContext: resourceCDROMImageRead,
|
ReadContext: resourceCDROMImageRead,
|
||||||
@@ -227,5 +227,12 @@ func ResourceCDROMImage() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceCDROMImageSchemaMake(),
|
Schema: resourceCDROMImageSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceCDROMImageV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentTOUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ func resourceImageEdit(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
|
|
||||||
func ResourceImage() *schema.Resource {
|
func ResourceImage() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageCreate,
|
CreateContext: resourceImageCreate,
|
||||||
ReadContext: resourceImageRead,
|
ReadContext: resourceImageRead,
|
||||||
@@ -376,5 +376,12 @@ func ResourceImage() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageSchemaMake(),
|
Schema: resourceImageSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentTOUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
func ResourceImageFromBlankCompute() *schema.Resource {
|
func ResourceImageFromBlankCompute() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageFromBlankComputeCreate,
|
CreateContext: resourceImageFromBlankComputeCreate,
|
||||||
ReadContext: resourceImageFromBlankComputeRead,
|
ReadContext: resourceImageFromBlankComputeRead,
|
||||||
@@ -274,5 +274,12 @@ func ResourceImageFromBlankCompute() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageFromBlankComputeSchemaMake(),
|
Schema: resourceImageFromBlankComputeSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageFromBlankComputeV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentTOUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
func ResourceImageFromPlatformDisk() *schema.Resource {
|
func ResourceImageFromPlatformDisk() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceImageFromPlatformDiskCreate,
|
CreateContext: resourceImageFromPlatformDiskCreate,
|
||||||
ReadContext: resourceImageFromPlatformDiskRead,
|
ReadContext: resourceImageFromPlatformDiskRead,
|
||||||
@@ -276,5 +276,12 @@ func ResourceImageFromPlatformDisk() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceImageFromPlatformDiskSchemaMake(),
|
Schema: resourceImageFromPlatformDiskSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceImageFromPlatformDiskV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentTOUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ func resourceImageLink(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
|
|
||||||
func ResourceVirtualImage() *schema.Resource {
|
func ResourceVirtualImage() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 2,
|
||||||
|
|
||||||
CreateContext: resourceVirtualImageCreate,
|
CreateContext: resourceVirtualImageCreate,
|
||||||
ReadContext: resourceVirtualImageRead,
|
ReadContext: resourceVirtualImageRead,
|
||||||
@@ -203,5 +203,12 @@ func ResourceVirtualImage() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceVirtualImageSchemaMake(),
|
Schema: resourceVirtualImageSchemaMake(),
|
||||||
|
StateUpgraders: []schema.StateUpgrader{
|
||||||
|
{
|
||||||
|
Type: resourceVirtualImageV1().CoreConfigSchema().ImpliedType(),
|
||||||
|
Upgrade: resourcePresentTOUpgradeV1,
|
||||||
|
Version: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
internal/service/cloudbroker/image/state_upgrader.go
Normal file
14
internal/service/cloudbroker/image/state_upgrader.go
Normal 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
|
||||||
|
}
|
||||||
@@ -112,6 +112,9 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
|||||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||||
d.Set("zone_id", computeRec.ZoneID)
|
d.Set("zone_id", computeRec.ZoneID)
|
||||||
d.Set("os_version", computeRec.OSVersion)
|
d.Set("os_version", computeRec.OSVersion)
|
||||||
|
d.Set("cpu_pin", computeRec.CPUPin)
|
||||||
|
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||||
|
d.Set("hp_backed", computeRec.HPBacked)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,6 +289,7 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
|||||||
"delete_by": disk.DeletedBy,
|
"delete_by": disk.DeletedBy,
|
||||||
"delete_time": disk.DeletedTime,
|
"delete_time": disk.DeletedTime,
|
||||||
"update_time": disk.UpdatedTime,
|
"update_time": disk.UpdatedTime,
|
||||||
|
"iotune": flattenIOTune(disk.IOTune),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
indexDataDisks++
|
indexDataDisks++
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
|
|||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.Get("create_blank").(bool) {
|
||||||
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
|
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if netErrs := existNetworks(ctx, d, c); errs != nil {
|
if netErrs := existNetworks(ctx, d, c); errs != nil {
|
||||||
errs = append(errs, netErrs...)
|
errs = append(errs, netErrs...)
|
||||||
|
|||||||
@@ -231,7 +231,32 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||||
apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
var apiResp uint64
|
||||||
|
var err error
|
||||||
|
if d.Get("create_blank").(bool) {
|
||||||
|
log.Debugf("resourceComputeCreate: using createBlank endpoint")
|
||||||
|
createBlankReq := kvmx86.CreateBlankRequest{
|
||||||
|
RGID: createReqX86.RGID,
|
||||||
|
Name: createReqX86.Name,
|
||||||
|
CPU: createReqX86.CPU,
|
||||||
|
RAM: createReqX86.RAM,
|
||||||
|
StoragePolicyID: createReqX86.StoragePolicyID,
|
||||||
|
WithoutBootDisk: createReqX86.WithoutBootDisk,
|
||||||
|
BootDisk: createReqX86.BootDisk,
|
||||||
|
SEPID: createReqX86.SEPID,
|
||||||
|
Pool: createReqX86.Pool,
|
||||||
|
DataDisks: createReqX86.DataDisks,
|
||||||
|
Interfaces: createReqX86.Interfaces,
|
||||||
|
Description: createReqX86.Description,
|
||||||
|
Chipset: createReqX86.Chipset,
|
||||||
|
PreferredCPU: createReqX86.PreferredCPU,
|
||||||
|
ZoneID: createReqX86.ZoneID,
|
||||||
|
OSVersion: createReqX86.OSVersion,
|
||||||
|
}
|
||||||
|
apiResp, err = c.CloudBroker().KVMX86().CreateBlank(ctx, createBlankReq)
|
||||||
|
} else {
|
||||||
|
apiResp, err = c.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -424,6 +449,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
if start, ok := d.GetOk("started"); ok && start.(bool) {
|
if start, ok := d.GetOk("started"); ok && start.(bool) {
|
||||||
req := compute.StartRequest{ComputeID: computeId}
|
req := compute.StartRequest{ComputeID: computeId}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
@@ -656,6 +684,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
|
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3406,6 +3406,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: false,
|
Default: false,
|
||||||
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
|
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
|
||||||
},
|
},
|
||||||
|
"create_blank": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
|
||||||
|
},
|
||||||
"boot_disk_size": {
|
"boot_disk_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -3730,8 +3736,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
"disk_type": {
|
"disk_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Optional: true,
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
|
||||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||||
},
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
@@ -3764,6 +3768,81 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Disk deletion status",
|
Description: "Disk deletion status",
|
||||||
},
|
},
|
||||||
|
"iotune": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
MaxItems: 1,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"read_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"read_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"total_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_bytes_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_bytes_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_iops_sec": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"write_iops_sec_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -184,7 +184,11 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isStopRequired {
|
if isStopRequired {
|
||||||
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
|
req := compute.StartRequest{ComputeID: computeId}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
|
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,6 +239,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
resizedDisks := make([]interface{}, 0)
|
resizedDisks := make([]interface{}, 0)
|
||||||
renamedDisks := make([]interface{}, 0)
|
renamedDisks := make([]interface{}, 0)
|
||||||
changeStoragePolicyDisks := make([]interface{}, 0)
|
changeStoragePolicyDisks := make([]interface{}, 0)
|
||||||
|
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||||
presentNewDisks := make([]interface{}, 0)
|
presentNewDisks := make([]interface{}, 0)
|
||||||
presentOldDisks := make([]interface{}, 0)
|
presentOldDisks := make([]interface{}, 0)
|
||||||
|
|
||||||
@@ -283,6 +288,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
if isChangeStoragePolicy(oldConv, el) {
|
if isChangeStoragePolicy(oldConv, el) {
|
||||||
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
|
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
|
||||||
}
|
}
|
||||||
|
if isChangeIOTuneDisk(oldConv, el) {
|
||||||
|
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deletedDisks) > 0 {
|
if len(deletedDisks) > 0 {
|
||||||
@@ -320,9 +328,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
if diskConv["sep_id"].(int) != 0 {
|
if diskConv["sep_id"].(int) != 0 {
|
||||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
req.SepID = uint64(diskConv["sep_id"].(int))
|
||||||
}
|
}
|
||||||
if diskConv["disk_type"].(string) != "" {
|
|
||||||
req.DiskType = diskConv["disk_type"].(string)
|
|
||||||
}
|
|
||||||
if diskConv["pool"].(string) != "" {
|
if diskConv["pool"].(string) != "" {
|
||||||
req.Pool = diskConv["pool"].(string)
|
req.Pool = diskConv["pool"].(string)
|
||||||
}
|
}
|
||||||
@@ -353,10 +358,34 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
|
||||||
|
if diskConv["disk_type"].(string) == "B" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
limitReq := disks.LimitIORequest{
|
||||||
|
DiskID: diskID,
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudBroker().Disks().LimitIO(ctx, limitReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resizedDisks) > 0 {
|
if len(resizedDisks) > 0 {
|
||||||
@@ -409,6 +438,44 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(iotuneUpdatedDisks) > 0 {
|
||||||
|
for _, disk := range iotuneUpdatedDisks {
|
||||||
|
diskConv := disk.(map[string]interface{})
|
||||||
|
if diskConv["disk_type"].(string) == "B" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
diskID := uint64(diskConv["disk_id"].(int))
|
||||||
|
if diskID == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneRaw, ok := diskConv["iotune"].([]interface{})
|
||||||
|
if !ok || len(iotuneRaw) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
req := disks.LimitIORequest{
|
||||||
|
DiskID: diskID,
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i := range presentNewDisks {
|
for i := range presentNewDisks {
|
||||||
newDisk := presentNewDisks[i].(map[string]interface{})
|
newDisk := presentNewDisks[i].(map[string]interface{})
|
||||||
oldDisk := presentOldDisks[i].(map[string]interface{})
|
oldDisk := presentOldDisks[i].(map[string]interface{})
|
||||||
@@ -769,7 +836,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|||||||
|
|
||||||
if needStart {
|
if needStart {
|
||||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
|
var altBootID uint64
|
||||||
|
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
altBootID = uint64(altBootIDRaw)
|
||||||
|
} else {
|
||||||
|
altBootID = 0
|
||||||
|
}
|
||||||
|
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
|
||||||
apiErrCount += numErr
|
apiErrCount += numErr
|
||||||
lastSavedError = err
|
lastSavedError = err
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1169,11 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
|
|
||||||
// If used to be STARTED, we need to start it after update
|
// If used to be STARTED, we need to start it after update
|
||||||
if isStopRequired {
|
if isStopRequired {
|
||||||
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
|
req := compute.StartRequest{ComputeID: computeId}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
req.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
|
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1567,6 +1644,9 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
startReq := compute.StartRequest{ComputeID: computeId}
|
startReq := compute.StartRequest{ComputeID: computeId}
|
||||||
|
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||||
|
startReq.AltBootID = uint64(altBootID)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityComputeRollback: starting compute %d", computeId)
|
log.Debugf("utilityComputeRollback: starting compute %d", computeId)
|
||||||
|
|
||||||
@@ -1824,10 +1904,14 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
|
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
startReq := compute.StartRequest{ComputeID: computeID}
|
startReq := compute.StartRequest{ComputeID: computeID}
|
||||||
|
|
||||||
|
if altBootID > 0 {
|
||||||
|
startReq.AltBootID = altBootID
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("utilityComputeStart: starting compute %d", computeID)
|
log.Debugf("utilityComputeStart: starting compute %d", computeID)
|
||||||
_, err := c.CloudBroker().Compute().Start(ctx, startReq)
|
_, err := c.CloudBroker().Compute().Start(ctx, startReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1928,6 +2012,100 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isChangeIOTuneDisk(els []interface{}, el interface{}) bool {
|
||||||
|
for _, elOld := range els {
|
||||||
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
elConv := el.(map[string]interface{})
|
||||||
|
if elOldConv["disk_id"].(int) != elConv["disk_id"].(int) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
oldIOTune := elOldConv["iotune"].([]interface{})
|
||||||
|
newIOTune := elConv["iotune"].([]interface{})
|
||||||
|
if len(oldIOTune) == 0 && len(newIOTune) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(oldIOTune) == 0 || len(newIOTune) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
oldMap := oldIOTune[0].(map[string]interface{})
|
||||||
|
newMap := newIOTune[0].(map[string]interface{})
|
||||||
|
return oldMap["read_bytes_sec"].(int) != newMap["read_bytes_sec"].(int) ||
|
||||||
|
oldMap["read_bytes_sec_max"].(int) != newMap["read_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["read_iops_sec"].(int) != newMap["read_iops_sec"].(int) ||
|
||||||
|
oldMap["read_iops_sec_max"].(int) != newMap["read_iops_sec_max"].(int) ||
|
||||||
|
oldMap["size_iops_sec"].(int) != newMap["size_iops_sec"].(int) ||
|
||||||
|
oldMap["total_bytes_sec"].(int) != newMap["total_bytes_sec"].(int) ||
|
||||||
|
oldMap["total_bytes_sec_max"].(int) != newMap["total_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["total_iops_sec"].(int) != newMap["total_iops_sec"].(int) ||
|
||||||
|
oldMap["total_iops_sec_max"].(int) != newMap["total_iops_sec_max"].(int) ||
|
||||||
|
oldMap["write_bytes_sec"].(int) != newMap["write_bytes_sec"].(int) ||
|
||||||
|
oldMap["write_bytes_sec_max"].(int) != newMap["write_bytes_sec_max"].(int) ||
|
||||||
|
oldMap["write_iops_sec"].(int) != newMap["write_iops_sec"].(int) ||
|
||||||
|
oldMap["write_iops_sec_max"].(int) != newMap["write_iops_sec_max"].(int)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
diskList := d.Get("disks").([]interface{})
|
||||||
|
|
||||||
|
iotuneArr := make([]interface{}, 0, len(diskList))
|
||||||
|
hasAny := false
|
||||||
|
for _, elem := range diskList {
|
||||||
|
diskVal := elem.(map[string]interface{})
|
||||||
|
iotune := diskVal["iotune"].([]interface{})
|
||||||
|
iotuneArr = append(iotuneArr, iotune)
|
||||||
|
if len(iotune) > 0 {
|
||||||
|
hasAny = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasAny {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
bootDisk := findBootDisk(computeRec.Disks)
|
||||||
|
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
|
||||||
|
|
||||||
|
for i, diskID := range computeDisksIDs {
|
||||||
|
if i >= len(iotuneArr) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotune, ok := iotuneArr[i].([]interface{})
|
||||||
|
if !ok || len(iotune) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotune[0].(map[string]interface{})
|
||||||
|
req := disks.LimitIORequest{
|
||||||
|
DiskID: diskID.(uint64),
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// isChangeNodesDisk get slice of new disks values and current value disk,
|
// isChangeNodesDisk get slice of new disks values and current value disk,
|
||||||
// if need change nodes on disk returns true and new disk value, else return false and nil
|
// if need change nodes on disk returns true and new disk value, else return false and nil
|
||||||
func isChangeNodesDisk(els []interface{}, elOld interface{}) (bool, interface{}) {
|
func isChangeNodesDisk(els []interface{}, elOld interface{}) (bool, interface{}) {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) {
|
|||||||
d.Set("name", details.Name)
|
d.Set("name", details.Name)
|
||||||
d.Set("mac", details.MAC)
|
d.Set("mac", details.MAC)
|
||||||
d.Set("description", details.Description)
|
d.Set("description", details.Description)
|
||||||
d.Set("accountIds", details.AccountIDs)
|
d.Set("account_ids", details.AccountIDs)
|
||||||
d.Set("ovsBridge", details.OVSBridge)
|
d.Set("ovs_bridge", details.OVSBridge)
|
||||||
d.Set("nativeVlanId", details.NativeVLANID)
|
d.Set("native_vlan_id", details.NativeVLANID)
|
||||||
d.Set("status", details.Status)
|
d.Set("status", details.Status)
|
||||||
d.Set("trunkTags", details.TrunkTags)
|
d.Set("trunk_tags", details.TrunkTags)
|
||||||
d.Set("created_at", details.CreatedAt)
|
d.Set("created_at", details.CreatedAt)
|
||||||
d.Set("created_by", details.CreatedBy)
|
d.Set("created_by", details.CreatedBy)
|
||||||
d.Set("updated_at", details.UpdatedAt)
|
d.Set("updated_at", details.UpdatedAt)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ package vfpool
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
@@ -85,6 +86,12 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
config, configOk := d.GetOk("config")
|
config, configOk := d.GetOk("config")
|
||||||
|
|
||||||
|
enableVal := d.Get("enable").(bool)
|
||||||
|
if enableVal && !configOk {
|
||||||
|
return diag.FromErr(fmt.Errorf("enable requires config to be set"))
|
||||||
|
}
|
||||||
|
|
||||||
if configOk {
|
if configOk {
|
||||||
configArray := config.(*schema.Set).List()
|
configArray := config.(*schema.Set).List()
|
||||||
req.Config = make([]vfpool.Config, 0, len(configArray))
|
req.Config = make([]vfpool.Config, 0, len(configArray))
|
||||||
@@ -117,11 +124,9 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
|
|
||||||
warnings := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
if err := utilityVFPoolEnabled(ctx, m, enableVal, vfPoolID); err != nil {
|
||||||
if err := utilityVFPoolEnabled(ctx, m, enable.(bool), vfPoolID, configOk); err != nil {
|
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID)
|
log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID)
|
||||||
return append(resourceVFPoolRead(ctx, d, m), warnings.Get()...)
|
return append(resourceVFPoolRead(ctx, d, m), warnings.Get()...)
|
||||||
@@ -147,20 +152,12 @@ func resourceVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
|
|
||||||
log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID)
|
log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID)
|
||||||
|
|
||||||
_, ok := d.GetOk("config")
|
if d.HasChanges("name", "description", "account_access", "rg_access", "config", "enable") {
|
||||||
|
|
||||||
if d.HasChanges("name,", "description", "account_access", "rg_access,", "config") {
|
|
||||||
if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil {
|
if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("enable") {
|
|
||||||
if err := utilityVFPoolEnabled(ctx, m, d.Get("enable").(bool), vfPoolID, ok); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID)
|
log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID)
|
||||||
|
|
||||||
return resourceVFPoolRead(ctx, d, m)
|
return resourceVFPoolRead(ctx, d, m)
|
||||||
|
|||||||
@@ -64,37 +64,26 @@ func utilityVFpoolCheckPresence(ctx context.Context, d *schema.ResourceData, m i
|
|||||||
return vfpoolData, nil
|
return vfpoolData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64, configOk bool) error {
|
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64) error {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
if enable && configOk {
|
var err error
|
||||||
req := vfpool.EnableRequest{
|
|
||||||
VFPoolID: vfPoolID,
|
if enable {
|
||||||
}
|
_, err = c.CloudBroker().VFPool().Enable(ctx, vfpool.EnableRequest{VFPoolID: vfPoolID})
|
||||||
_, err := c.CloudBroker().VFPool().Enable(ctx, req)
|
} else {
|
||||||
if err != nil {
|
_, err = c.CloudBroker().VFPool().Disable(ctx, vfpool.DisableRequest{VFPoolID: vfPoolID})
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if enable && !configOk {
|
|
||||||
return fmt.Errorf("you must provide configuration for this resource, after enabling it")
|
|
||||||
}
|
|
||||||
if !enable {
|
|
||||||
req := vfpool.DisableRequest{
|
|
||||||
VFPoolID: vfPoolID,
|
|
||||||
}
|
|
||||||
_, err := c.CloudBroker().VFPool().Disable(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityVFPoolEnabled: enable=%v vfPool ID %d after completing its resource configuration", enable, vfPoolID)
|
return err
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error {
|
func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error {
|
||||||
|
hasConfig := len(d.Get("config").(*schema.Set).List()) > 0
|
||||||
|
if d.Get("enable").(bool) && !hasConfig {
|
||||||
|
return fmt.Errorf("enable requires config to be set")
|
||||||
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
vfPool, err := utilityVFpoolCheckPresence(ctx, d, m)
|
vfPool, err := utilityVFpoolCheckPresence(ctx, d, m)
|
||||||
@@ -190,7 +179,7 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
}
|
}
|
||||||
log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req)
|
log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req)
|
||||||
|
|
||||||
if len(d.Get("config").(*schema.Set).List()) > 0 && d.Get("enable").(bool) {
|
if hasConfig && d.Get("enable").(bool) {
|
||||||
reqEnable := vfpool.EnableRequest{
|
reqEnable := vfpool.EnableRequest{
|
||||||
VFPoolID: vfPoolID,
|
VFPoolID: vfPoolID,
|
||||||
}
|
}
|
||||||
@@ -201,8 +190,6 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID)
|
log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID)
|
||||||
} else {
|
|
||||||
return (fmt.Errorf("the vfPool is not enabled after update, you must provide configuration for this resource, after enabling it"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -112,6 +112,18 @@ resource "decort_kvmvm" "comp" {
|
|||||||
#используется при создании
|
#используется при создании
|
||||||
#without_boot_disk = true
|
#without_boot_disk = true
|
||||||
|
|
||||||
|
#создание без образа ОС
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - булев
|
||||||
|
#используется при создании
|
||||||
|
#create_blank = false
|
||||||
|
|
||||||
|
#id образа CD-ROM для загрузки
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - целое число
|
||||||
|
#используется при создании и обновлении
|
||||||
|
#alt_boot_id = 1
|
||||||
|
|
||||||
#необходимость выравнивать ВМ по NUMA
|
#необходимость выравнивать ВМ по NUMA
|
||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#возможные значения - "none, "strict", "loose"
|
#возможные значения - "none, "strict", "loose"
|
||||||
@@ -160,11 +172,6 @@ resource "decort_kvmvm" "comp" {
|
|||||||
#тип - целое число
|
#тип - целое число
|
||||||
#size = 5
|
#size = 5
|
||||||
|
|
||||||
#тип диска
|
|
||||||
#опциональный параметр
|
|
||||||
#тип - строка
|
|
||||||
#disk_type = "D"
|
|
||||||
|
|
||||||
#id сепа
|
#id сепа
|
||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - целое число
|
#тип - целое число
|
||||||
@@ -189,6 +196,25 @@ resource "decort_kvmvm" "comp" {
|
|||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - булев
|
#тип - булев
|
||||||
#permanently = false
|
#permanently = false
|
||||||
|
|
||||||
|
#ограничения ввода-вывода для диска
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - блок
|
||||||
|
#iotune {
|
||||||
|
#read_bytes_sec = 0
|
||||||
|
#read_bytes_sec_max = 0
|
||||||
|
#read_iops_sec = 0
|
||||||
|
#read_iops_sec_max = 0
|
||||||
|
#size_iops_sec = 0
|
||||||
|
#total_bytes_sec = 0
|
||||||
|
#total_bytes_sec_max = 0
|
||||||
|
#total_iops_sec = 0
|
||||||
|
#total_iops_sec_max = 0
|
||||||
|
#write_bytes_sec = 0
|
||||||
|
#write_bytes_sec_max = 0
|
||||||
|
#write_iops_sec = 0
|
||||||
|
#write_iops_sec_max = 0
|
||||||
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
#правила affinity
|
#правила affinity
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ resource "decort_cb_kvmvm" "comp" {
|
|||||||
#используется при создании
|
#используется при создании
|
||||||
#without_boot_disk = true
|
#without_boot_disk = true
|
||||||
|
|
||||||
|
#создание без образа ОС
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - булев
|
||||||
|
#используется при создании
|
||||||
|
#create_blank = false
|
||||||
|
|
||||||
#размер загрузочного диска
|
#размер загрузочного диска
|
||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - целое число
|
#тип - целое число
|
||||||
@@ -121,7 +127,7 @@ resource "decort_cb_kvmvm" "comp" {
|
|||||||
#id образа CD-ROM для загрузки
|
#id образа CD-ROM для загрузки
|
||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - целое число
|
#тип - целое число
|
||||||
#используется при обновлении, при повторном старте вм
|
#используется при создании и обновлении
|
||||||
#alt_boot_id = 1
|
#alt_boot_id = 1
|
||||||
|
|
||||||
#необходимость выравнивать ВМ по NUMA
|
#необходимость выравнивать ВМ по NUMA
|
||||||
@@ -166,11 +172,6 @@ resource "decort_cb_kvmvm" "comp" {
|
|||||||
#тип - целое число
|
#тип - целое число
|
||||||
#storage_policy_id = 1
|
#storage_policy_id = 1
|
||||||
|
|
||||||
#тип диска
|
|
||||||
#опциональный параметр
|
|
||||||
#тип - строка
|
|
||||||
#disk_type = "D"
|
|
||||||
|
|
||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - целое число
|
#тип - целое число
|
||||||
#sep_id = 1
|
#sep_id = 1
|
||||||
@@ -198,6 +199,25 @@ resource "decort_cb_kvmvm" "comp" {
|
|||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - булев
|
#тип - булев
|
||||||
#permanently = false
|
#permanently = false
|
||||||
|
|
||||||
|
#ограничения ввода-вывода для диска
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - блок
|
||||||
|
#iotune {
|
||||||
|
#read_bytes_sec = 0
|
||||||
|
#read_bytes_sec_max = 0
|
||||||
|
#read_iops_sec = 0
|
||||||
|
#read_iops_sec_max = 0
|
||||||
|
#size_iops_sec = 0
|
||||||
|
#total_bytes_sec = 0
|
||||||
|
#total_bytes_sec_max = 0
|
||||||
|
#total_iops_sec = 0
|
||||||
|
#total_iops_sec_max = 0
|
||||||
|
#write_bytes_sec = 0
|
||||||
|
#write_bytes_sec_max = 0
|
||||||
|
#write_iops_sec = 0
|
||||||
|
#write_iops_sec_max = 0
|
||||||
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
#правила affinity
|
#правила affinity
|
||||||
|
|||||||
Reference in New Issue
Block a user