4.11.0
This commit is contained in:
@@ -13,6 +13,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||
d.Set("account_id", disk.AccountID)
|
||||
d.Set("account_name", disk.AccountName)
|
||||
d.Set("acl", string(diskAcl))
|
||||
d.Set("blk_discard", disk.BLKDiscard)
|
||||
d.Set("boot_partition", disk.BootPartition)
|
||||
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||
d.Set("created_by", disk.CreatedBy)
|
||||
@@ -53,6 +54,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("cache", disk.Cache)
|
||||
d.Set("size_available", disk.SizeAvailable)
|
||||
d.Set("size_max", disk.SizeMax)
|
||||
d.Set("size_used", disk.SizeUsed)
|
||||
@@ -108,6 +110,7 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe
|
||||
d.Set("sep_id", disk.SEPID)
|
||||
d.Set("sep_type", disk.SEPType)
|
||||
d.Set("shareable", disk.Shareable)
|
||||
d.Set("cache", disk.Cache)
|
||||
d.Set("size_max", disk.SizeMax)
|
||||
d.Set("size_used", disk.SizeUsed)
|
||||
d.Set("snapshots", flattendDiskSnapshotList(disk.Snapshots))
|
||||
@@ -183,6 +186,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
"account_id": disk.AccountID,
|
||||
"account_name": disk.AccountName,
|
||||
"acl": string(diskAcl),
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"computes": flattenDiskComputes(disk.Computes),
|
||||
"created_by": disk.CreatedBy,
|
||||
@@ -221,6 +225,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
"role": disk.Role,
|
||||
"sep_id": disk.SEPID,
|
||||
"sep_type": disk.SEPType,
|
||||
"shareable": disk.Shareable,
|
||||
"cache": disk.Cache,
|
||||
"size_available": disk.SizeAvailable,
|
||||
"size_max": disk.SizeMax,
|
||||
"size_used": disk.SizeUsed,
|
||||
@@ -293,11 +299,11 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
|
||||
for _, unattachedDisk := range ul.Data {
|
||||
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
|
||||
tmp := map[string]interface{}{
|
||||
"_ckey": unattachedDisk.CKey,
|
||||
"_meta": flattens.FlattenMeta(unattachedDisk.Meta),
|
||||
"account_id": unattachedDisk.AccountID,
|
||||
"account_name": unattachedDisk.AccountName,
|
||||
"acl": string(unattachedDiskAcl),
|
||||
"blk_discard": unattachedDisk.BLKDiscard,
|
||||
"boot_partition": unattachedDisk.BootPartition,
|
||||
"created_time": unattachedDisk.CreatedTime,
|
||||
"deleted_time": unattachedDisk.DeletedTime,
|
||||
@@ -330,6 +336,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
|
||||
"role": unattachedDisk.Role,
|
||||
"sep_id": unattachedDisk.SEPID,
|
||||
"shareable": unattachedDisk.Shareable,
|
||||
"cache": unattachedDisk.Cache,
|
||||
"size_max": unattachedDisk.SizeMax,
|
||||
"size_used": unattachedDisk.SizeUsed,
|
||||
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
|
||||
|
||||
@@ -75,6 +75,14 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
req.Pool = pool.(string)
|
||||
}
|
||||
|
||||
if cache, ok := d.GetOk("cache"); ok {
|
||||
req.Cache = cache.(string)
|
||||
}
|
||||
|
||||
if blkDiscard, ok := d.GetOk("blk_discard"); ok {
|
||||
req.BLKDiscard = blkDiscard.(bool)
|
||||
}
|
||||
|
||||
diskID, err := c.CloudBroker().Disks().Create(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
@@ -236,6 +244,18 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cache") {
|
||||
if err := resourceDiskChangeCache(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("blk_discard") {
|
||||
if err := resourceDiskChangeBLKDiscard(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("node_ids") {
|
||||
log.Debugf("resourceDiskUpdate: present for disk %d", d.Get("disk_id"))
|
||||
if err := resourceDiskChangeNodes(ctx, d, m, false); err != nil {
|
||||
@@ -362,6 +382,26 @@ func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceDa
|
||||
return err
|
||||
}
|
||||
|
||||
func resourceDiskChangeCache(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
|
||||
DiskID: uint64(d.Get("disk_id").(int)),
|
||||
Cache: d.Get("cache").(string),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func resourceDiskChangeBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
|
||||
DiskID: uint64(d.Get("disk_id").(int)),
|
||||
BLKDiscard: d.Get("blk_discard").(bool),
|
||||
})
|
||||
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))
|
||||
|
||||
@@ -22,6 +22,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -281,6 +285,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
@@ -456,6 +464,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -719,6 +731,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
@@ -880,6 +896,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1143,6 +1163,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
@@ -1400,11 +1424,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"_ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CKey",
|
||||
},
|
||||
"_meta": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1427,6 +1446,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1659,6 +1682,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1964,12 +1991,23 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "none",
|
||||
Description: "Cache mode for the disk",
|
||||
},
|
||||
"restore": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "restore deleting disk",
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -2569,6 +2607,10 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -2939,6 +2981,10 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
Reference in New Issue
Block a user