This commit is contained in:
2025-11-18 16:20:26 +03:00
parent 4b3f21d9be
commit e42fbcef39
397 changed files with 17560 additions and 1501 deletions

View File

@@ -58,11 +58,13 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("size_used", disk.SizeUsed)
d.Set("snapshots", flattendDiskSnapshotList(disk.Snapshots))
d.Set("status", disk.Status)
d.Set("storage_policy_id", disk.StoragePolicyID)
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)
d.Set("to_clean", disk.ToClean)
}
func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusReplication string) {
@@ -224,11 +226,13 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"size_used": disk.SizeUsed,
"snapshots": flattendDiskSnapshotList(disk.Snapshots),
"status": disk.Status,
"storage_policy_id": disk.StoragePolicyID,
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
"to_clean": disk.ToClean,
}
res = append(res, temp)
}

View File

@@ -57,19 +57,16 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
}
req := disks.CreateRequest{
AccountID: uint64(d.Get("account_id").(int)),
Name: d.Get("disk_name").(string),
Size: uint64(d.Get("size_max").(int)),
AccountID: uint64(d.Get("account_id").(int)),
StoragePolicyID: uint64(d.Get("storage_policy_id").(int)),
Name: d.Get("disk_name").(string),
Size: uint64(d.Get("size_max").(int)),
}
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
if iops, ok := d.GetOk("iops"); ok {
req.IOPS = uint64(iops.(int))
}
if sepID, ok := d.GetOk("sep_id"); ok {
req.SEPID = uint64(sepID.(int))
}
@@ -202,6 +199,12 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.HasChange("storage_policy_id") {
if err := resourceDiskChangeStoragePolicyID(ctx, d, m); err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("size_max") {
oldSize, newSize := d.GetChange("size_max")
if oldSize.(int) > newSize.(int) {
@@ -297,8 +300,6 @@ func resourceDiskChangeIotune(ctx context.Context, d *schema.ResourceData, m int
if _, ok := iotune["total_iops_sec"]; ok {
req.IOPS = uint64(iotune["total_iops_sec"].(int))
} else if _, ok := d.GetOk("iops"); ok {
req.IOPS = uint64(d.Get("iops").(int))
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
@@ -351,6 +352,16 @@ func resourceDiskChangeSize(ctx context.Context, d *schema.ResourceData, m inter
return err
}
func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
_, err := c.CloudBroker().Disks().ChangeDiskStoragePolicy(ctx, disks.ChangeDiskStoragePolicyRequest{
DiskID: uint64(d.Get("disk_id").(int)),
StoragePolicyID: uint64(d.Get("storage_policy_id").(int)),
})
return err
}
func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m interface{}, afterCreate bool) error {
c := m.(*controller.ControllerCfg)
diskID := uint64(d.Get("disk_id").(int))

View File

@@ -333,6 +333,11 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_id": {
Type: schema.TypeFloat,
Computed: true,
Description: "Storage policy ID",
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
@@ -353,6 +358,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
}
return rets
@@ -425,6 +434,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Page size",
},
"storage_policy_id": {
Type: schema.TypeInt,
Optional: true,
Description: "storage policy ID ",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -757,6 +771,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_id": {
Type: schema.TypeFloat,
Computed: true,
Description: "Storage policy ID",
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
@@ -777,6 +796,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
@@ -1172,6 +1195,11 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_id": {
Type: schema.TypeFloat,
Computed: true,
Description: "Storage policy ID",
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
@@ -1192,6 +1220,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
@@ -1358,6 +1390,11 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Page size",
},
"storage_policy_id": {
Type: schema.TypeInt,
Optional: true,
Description: "storage policy ID ",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -1863,6 +1900,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Required: true,
//ForceNew: true,
},
"storage_policy_id": {
Type: schema.TypeInt,
Required: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
@@ -1889,11 +1930,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"iops": {
Type: schema.TypeInt,
Optional: true,
Description: "max IOPS disk can perform",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -2252,6 +2288,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
}
return rets

View File

@@ -85,6 +85,9 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudBroker().Disks().List(ctx, req)

View File

@@ -46,6 +46,9 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
unattachedList, err := c.CloudBroker().Disks().ListUnattached(ctx, req)