This commit is contained in:
2025-05-21 16:38:25 +03:00
parent 2c70109d2d
commit 9e68edb2b9
1034 changed files with 73925 additions and 3187 deletions

View File

@@ -15,7 +15,9 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("acl", string(diskAcl))
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_by", disk.DeletedBy)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Description)
d.Set("destruction_time", disk.DestructionTime)
@@ -29,6 +31,8 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
d.Set("machine_id", disk.MachineID)
d.Set("machine_name", disk.MachineName)
d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
@@ -49,6 +53,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("sep_id", disk.SEPID)
d.Set("sep_type", disk.SEPType)
d.Set("shareable", disk.Shareable)
d.Set("size_available", disk.SizeAvailable)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("snapshots", flattendDiskSnapshotList(disk.Snapshots))
@@ -56,6 +61,8 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
}
func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusReplication string) {
@@ -176,7 +183,9 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"acl": string(diskAcl),
"boot_partition": disk.BootPartition,
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
"created_time": disk.CreatedTime,
"deleted_by": disk.DeletedBy,
"deleted_time": disk.DeletedTime,
"desc": disk.Description,
"destruction_time": disk.DestructionTime,
@@ -210,6 +219,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"role": disk.Role,
"sep_id": disk.SEPID,
"sep_type": disk.SEPType,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattendDiskSnapshotList(disk.Snapshots),
@@ -217,6 +227,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
}

View File

@@ -2,6 +2,7 @@ package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
@@ -14,15 +15,10 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
var errs []error
accountID := uint64(d.Get("account_id").(int))
gid := uint64(d.Get("gid").(int))
if err := ic.ExistAccount(ctx, accountID, c); err != nil {
errs = append(errs, err)
}
if err := ic.ExistGID(ctx, gid, c); err != nil {
errs = append(errs, err)
}
return dc.ErrorsToDiagnostics(errs)
}

View File

@@ -58,20 +58,14 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
req := disks.CreateRequest{
AccountID: uint64(d.Get("account_id").(int)),
GID: uint64(d.Get("gid").(int)),
Name: d.Get("disk_name").(string),
Size: uint64(d.Get("size_max").(int)),
Type: d.Get("type").(string),
}
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
if ssdSize, ok := d.GetOk("ssd_size"); ok {
req.SSDSize = uint64(ssdSize.(int))
}
if iops, ok := d.GetOk("iops"); ok {
req.IOPS = uint64(iops.(int))
}

View File

@@ -2,7 +2,6 @@ package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceDiskSchemaMake() map[string]*schema.Schema {
@@ -43,10 +42,18 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -154,6 +161,14 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -187,7 +202,7 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -266,6 +281,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -326,6 +345,14 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
@@ -435,10 +462,18 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -591,7 +626,7 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -670,6 +705,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -730,6 +769,14 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -830,10 +877,18 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -986,7 +1041,7 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1065,6 +1120,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -1125,6 +1184,14 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1505,7 +1572,7 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1796,22 +1863,18 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Required: true,
//ForceNew: true,
},
"gid": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: 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,
@@ -1821,9 +1884,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Required: true,
},
"ssd_size": {
Type: schema.TypeInt,
Optional: true,
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"iops": {
Type: schema.TypeInt,
@@ -1922,6 +1986,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
@@ -2020,11 +2088,18 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Computed: true,
@@ -2046,7 +2121,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2169,6 +2244,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
@@ -2367,7 +2450,7 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2741,7 +2824,7 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,