|
|
|
@ -236,7 +236,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
argVal, ok = d.GetOk("extra_disks")
|
|
|
|
|
if ok && argVal.(*schema.Set).Len() > 0 {
|
|
|
|
|
log.Debugf("resourceComputeCreate: calling utilityComputeExtraDisksConfigure to attach %d extra disk(s)", argVal.(*schema.Set).Len())
|
|
|
|
|
err = utilityComputeExtraDisksConfigure(ctx, d, m, false)
|
|
|
|
|
err = utilityComputeExtraDisksConfigure(ctx, d, m, false, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Errorf("resourceComputeCreate: error when attaching extra disk(s) to a new Compute ID %d: %v", computeId, err)
|
|
|
|
|
cleanup = true
|
|
|
|
@ -716,7 +716,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if d.HasChange("extra_disks") {
|
|
|
|
|
err := utilityComputeExtraDisksConfigure(ctx, d, m, true) // pass do_delta = true to apply changes, if any
|
|
|
|
|
err := utilityComputeExtraDisksConfigure(ctx, d, m, true, computeRec.Disks) // pass do_delta = true to apply changes, if any
|
|
|
|
|
if err != nil {
|
|
|
|
|
return diag.FromErr(err)
|
|
|
|
|
}
|
|
|
|
@ -755,7 +755,23 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
|
|
|
|
|
for _, el := range oldConv {
|
|
|
|
|
if !isContainsDisk(newConv, el) {
|
|
|
|
|
deletedDisks = append(deletedDisks, el)
|
|
|
|
|
flag := false
|
|
|
|
|
extraDisks := d.Get("extra_disks").(*schema.Set).List()
|
|
|
|
|
delDisk := el.(map[string]interface{})
|
|
|
|
|
delDiskId := delDisk["disk_id"].(int)
|
|
|
|
|
|
|
|
|
|
for _, extraDiskId := range extraDisks {
|
|
|
|
|
if extraDiskId.(int) == delDiskId {
|
|
|
|
|
flag = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !flag {
|
|
|
|
|
deletedDisks = append(deletedDisks, el)
|
|
|
|
|
} else {
|
|
|
|
|
log.Debugf("disk %d will not be deleted because it is present in the extra_disks block", delDiskId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -792,6 +808,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
Permanently: diskConv["permanently"].(bool),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Debugf("trying to delete disk %d", req.DiskID)
|
|
|
|
|
|
|
|
|
|
_, err := c.CloudAPI().Compute().DiskDel(ctx, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return diag.FromErr(err)
|
|
|
|
@ -1759,6 +1777,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|
|
|
|
"extra_disks": {
|
|
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Computed: true,
|
|
|
|
|
MaxItems: constants.MaxExtraDisksPerCompute,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
|