4.9.10
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
## Version 4.9.9
|
||||
## Version 4.9.10
|
||||
|
||||
### Исправлено
|
||||
### Добавлено
|
||||
|
||||
#### kvmvmm
|
||||
#### kvmvm
|
||||
| Идентификатор<br>задачи | Описание |
|
||||
| --- | --- |
|
||||
| BATF-1241 | Ошибки применения новой конфигурации после импортирования в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
| BATF-1270 | Опциональное поле `iotune` в блоке `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
||||
BINARY=${NAME}
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=4.9.9
|
||||
VERSION=4.9.10
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
|
||||
@@ -18,6 +18,7 @@ description: |-
|
||||
### Required
|
||||
|
||||
- `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
|
||||
|
||||
@@ -26,7 +27,6 @@ description: |-
|
||||
- `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_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.
|
||||
- `jwt` (String) JWT to access DECORT cloud API in 'jwt' authentication mode.
|
||||
- `oauth2_url` (String) OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.
|
||||
|
||||
@@ -183,6 +183,7 @@ Optional:
|
||||
- `desc` (String) Optional description
|
||||
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
||||
- `image_id` (Number) Specify image id for create disk from template
|
||||
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
|
||||
- `node_ids` (Set of Number)
|
||||
- `permanently` (Boolean) Disk deletion status
|
||||
- `pool` (String) Pool name; by default will be chosen automatically
|
||||
@@ -196,6 +197,26 @@ Read-Only:
|
||||
- `size_max` (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>
|
||||
### Nested Schema for `libvirt_settings`
|
||||
|
||||
@@ -177,6 +177,7 @@ Optional:
|
||||
- `desc` (String) Optional description
|
||||
- `disk_type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data'
|
||||
- `image_id` (Number) Specify image id for create disk from template
|
||||
- `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--disks--iotune))
|
||||
- `permanently` (Boolean) Disk deletion status
|
||||
- `pool` (String) Pool name; by default will be chosen automatically
|
||||
- `sep_id` (Number) Storage endpoint provider ID; by default the same with boot disk
|
||||
@@ -189,6 +190,26 @@ Read-Only:
|
||||
- `size_max` (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>
|
||||
### Nested Schema for `network`
|
||||
@@ -276,6 +297,7 @@ Read-Only:
|
||||
- `disk_name` (String)
|
||||
- `disk_type` (String)
|
||||
- `image_id` (Number)
|
||||
- `iotune` (List of Object) (see [below for nested schema](#nestedobjatt--boot_disk--iotune))
|
||||
- `permanently` (Boolean)
|
||||
- `pool` (String)
|
||||
- `present_to` (Map of Number)
|
||||
@@ -285,6 +307,26 @@ Read-Only:
|
||||
- `size_max` (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>
|
||||
### Nested Schema for `interfaces`
|
||||
|
||||
@@ -307,6 +307,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"size": disk.SizeMax,
|
||||
"permanently": permanentlyValue,
|
||||
"present_to": disk.PresentTo,
|
||||
"iotune": flattenIotune(disk.IOTune),
|
||||
}
|
||||
res = append(res, temp)
|
||||
indexDataDisks++
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1063,6 +1069,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
addedDisks := make([]interface{}, 0)
|
||||
resizedDisks := make([]interface{}, 0)
|
||||
renamedDisks := make([]interface{}, 0)
|
||||
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||
|
||||
oldDisks, newDisks := d.GetChange("disks")
|
||||
oldConv := oldDisks.([]interface{})
|
||||
@@ -1100,6 +1107,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if isRenameDisk(oldConv, el) {
|
||||
renamedDisks = append(renamedDisks, el)
|
||||
}
|
||||
if isChangeIOTuneDisk(oldConv, el) {
|
||||
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deletedDisks) > 0 {
|
||||
@@ -1153,10 +1163,33 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if diskConv["image_id"].(int) != 0 {
|
||||
req.ImageID = uint64(diskConv["image_id"].(int))
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
||||
diskID, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
|
||||
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||
limitReq := disks.LimitIORequest{
|
||||
DiskID: diskID,
|
||||
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
|
||||
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
|
||||
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
|
||||
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
|
||||
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
|
||||
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
|
||||
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
|
||||
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
|
||||
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
|
||||
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
|
||||
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
|
||||
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
|
||||
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
|
||||
}
|
||||
_, err := c.CloudAPI().Disks().LimitIO(ctx, limitReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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") {
|
||||
@@ -1818,6 +1891,81 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "Disk deletion status",
|
||||
},
|
||||
"iotune": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"read_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"read_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"read_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"read_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"size_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"total_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"total_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"total_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"total_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"write_bytes_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"write_bytes_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"write_iops_sec": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"write_iops_sec_max": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
@@ -433,3 +434,118 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -262,6 +262,7 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
||||
"size_max": disk.SizeMax,
|
||||
"permanently": permanentlyValue,
|
||||
"present_to": disk.PresentTo,
|
||||
"iotune": flattenIOTune(disk.IOTune),
|
||||
}
|
||||
res = append(res, temp)
|
||||
indexDataDisks++
|
||||
|
||||
@@ -585,6 +585,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3499,6 +3499,81 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
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)
|
||||
resizedDisks := make([]interface{}, 0)
|
||||
renamedDisks := make([]interface{}, 0)
|
||||
iotuneUpdatedDisks := make([]interface{}, 0)
|
||||
presentNewDisks := 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) {
|
||||
renamedDisks = append(renamedDisks, el)
|
||||
}
|
||||
if isChangeIOTuneDisk(oldConv, el) {
|
||||
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
newDisk := presentNewDisks[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
|
||||
}
|
||||
|
||||
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 {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var errs error
|
||||
@@ -1683,6 +1810,40 @@ func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData
|
||||
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 {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
|
||||
@@ -185,6 +185,27 @@ resource "decort_kvmvm" "comp" {
|
||||
#опциональный параметр
|
||||
#тип - булев
|
||||
#permanently = false
|
||||
|
||||
#настройки лимитов операций ввода/вывода диска
|
||||
#опциональный параметр
|
||||
#тип - блок
|
||||
#тип вложенных полей - целое число
|
||||
#используется при создании и обновлении
|
||||
#iotune {
|
||||
#read_bytes_sec = 0
|
||||
#read_bytes_sec_max = 0
|
||||
#read_iops_sec = 0
|
||||
#read_iops_sec_max = 0
|
||||
#size_iops_sec = 0
|
||||
#total_bytes_sec = 0
|
||||
#total_bytes_sec_max = 0
|
||||
#total_iops_sec = 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
|
||||
|
||||
@@ -194,6 +194,27 @@ resource "decort_cb_kvmvm" "comp" {
|
||||
#опциональный параметр
|
||||
#тип - булев
|
||||
#permanently = false
|
||||
|
||||
#настройки лимитов операций ввода/вывода диска
|
||||
#опциональный параметр
|
||||
#тип - блок
|
||||
#тип вложенных полей - целое число
|
||||
#используется при создании и обновлении
|
||||
#iotune {
|
||||
#read_bytes_sec = 0
|
||||
#read_bytes_sec_max = 0
|
||||
#read_iops_sec = 0
|
||||
#read_iops_sec_max = 0
|
||||
#size_iops_sec = 0
|
||||
#total_bytes_sec = 0
|
||||
#total_bytes_sec_max = 0
|
||||
#total_iops_sec = 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
|
||||
|
||||
Reference in New Issue
Block a user