Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3e5de6561 | |||
| bd95fa8b78 | |||
|
|
0720d7f6be | ||
|
|
a475cf3f75 | ||
| 476a09ed53 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,13 +1,8 @@
|
|||||||
## Version 4.9.7
|
## Version 4.9.11
|
||||||
|
|
||||||
### Исправлено
|
### Исправлено
|
||||||
|
|
||||||
#### disks
|
#### flipgroup
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BATF-1203 | Ошибка построения и применения плана при использовании состояния, созданного в предыдущих версиях провайдера в resources `decort_disk` в cloudapi/disks и в `decort_cb_disk` cloudbroker/disks |
|
| BATF-1283 | Установка поля `desc` с платформы в ресурсе `decort_cb_flipgroup` в cloudbroker/flipgroup |
|
||||||
|
|
||||||
#### image
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-1203 | Ошибка построения и применения плана при использовании состояния, созданного в предыдущих версиях провайдера в resources `decort_image_from_blank_compute`, `decort_image_from_platform_disk`, `decort_virtual_image` в cloudapi/image и в `decort_cb_cdrom_image`, `decort_cb_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_virtual_image` в cloudbroker/image |
|
|
||||||
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.9.7
|
VERSION=4.9.11
|
||||||
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\
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ description: |-
|
|||||||
### Required
|
### Required
|
||||||
|
|
||||||
- `authenticator` (String) Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.
|
- `authenticator` (String) Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.
|
||||||
- `controller_url` (String) URL of DECORT Cloud controller to use. API calls will be directed to this URL.
|
|
||||||
|
|
||||||
### Optional
|
### Optional
|
||||||
|
|
||||||
@@ -27,6 +26,7 @@ description: |-
|
|||||||
- `app_secret` (String) Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.
|
- `app_secret` (String) Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.
|
||||||
- `bvs_password` (String) User password for DECORT cloud API operations in 'bvs' authentication mode.
|
- `bvs_password` (String) User password for DECORT cloud API operations in 'bvs' authentication mode.
|
||||||
- `bvs_user` (String) User name for DECORT cloud API operations in 'bvs' authentication mode.
|
- `bvs_user` (String) User name for DECORT cloud API operations in 'bvs' authentication mode.
|
||||||
|
- `controller_url` (String) URL of DECORT Cloud controller to use. API calls will be directed to this URL.
|
||||||
- `domain` (String) User password for DECORT cloud API operations in 'bvs' authentication mode.
|
- `domain` (String) User password for DECORT cloud API operations in 'bvs' authentication mode.
|
||||||
- `jwt` (String) JWT to access DECORT cloud API in 'jwt' authentication mode.
|
- `jwt` (String) JWT to access DECORT cloud API in 'jwt' authentication mode.
|
||||||
- `oauth2_url` (String) OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.
|
- `oauth2_url` (String) OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ 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'
|
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
||||||
- `image_id` (Number) Specify image id for create disk from template
|
- `image_id` (Number) Specify image id for create disk from template
|
||||||
|
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
|
||||||
- `node_ids` (Set of Number)
|
- `node_ids` (Set of Number)
|
||||||
- `permanently` (Boolean) Disk deletion status
|
- `permanently` (Boolean) Disk deletion status
|
||||||
- `pool` (String) Pool name; by default will be chosen automatically
|
- `pool` (String) Pool name; by default will be chosen automatically
|
||||||
@@ -196,6 +197,26 @@ Read-Only:
|
|||||||
- `size_max` (Number)
|
- `size_max` (Number)
|
||||||
- `size_used` (Number)
|
- `size_used` (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`
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ 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'
|
- `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
|
||||||
@@ -189,6 +190,26 @@ Read-Only:
|
|||||||
- `size_max` (Number)
|
- `size_max` (Number)
|
||||||
- `size_used` (Number)
|
- `size_used` (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`
|
||||||
@@ -276,6 +297,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)
|
||||||
@@ -285,6 +307,26 @@ Read-Only:
|
|||||||
- `size_max` (Number)
|
- `size_max` (Number)
|
||||||
- `size_used` (Number)
|
- `size_used` (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`
|
||||||
|
|||||||
@@ -276,10 +276,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
|||||||
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(disksList))
|
res := make([]map[string]interface{}, 0, len(disksList))
|
||||||
|
|
||||||
if len(disksBlocks) == 0 {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(disksList, func(i, j int) bool {
|
sort.Slice(disksList, func(i, j int) bool {
|
||||||
return disksList[i].ID < disksList[j].ID
|
return disksList[i].ID < disksList[j].ID
|
||||||
})
|
})
|
||||||
@@ -291,7 +287,11 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
|
permanentlyValue := false
|
||||||
|
|
||||||
|
if indexDataDisks < len(disksBlocks) {
|
||||||
|
permanentlyValue = disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
|
||||||
|
}
|
||||||
|
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"disk_name": disk.Name,
|
"disk_name": disk.Name,
|
||||||
@@ -305,8 +305,9 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
|||||||
"desc": disk.Description,
|
"desc": disk.Description,
|
||||||
"image_id": disk.ImageID,
|
"image_id": disk.ImageID,
|
||||||
"size": disk.SizeMax,
|
"size": disk.SizeMax,
|
||||||
"permanently": pernamentlyValue,
|
"permanently": permanentlyValue,
|
||||||
"present_to": disk.PresentTo,
|
"present_to": disk.PresentTo,
|
||||||
|
"iotune": flattenIotune(disk.IOTune),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
indexDataDisks++
|
indexDataDisks++
|
||||||
@@ -447,6 +448,9 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
|||||||
d.Set("boot_type", computeRec.BootType)
|
d.Set("boot_type", computeRec.BootType)
|
||||||
d.Set("hot_resize", computeRec.HotResize)
|
d.Set("hot_resize", computeRec.HotResize)
|
||||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||||
|
d.Set("cpu_pin", computeRec.CPUPin)
|
||||||
|
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||||
|
d.Set("hp_backed", computeRec.HPBacked)
|
||||||
|
|
||||||
d.Set("enabled", false)
|
d.Set("enabled", false)
|
||||||
if computeRec.Status == status.Enabled {
|
if computeRec.Status == status.Enabled {
|
||||||
|
|||||||
@@ -587,6 +587,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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
||||||
|
|
||||||
@@ -1063,6 +1069,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
addedDisks := make([]interface{}, 0)
|
addedDisks := make([]interface{}, 0)
|
||||||
resizedDisks := make([]interface{}, 0)
|
resizedDisks := make([]interface{}, 0)
|
||||||
renamedDisks := make([]interface{}, 0)
|
renamedDisks := make([]interface{}, 0)
|
||||||
|
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||||
|
|
||||||
oldDisks, newDisks := d.GetChange("disks")
|
oldDisks, newDisks := d.GetChange("disks")
|
||||||
oldConv := oldDisks.([]interface{})
|
oldConv := oldDisks.([]interface{})
|
||||||
@@ -1100,6 +1107,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
if isRenameDisk(oldConv, el) {
|
if isRenameDisk(oldConv, el) {
|
||||||
renamedDisks = append(renamedDisks, el)
|
renamedDisks = append(renamedDisks, el)
|
||||||
}
|
}
|
||||||
|
if isChangeIOTuneDisk(oldConv, el) {
|
||||||
|
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deletedDisks) > 0 {
|
if len(deletedDisks) > 0 {
|
||||||
@@ -1153,10 +1163,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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1194,6 +1227,46 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(iotuneUpdatedDisks) > 0 {
|
||||||
|
for _, disk := range iotuneUpdatedDisks {
|
||||||
|
diskConv := disk.(map[string]interface{})
|
||||||
|
if diskConv["disk_type"].(string) == "B" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
diskID := uint64(diskConv["disk_id"].(int))
|
||||||
|
if diskID == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
iotuneRaw := diskConv["iotune"].([]interface{})
|
||||||
|
if len(iotuneRaw) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||||
|
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.CloudAPI().Disks().LimitIO(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("affinity_label") {
|
if d.HasChange("affinity_label") {
|
||||||
@@ -1815,8 +1888,84 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
"permanently": {
|
"permanently": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
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,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import (
|
|||||||
|
|
||||||
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"
|
||||||
@@ -433,3 +434,118 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.CloudAPI().Disks().LimitIO(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getComputeDiskIDs(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []interface{} {
|
||||||
|
res := make([]interface{}, 0)
|
||||||
|
|
||||||
|
if len(disksBlocks) == 0 {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(disksList, func(i, j int) bool {
|
||||||
|
return disksList[i].ID < disksList[j].ID
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, disk := range disksList {
|
||||||
|
if disk.ID == bootDiskId || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, disk.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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("description", 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 {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ package flipgroup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup"
|
||||||
@@ -107,9 +108,9 @@ 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 flattenFlipgroupResource: flipgroup_id %s, name %s",
|
||||||
d.Id(), d.Get("name").(string))
|
d.Id(), d.Get("name").(string))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
|||||||
d.Set("boot_type", computeRec.BootType)
|
d.Set("boot_type", computeRec.BootType)
|
||||||
d.Set("hot_resize", computeRec.HotResize)
|
d.Set("hot_resize", computeRec.HotResize)
|
||||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||||
|
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||||
|
d.Set("cpu_pin", computeRec.CPUPin)
|
||||||
|
d.Set("hp_backed", computeRec.HPBacked)
|
||||||
|
|
||||||
|
d.Set("started", computeRec.TechStatus == "STARTED")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,10 +227,6 @@ func flattenQOS(qos compute.QOS) []map[string]interface{} {
|
|||||||
func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(disksList))
|
res := make([]map[string]interface{}, 0, len(disksList))
|
||||||
|
|
||||||
if len(disksBlocks) == 0 {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(disksList, func(i, j int) bool {
|
sort.Slice(disksList, func(i, j int) bool {
|
||||||
return disksList[i].ID < disksList[j].ID
|
return disksList[i].ID < disksList[j].ID
|
||||||
})
|
})
|
||||||
@@ -236,8 +238,14 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
|
permanentlyValue := false
|
||||||
nodeIds := disksBlocks[indexDataDisks].(map[string]interface{})["node_ids"].(*schema.Set)
|
var nodeIds *schema.Set
|
||||||
|
|
||||||
|
if indexDataDisks < len(disksBlocks) {
|
||||||
|
log.Debug("entering indexDataDisks < len(disksBlocks)", indexDataDisks < len(disksBlocks), indexDataDisks, len(disksBlocks))
|
||||||
|
permanentlyValue = disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
|
||||||
|
nodeIds = disksBlocks[indexDataDisks].(map[string]interface{})["node_ids"].(*schema.Set)
|
||||||
|
}
|
||||||
|
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"disk_name": disk.Name,
|
"disk_name": disk.Name,
|
||||||
@@ -252,8 +260,9 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
|||||||
"shareable": disk.Shareable,
|
"shareable": disk.Shareable,
|
||||||
"size_used": disk.SizeUsed,
|
"size_used": disk.SizeUsed,
|
||||||
"size_max": disk.SizeMax,
|
"size_max": disk.SizeMax,
|
||||||
"permanently": pernamentlyValue,
|
"permanently": permanentlyValue,
|
||||||
"present_to": disk.PresentTo,
|
"present_to": disk.PresentTo,
|
||||||
|
"iotune": flattenIOTune(disk.IOTune),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
indexDataDisks++
|
indexDataDisks++
|
||||||
|
|||||||
@@ -585,6 +585,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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3499,6 +3499,81 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
addedDisks := make([]interface{}, 0)
|
addedDisks := make([]interface{}, 0)
|
||||||
resizedDisks := make([]interface{}, 0)
|
resizedDisks := make([]interface{}, 0)
|
||||||
renamedDisks := make([]interface{}, 0)
|
renamedDisks := make([]interface{}, 0)
|
||||||
|
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||||
presentNewDisks := make([]interface{}, 0)
|
presentNewDisks := make([]interface{}, 0)
|
||||||
presentOldDisks := make([]interface{}, 0)
|
presentOldDisks := make([]interface{}, 0)
|
||||||
|
|
||||||
@@ -278,6 +279,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
if isRenameDisk(oldConv, el) {
|
if isRenameDisk(oldConv, el) {
|
||||||
renamedDisks = append(renamedDisks, el)
|
renamedDisks = append(renamedDisks, el)
|
||||||
}
|
}
|
||||||
|
if isChangeIOTuneDisk(oldConv, el) {
|
||||||
|
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deletedDisks) > 0 {
|
if len(deletedDisks) > 0 {
|
||||||
@@ -349,6 +353,29 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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.CloudBroker().Disks().LimitIO(ctx, limitReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -390,6 +417,46 @@ 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 := diskConv["iotune"].([]interface{})
|
||||||
|
if 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{})
|
||||||
@@ -1638,6 +1705,66 @@ func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
diskList := d.Get("disks").([]interface{})
|
||||||
|
|
||||||
|
iotuneArr := make([]interface{}, 0, len(diskList))
|
||||||
|
hasAny := false
|
||||||
|
for _, elem := range diskList {
|
||||||
|
diskVal := elem.(map[string]interface{})
|
||||||
|
iotune := diskVal["iotune"].([]interface{})
|
||||||
|
iotuneArr = append(iotuneArr, iotune)
|
||||||
|
if len(iotune) > 0 {
|
||||||
|
hasAny = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasAny {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
bootDisk := findBootDisk(computeRec.Disks)
|
||||||
|
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
|
||||||
|
|
||||||
|
for i, diskID := range computeDisksIDs {
|
||||||
|
if i >= len(iotuneArr) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotune, ok := iotuneArr[i].([]interface{})
|
||||||
|
if !ok || len(iotune) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iotuneMap := iotune[0].(map[string]interface{})
|
||||||
|
req := disks.LimitIORequest{
|
||||||
|
DiskID: diskID.(uint64),
|
||||||
|
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||||
|
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||||
|
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||||
|
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||||
|
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||||
|
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||||
|
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||||
|
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||||
|
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||||
|
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||||
|
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||||
|
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||||
|
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||||
|
}
|
||||||
|
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
var errs error
|
var errs error
|
||||||
@@ -1683,6 +1810,40 @@ func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData
|
|||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 isResizeDisk(els []interface{}, el interface{}) bool {
|
func isResizeDisk(els []interface{}, el interface{}) bool {
|
||||||
for _, elOld := range els {
|
for _, elOld := range els {
|
||||||
elOldConv := elOld.(map[string]interface{})
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
|||||||
@@ -185,6 +185,27 @@ 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 = 3000
|
||||||
|
#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
|
||||||
|
|||||||
@@ -194,6 +194,27 @@ 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 = 3000
|
||||||
|
#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