4.13.0
This commit is contained in:
@@ -349,7 +349,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"storage_policy_ids": {
|
||||
|
||||
@@ -116,6 +116,8 @@ func DataSourceAccountAuditsList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceAccountAuditsListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -79,6 +79,8 @@ func DataSourceAccountConsumedUnitsByType() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0.",
|
||||
|
||||
ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -99,6 +99,8 @@ func DataSourceAccountReservedUnits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0.",
|
||||
|
||||
ReadContext: dataSourceAccountReservedUnitsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -501,12 +501,14 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "whether to completely delete the account",
|
||||
Deprecated: "\"permanently\" is deprecated and will be removed in version 4.14.0",
|
||||
},
|
||||
"enable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "enable/disable account",
|
||||
Deprecated: "\"enable\" is deprecated and will be removed in version 4.14.0",
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
@@ -667,7 +669,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"storage_policy_ids": {
|
||||
|
||||
@@ -80,8 +80,8 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -109,6 +109,22 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"computes_read_only": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -431,6 +447,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -152,8 +152,8 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -181,6 +181,22 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"computes_read_only": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -510,6 +526,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -155,8 +155,8 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -430,6 +430,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -416,6 +416,10 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -123,8 +123,8 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -152,6 +152,22 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"computes_read_only": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -481,6 +497,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -25,7 +25,7 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
|
||||
"account_id": unattachedDisk.AccountID,
|
||||
"account_name": unattachedDisk.AccountName,
|
||||
"acl": string(unattachedDiskAcl),
|
||||
"blk_discard": unattachedDisk.BLKDiscard,
|
||||
"discard": unattachedDisk.Discard,
|
||||
"block_size": unattachedDisk.BlockSize,
|
||||
"boot_partition": unattachedDisk.BootPartition,
|
||||
"created_time": unattachedDisk.CreatedTime,
|
||||
@@ -79,10 +79,11 @@ 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("discard", disk.Discard)
|
||||
d.Set("block_size", disk.BlockSize)
|
||||
// d.Set("boot_partition", disk.BootPartition)
|
||||
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||
d.Set("computes_read_only", flattenDiskComputesReadOnly(disk.ComputesReadOnly))
|
||||
d.Set("created_by", disk.CreatedBy)
|
||||
d.Set("created_time", disk.CreatedTime)
|
||||
d.Set("deleted_by", disk.DeletedBy)
|
||||
@@ -206,6 +207,7 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
"label": snapshot.Label,
|
||||
"pool_name": snapshot.PoolName,
|
||||
"res_id": snapshot.ResID,
|
||||
"snap_set_guid": snapshot.SnapSetGUID,
|
||||
"snap_set_time": snapshot.SnapSetTime,
|
||||
@@ -222,56 +224,57 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
for _, disk := range dl.Data {
|
||||
diskAcl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
"account_id": disk.AccountID,
|
||||
"account_name": disk.AccountName,
|
||||
"acl": string(diskAcl),
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"block_size": disk.BlockSize,
|
||||
"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,
|
||||
"devicename": disk.DeviceName,
|
||||
"gid": disk.GID,
|
||||
"disk_id": disk.ID,
|
||||
"image_id": disk.ImageID,
|
||||
"images": disk.Images,
|
||||
"independent": disk.Independent,
|
||||
"iotune": flattenIOTune(disk.IOTune),
|
||||
"machine_id": disk.MachineID,
|
||||
"machine_name": disk.MachineName,
|
||||
"milestones": disk.Milestones,
|
||||
"disk_name": disk.Name,
|
||||
"order": disk.Order,
|
||||
"params": disk.Params,
|
||||
"parent_id": disk.ParentID,
|
||||
"pci_slot": disk.PCISlot,
|
||||
"pool": disk.Pool,
|
||||
"present_to": disk.PresentTo,
|
||||
"provision": disk.Provision,
|
||||
"purge_time": disk.PurgeTime,
|
||||
"replication": flattenDiskReplication(disk.Replication),
|
||||
"res_id": disk.ResID,
|
||||
"res_name": disk.ResName,
|
||||
"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,
|
||||
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
|
||||
"status": disk.Status,
|
||||
"storage_policy_id": disk.StoragePolicyID,
|
||||
"tech_status": disk.TechStatus,
|
||||
"vmid": disk.VMID,
|
||||
"updated_by": disk.UpdatedBy,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"to_clean": disk.ToClean,
|
||||
"account_id": disk.AccountID,
|
||||
"account_name": disk.AccountName,
|
||||
"acl": string(diskAcl),
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"computes": flattenDiskComputes(disk.Computes),
|
||||
"computes_read_only": flattenDiskComputesReadOnly(disk.ComputesReadOnly),
|
||||
"created_by": disk.CreatedBy,
|
||||
"created_time": disk.CreatedTime,
|
||||
"deleted_by": disk.DeletedBy,
|
||||
"deleted_time": disk.DeletedTime,
|
||||
"desc": disk.Description,
|
||||
"destruction_time": disk.DestructionTime,
|
||||
"devicename": disk.DeviceName,
|
||||
"gid": disk.GID,
|
||||
"disk_id": disk.ID,
|
||||
"image_id": disk.ImageID,
|
||||
"images": disk.Images,
|
||||
"independent": disk.Independent,
|
||||
"iotune": flattenIOTune(disk.IOTune),
|
||||
"machine_id": disk.MachineID,
|
||||
"machine_name": disk.MachineName,
|
||||
"milestones": disk.Milestones,
|
||||
"disk_name": disk.Name,
|
||||
"order": disk.Order,
|
||||
"params": disk.Params,
|
||||
"parent_id": disk.ParentID,
|
||||
"pci_slot": disk.PCISlot,
|
||||
"pool": disk.Pool,
|
||||
"present_to": disk.PresentTo,
|
||||
"provision": disk.Provision,
|
||||
"purge_time": disk.PurgeTime,
|
||||
"replication": flattenDiskReplication(disk.Replication),
|
||||
"res_id": disk.ResID,
|
||||
"res_name": disk.ResName,
|
||||
"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,
|
||||
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
|
||||
"status": disk.Status,
|
||||
"storage_policy_id": disk.StoragePolicyID,
|
||||
"tech_status": disk.TechStatus,
|
||||
"vmid": disk.VMID,
|
||||
"updated_by": disk.UpdatedBy,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"to_clean": disk.ToClean,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -311,3 +314,15 @@ func flattenDiskComputes(computes map[string]string) []map[string]interface{} {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDiskComputesReadOnly(computesReadOnly map[string]bool) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for computeID, readOnly := range computesReadOnly {
|
||||
temp := map[string]interface{}{
|
||||
"compute_id": computeID,
|
||||
"read_only": readOnly,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -419,3 +419,12 @@ func resourceDiskV1() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceDiskV2() *schema.Resource {
|
||||
s := resourceDiskSchemaMake()
|
||||
s["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
@@ -558,6 +558,22 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"computes_read_only": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -755,6 +771,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Name of the snapshot",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -805,10 +825,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Flag indicating whether blk-discard is enabled for the disk",
|
||||
Description: "Discard mode of the disk",
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
@@ -821,7 +841,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceDisk() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 2,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CreateContext: resourceDiskCreate,
|
||||
ReadContext: resourceDiskRead,
|
||||
@@ -847,6 +867,11 @@ func ResourceDisk() *schema.Resource {
|
||||
Upgrade: resourceDiskUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceDiskV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceDiskUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,3 +12,17 @@ func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{},
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceDiskUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceDiskUpgradeV2: upgrading state")
|
||||
if v, ok := rawState["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
rawState["discard"] = "unmap"
|
||||
} else {
|
||||
rawState["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(rawState, "blk_discard")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -138,6 +138,10 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"free_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -133,10 +133,11 @@ func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(el.Data))
|
||||
for _, e := range el.Data {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
"name": e.Name,
|
||||
"status": e.Status,
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
"name": e.Name,
|
||||
"status": e.Status,
|
||||
"free_ips": e.FreeIPs,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -83,9 +83,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Filter by architecture",
|
||||
},
|
||||
"type_image": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "Filter by image type",
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"image_size": {
|
||||
Type: schema.TypeInt,
|
||||
|
||||
@@ -64,7 +64,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
|
||||
d.Set("storage_policy_id", img.StoragePolicyID)
|
||||
d.Set("tech_status", img.TechStatus)
|
||||
d.Set("to_clean", img.ToClean)
|
||||
d.Set("type", img.Type)
|
||||
d.Set("image_type", img.Type)
|
||||
d.Set("username", img.Username)
|
||||
d.Set("version", img.Version)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
|
||||
"size": img.Size,
|
||||
"status": img.Status,
|
||||
"storage_policy_id": img.StoragePolicyID,
|
||||
"type": img.Type,
|
||||
"type_image": img.Type,
|
||||
"username": img.Username,
|
||||
"virtual": img.Virtual,
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
"type_image": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Image type",
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
|
||||
func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema {
|
||||
delete(sch, "show_all")
|
||||
|
||||
sch["name"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
@@ -52,9 +53,8 @@ func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*s
|
||||
|
||||
sch["account_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "account_id",
|
||||
Required: true,
|
||||
Description: "Account ID",
|
||||
}
|
||||
|
||||
sch["image_id"] = &schema.Schema{
|
||||
|
||||
@@ -63,7 +63,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
}
|
||||
|
||||
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||
req.TypeImage = typeImage.(string)
|
||||
for _, v := range typeImage.([]interface{}) {
|
||||
req.TypeImage = append(req.TypeImage, v.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if imageSize, ok := d.GetOk("image_size"); ok {
|
||||
|
||||
@@ -653,7 +653,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
//ForceNew: true,
|
||||
Description: "ID of the k8s catalog item to base this instance on.",
|
||||
Description: "ID of the k8s catalog item to base this instance on. The maximum supported Kubernetes version is < 1.29.",
|
||||
},
|
||||
"wg_name": {
|
||||
Type: schema.TypeString,
|
||||
@@ -805,13 +805,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
||||
Description: "insert ssl certificate in x509 pem format",
|
||||
},
|
||||
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -673,7 +673,7 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
//ForceNew: true,
|
||||
Description: "ID of the k8s catalog item to base this instance on.",
|
||||
Description: "ID of the k8s catalog item to base this instance on. The maximum supported Kubernetes version is < 1.29.",
|
||||
},
|
||||
"network_plugin": {
|
||||
Type: schema.TypeString,
|
||||
@@ -715,13 +715,13 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
),
|
||||
Description: "Node RAM in MB.",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"disk": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
@@ -220,8 +220,12 @@ func computeSnapshotsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"reference_id": {
|
||||
Type: schema.TypeInt,
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"res_id": {
|
||||
@@ -244,20 +248,44 @@ func computeSnapshotsSchemaMake() map[string]*schema.Schema {
|
||||
}
|
||||
func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"_ckey": {
|
||||
/*"_ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"acl": {
|
||||
Type: schema.TypeString,
|
||||
},*/
|
||||
/*"acl": {
|
||||
Type: schema.TypeList,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"user_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"right": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"explicit": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
},*/
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -316,10 +344,11 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"image_name": {
|
||||
// TODO
|
||||
/*"image_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},*/
|
||||
"images": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -489,6 +518,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,6 +572,10 @@ func computeInterfacesSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"enable_default_gateway": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"flip_group_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -708,8 +745,13 @@ func computeSnapSetsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"memory_dump_image": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
@@ -766,6 +808,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_order": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -789,6 +835,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"pci_devices": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -807,6 +857,26 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -998,6 +1068,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"resized_online": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"res_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -136,6 +136,8 @@ func DataSourceComputeAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceComputeAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceComputeCPUAlignmentProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
profile, err := utilityComputeGetCPUAlignmentProfile(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("model", profile.Model)
|
||||
d.Set("name", profile.Name)
|
||||
d.Set("vendor", profile.Vendor)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeCPUAlignmentProfileSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the compute instance",
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU model of the alignment profile",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the CPU alignment profile",
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "CPU vendor of the alignment profile",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputeCPUAlignmentProfile() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeCPUAlignmentProfileRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeCPUAlignmentProfileSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,8 @@ func DataSourceComputeGetAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceComputeGetAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -80,6 +80,10 @@ func computeDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
@@ -156,6 +160,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"clones": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -167,6 +175,26 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cpu_pin": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -335,6 +363,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"resized_online": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"res_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -50,7 +50,8 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
|
||||
// "bus_number": disk.BusNumber,
|
||||
"disk_id": disk.ID,
|
||||
// "pci_slot": disk.PCISlot,
|
||||
"sep_id": disk.SepID,
|
||||
"sep_id": disk.SepID,
|
||||
"read_only": disk.ReadOnly,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -71,32 +72,33 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, interfaceItem := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"bus_number": interfaceItem.BusNumber,
|
||||
"conn_id": interfaceItem.ConnID,
|
||||
"conn_type": interfaceItem.ConnType,
|
||||
"def_gw": interfaceItem.DefGW,
|
||||
"enabled": interfaceItem.Enabled,
|
||||
"enable_secgroups": interfaceItem.EnableSecGroups,
|
||||
"flip_group_id": interfaceItem.FLIPGroupID,
|
||||
"guid": interfaceItem.GUID,
|
||||
"ip_address": interfaceItem.IPAddress,
|
||||
"listen_ssh": interfaceItem.ListenSSH,
|
||||
"mac": interfaceItem.MAC,
|
||||
"mtu": interfaceItem.MTU,
|
||||
"name": interfaceItem.Name,
|
||||
"net_id": interfaceItem.NetID,
|
||||
"netmask": interfaceItem.NetMask,
|
||||
"net_type": interfaceItem.NetType,
|
||||
"node_id": interfaceItem.NodeID,
|
||||
"pci_slot": interfaceItem.PCISlot,
|
||||
"qos": flattenQOS(interfaceItem.QOS),
|
||||
"security_groups": interfaceItem.SecGroups,
|
||||
"sdn_interface_id": interfaceItem.SDNInterfaceID,
|
||||
"target": interfaceItem.Target,
|
||||
"type": interfaceItem.Type,
|
||||
"trunk_tags": interfaceItem.TrunkTags,
|
||||
"vnfs": interfaceItem.VNFs,
|
||||
"libvirt_settings": flattenLibvirtSettings(interfaceItem.LibvirtSettings),
|
||||
"bus_number": interfaceItem.BusNumber,
|
||||
"conn_id": interfaceItem.ConnID,
|
||||
"conn_type": interfaceItem.ConnType,
|
||||
"def_gw": interfaceItem.DefGW,
|
||||
"enabled": interfaceItem.Enabled,
|
||||
"enable_secgroups": interfaceItem.EnableSecGroups,
|
||||
"enable_default_gateway": interfaceItem.EnableDefaultGateway,
|
||||
"flip_group_id": interfaceItem.FLIPGroupID,
|
||||
"guid": interfaceItem.GUID,
|
||||
"ip_address": interfaceItem.IPAddress,
|
||||
"listen_ssh": interfaceItem.ListenSSH,
|
||||
"mac": interfaceItem.MAC,
|
||||
"mtu": interfaceItem.MTU,
|
||||
"name": interfaceItem.Name,
|
||||
"net_id": interfaceItem.NetID,
|
||||
"netmask": interfaceItem.NetMask,
|
||||
"net_type": interfaceItem.NetType,
|
||||
"node_id": interfaceItem.NodeID,
|
||||
"pci_slot": interfaceItem.PCISlot,
|
||||
"qos": flattenQOS(interfaceItem.QOS),
|
||||
"security_groups": interfaceItem.SecGroups,
|
||||
"sdn_interface_id": interfaceItem.SDNInterfaceID,
|
||||
"target": interfaceItem.Target,
|
||||
"type": interfaceItem.Type,
|
||||
"trunk_tags": interfaceItem.TrunkTags,
|
||||
"vnfs": interfaceItem.VNFs,
|
||||
"libvirt_settings": flattenLibvirtSettings(interfaceItem.LibvirtSettings),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -122,10 +124,11 @@ func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(snapSets))
|
||||
for _, snapSet := range snapSets {
|
||||
temp := map[string]interface{}{
|
||||
"disks": snapSet.Disks,
|
||||
"guid": snapSet.GUID,
|
||||
"label": snapSet.Label,
|
||||
"timestamp": snapSet.Timestamp,
|
||||
"disks": snapSet.Disks,
|
||||
"guid": snapSet.GUID,
|
||||
"label": snapSet.Label,
|
||||
"timestamp": snapSet.Timestamp,
|
||||
"memory_dump_image": snapSet.MemoryDumpImage,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -193,10 +196,12 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"bootdisk_size": compute.BootDiskSize,
|
||||
"boot_image_id": compute.BootImageID,
|
||||
"chipset": compute.Chipset,
|
||||
"clock": compute.Clock,
|
||||
"cd_image_id": compute.CdImageId,
|
||||
"clone_reference": compute.CloneReference,
|
||||
"clones": compute.Clones,
|
||||
"computeci_id": compute.ComputeCIID,
|
||||
"cpu_alignment_profiles": flattenCPUAlignmentProfile(compute.CPUAlignmentProfile),
|
||||
"cpu_pin": compute.CPUPin,
|
||||
"cpus": compute.CPU,
|
||||
"created_by": compute.CreatedBy,
|
||||
@@ -232,6 +237,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"registered": compute.Registered,
|
||||
"res_name": compute.ResName,
|
||||
"reserved_node_cpus": compute.ReservedNodeCpus,
|
||||
"resized_online": compute.ResizedOnline,
|
||||
"rg_id": compute.RGID,
|
||||
"rg_name": compute.RGName,
|
||||
"snap_sets": flattenSnapSets(compute.SnapSets),
|
||||
@@ -278,7 +284,7 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
"storage_policy_id": bootDisk.StoragePolicyID,
|
||||
"to_clean": bootDisk.ToClean,
|
||||
"cache": bootDisk.Cache,
|
||||
"blk_discard": bootDisk.BLKDiscard,
|
||||
"discard": bootDisk.Discard,
|
||||
"block_size": bootDisk.BlockSize,
|
||||
"bus_number": bootDisk.BusNumber,
|
||||
"provision": bootDisk.Provision,
|
||||
@@ -289,6 +295,7 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
"deleted_time": bootDisk.DeletedTime,
|
||||
"updated_time": bootDisk.UpdatedTime,
|
||||
"devicename": bootDisk.DeviceName,
|
||||
"read_only": bootDisk.ReadOnly,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
@@ -346,10 +353,11 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"permanently": pernamentlyValue,
|
||||
"cache": disk.Cache,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"provision": disk.Provision,
|
||||
"iotune": flattenIotune(disk.IOTune),
|
||||
"read_only": disk.ReadOnly,
|
||||
}
|
||||
res = append(res, temp)
|
||||
indexDataDisks++
|
||||
@@ -363,15 +371,16 @@ func flattenNetwork(networks []interface{}, interfaces compute.ListInterfaces) [
|
||||
|
||||
for _, network := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": network.NetID,
|
||||
"net_type": network.NetType,
|
||||
"ip_address": network.IPAddress,
|
||||
"mac": network.MAC,
|
||||
"mtu": network.MTU,
|
||||
"net_mask": network.NetMask,
|
||||
"sdn_interface_id": network.SDNInterfaceID,
|
||||
"weight": flattenNetworkWeight(networks, network.NetID, network.NetType),
|
||||
"enabled": network.Enabled,
|
||||
"net_id": network.NetID,
|
||||
"net_type": network.NetType,
|
||||
"ip_address": network.IPAddress,
|
||||
"mac": network.MAC,
|
||||
"mtu": network.MTU,
|
||||
"net_mask": network.NetMask,
|
||||
"sdn_interface_id": network.SDNInterfaceID,
|
||||
"weight": flattenNetworkWeight(networks, network.NetID, network.NetType),
|
||||
"enabled": network.Enabled,
|
||||
"enable_default_gateway": network.EnableDefaultGateway,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -440,6 +449,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("sep_id", bootDisk.SepID)
|
||||
d.Set("pool", bootDisk.Pool)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("clock", computeRec.Clock)
|
||||
d.Set("clone_reference", computeRec.CloneReference)
|
||||
d.Set("clones", computeRec.Clones)
|
||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||
@@ -484,6 +494,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("registered", computeRec.Registered)
|
||||
d.Set("res_name", computeRec.ResName)
|
||||
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
|
||||
d.Set("resized_online", computeRec.ResizedOnline)
|
||||
d.Set("rg_id", computeRec.RGID)
|
||||
d.Set("rg_name", computeRec.RGName)
|
||||
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
|
||||
@@ -505,6 +516,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
d.Set("cpu_pin", computeRec.CPUPin)
|
||||
d.Set("cpu_alignment_profile", computeRec.CPUAlignmentProfile.Name)
|
||||
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||
d.Set("hp_backed", computeRec.HPBacked)
|
||||
d.Set("weight", computeRec.Weight)
|
||||
@@ -565,6 +577,20 @@ func flattenAffinityRules(affinityRules compute.ListRules) []map[string]interfac
|
||||
return res
|
||||
}
|
||||
|
||||
/*func flattenDisksACL(acl compute.ItemDisksACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"user_group_id": acl.UserGroupID,
|
||||
"type": acl.Type,
|
||||
"right": acl.Right,
|
||||
"status": acl.Status,
|
||||
"explicit": acl.Explicit,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}*/
|
||||
|
||||
func flattenIotune(iotune compute.IOTune) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
@@ -593,6 +619,7 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
"label": snapshot.Label,
|
||||
"pool_name": snapshot.PoolName,
|
||||
"res_id": snapshot.ResID,
|
||||
"reference_id": snapshot.ReferenceID,
|
||||
"snap_set_guid": snapshot.SnapSetGUID,
|
||||
@@ -607,13 +634,14 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
|
||||
|
||||
func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(disks))
|
||||
log.Debug("flattenListComputeDisks:", disks)
|
||||
for _, disk := range disks {
|
||||
acl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
"_ckey": disk.CKey,
|
||||
"acl": string(acl),
|
||||
//"_ckey": disk.CKey,
|
||||
// TODO
|
||||
//"acl": flattenDisksACL(disk.ACL),
|
||||
"account_id": disk.AccountID,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"discard": disk.Discard,
|
||||
"block_size": disk.BlockSize,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
@@ -660,6 +688,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"to_clean": disk.ToClean,
|
||||
"provision": disk.Provision,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"read_only": disk.ReadOnly,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -713,6 +742,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("auto_start_w_node", computeRec.AutoStart)
|
||||
d.Set("arch", computeRec.Architecture)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("clock", computeRec.Clock)
|
||||
d.Set("boot_order", computeRec.BootOrder)
|
||||
d.Set("bootdisk_size", computeRec.BootDiskSize)
|
||||
d.Set("boot_image_id", computeRec.BootImageID)
|
||||
@@ -729,7 +759,10 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("deleted_time", computeRec.DeletedTime)
|
||||
d.Set("desc", computeRec.Description)
|
||||
d.Set("devices", string(devices))
|
||||
d.Set("disks", flattenListComputeDisks(computeRec.Disks))
|
||||
err := d.Set("disks", flattenListComputeDisks(computeRec.Disks))
|
||||
if err != nil {
|
||||
log.Debugf("error in flattenDataCompute: %v", err)
|
||||
}
|
||||
d.Set("driver", computeRec.Driver)
|
||||
d.Set("gid", computeRec.GID)
|
||||
d.Set("guid", computeRec.GUID)
|
||||
@@ -762,6 +795,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("registered", computeRec.Registered)
|
||||
d.Set("res_name", computeRec.ResName)
|
||||
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
|
||||
d.Set("resized_online", computeRec.ResizedOnline)
|
||||
d.Set("rg_id", computeRec.RGID)
|
||||
d.Set("rg_name", computeRec.RGName)
|
||||
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
|
||||
@@ -785,9 +819,23 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
d.Set("os_version", computeRec.OSVersion)
|
||||
d.Set("cpu_alignment_profiles", flattenCPUAlignmentProfile(computeRec.CPUAlignmentProfile))
|
||||
d.Set("weight", computeRec.Weight)
|
||||
}
|
||||
|
||||
func flattenCPUAlignmentProfile(profile compute.CPUAlignmentProfile) []map[string]interface{} {
|
||||
if profile.Name == "" && profile.Model == "" && profile.Vendor == "" {
|
||||
return nil
|
||||
}
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
"name": profile.Name,
|
||||
"model": profile.Model,
|
||||
"vendor": profile.Vendor,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
|
||||
res := make([]uint64, 0, len(pciList.Data))
|
||||
|
||||
|
||||
@@ -185,6 +185,13 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Description: "network enable flag",
|
||||
},
|
||||
|
||||
"enable_default_gateway": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "Flag indicating whether default gateway is enabled for this interface. Applicable only to VINS network type",
|
||||
},
|
||||
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
@@ -1427,3 +1427,19 @@ func resourceComputeResourceV2() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceComputeResourceV3() *schema.Resource {
|
||||
s := ResourceComputeSchemaMake()
|
||||
|
||||
for _, blockKey := range []string{"disks", "boot_disk"} {
|
||||
if block, ok := s[blockKey]; ok {
|
||||
if res, ok := block.Elem.(*schema.Resource); ok {
|
||||
res.Schema["blk_discard"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &schema.Resource{Schema: s}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.BootDisk = uint64(bootSize.(int))
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
ns := networks.(*schema.Set).List()
|
||||
@@ -164,6 +162,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
reqInterface.Enabled = netInterfaceVal["enabled"].(bool)
|
||||
}
|
||||
|
||||
if reqInterface.NetType == "VINS" {
|
||||
reqInterface.EnableDefaultGateway = netInterfaceVal["enable_default_gateway"].(bool)
|
||||
}
|
||||
|
||||
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" {
|
||||
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
|
||||
}
|
||||
@@ -264,6 +266,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.CPUPin = d.Get("cpu_pin").(bool)
|
||||
createReqX86.HPBacked = d.Get("hp_backed").(bool)
|
||||
createReqX86.Chipset = d.Get("chipset").(string)
|
||||
if clock, ok := d.GetOk("clock"); ok {
|
||||
createReqX86.Clock = clock.(string)
|
||||
}
|
||||
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
@@ -513,6 +518,17 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if profileName, ok := d.GetOk("cpu_alignment_profile"); ok {
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName.(string),
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if ars, ok := d.GetOk("affinity_rules"); ok {
|
||||
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", computeId)
|
||||
addedAR := ars.([]interface{})
|
||||
@@ -968,9 +984,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
|
||||
// Note bene: numa_affinity, cpu_pin, hp_backed and clock are not allowed to be changed for compute in STARTED tech status.
|
||||
var isStopRequired bool
|
||||
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) {
|
||||
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize", "clock") && d.Get("started").(bool) {
|
||||
isStopRequired = true
|
||||
}
|
||||
|
||||
@@ -1042,6 +1058,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
if d.HasChanges("description",
|
||||
"name",
|
||||
"clock",
|
||||
"numa_affinity",
|
||||
"cpu_pin",
|
||||
"hp_backed",
|
||||
@@ -1069,6 +1086,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if d.HasChange("chipset") {
|
||||
req.Chipset = d.Get("chipset").(string)
|
||||
}
|
||||
if d.HasChange("clock") {
|
||||
req.Clock = d.Get("clock").(string)
|
||||
}
|
||||
if d.HasChange("preferred_cpu") {
|
||||
if preferredCPU, ok := d.GetOk("preferred_cpu"); ok {
|
||||
preferredList := preferredCPU.([]interface{})
|
||||
@@ -1242,6 +1262,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if diskConv["image_id"].(int) != 0 {
|
||||
req.ImageID = uint64(diskConv["image_id"].(int))
|
||||
}
|
||||
req.ReadOnly = diskConv["read_only"].(bool)
|
||||
diskID, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -1911,6 +1932,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cpu_alignment_profile") {
|
||||
if err := utilityComputeUpdateCPUAlignmentProfile(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||
// between Compute resource and Compute data source schemas
|
||||
|
||||
@@ -2095,6 +2122,12 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Disk deletion status",
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Mount disk in read-only mode",
|
||||
},
|
||||
"iotune": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -2230,8 +2263,8 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
"discard": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
@@ -2382,6 +2415,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false), // observe case while validating
|
||||
Description: "Type of the emulated system.",
|
||||
},
|
||||
"clock": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "default",
|
||||
ValidateFunc: validation.StringInSlice([]string{"default", "linux", "windows", "none"}, false),
|
||||
Description: "Clock synchronization mode.",
|
||||
},
|
||||
"without_boot_disk": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -2405,6 +2445,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Set affinity label for compute",
|
||||
},
|
||||
"cpu_alignment_profile": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "CPU alignment profile name",
|
||||
},
|
||||
"affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -2931,6 +2976,10 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"resized_online": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -3095,7 +3144,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceCompute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 3,
|
||||
SchemaVersion: 4,
|
||||
|
||||
CreateContext: resourceComputeCreate,
|
||||
ReadContext: resourceComputeRead,
|
||||
@@ -3142,6 +3191,11 @@ func ResourceCompute() *schema.Resource {
|
||||
Upgrade: resourceComputeStateUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
{
|
||||
Type: resourceComputeResourceV3().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceComputeStateUpgradeV3,
|
||||
Version: 3,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,31 @@ func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]int
|
||||
|
||||
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
|
||||
|
||||
|
||||
delete(rawState, "with_default_vins")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceComputeStateUpgradeV3(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV3: upgrading state")
|
||||
|
||||
for _, blockKey := range []string{"disks", "boot_disk"} {
|
||||
if items, ok := rawState[blockKey].([]interface{}); ok {
|
||||
for _, item := range items {
|
||||
if disk, ok := item.(map[string]interface{}); ok {
|
||||
if v, ok := disk["blk_discard"].(bool); ok {
|
||||
if v {
|
||||
disk["discard"] = "unmap"
|
||||
} else {
|
||||
disk["discard"] = "ignore"
|
||||
}
|
||||
}
|
||||
delete(disk, "blk_discard")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -278,6 +278,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
req.Enabled = netData["enabled"].(bool)
|
||||
}
|
||||
|
||||
if req.NetType == "VINS" {
|
||||
req.EnableDefaultGateway = netData["enable_default_gateway"].(bool)
|
||||
}
|
||||
|
||||
if req.NetType == "DPDK" || req.NetType == "EXTNET" {
|
||||
req.MTU = uint64(netData["mtu"].(int))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityComputeUpdateCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
profileName := d.Get("cpu_alignment_profile").(string)
|
||||
if profileName == "" {
|
||||
req := compute.DeleteCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []uint64{computeId},
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().DeleteCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
req := compute.SetCPUAlignmentProfileRequest{
|
||||
ComputeIDs: []int64{int64(computeId)},
|
||||
CPUAlignmentProfile: profileName,
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().SetCPUAlignmentProfile(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeGetCPUAlignmentProfile(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.CPUAlignmentProfile, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.GetCPUAlignmentProfileRequest{
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
return c.CloudAPI().Compute().GetCPUAlignmentProfile(ctx, req)
|
||||
}
|
||||
@@ -420,7 +420,7 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"sdn_access_group_id": {
|
||||
|
||||
@@ -97,6 +97,8 @@ func DataSourceRgAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceRgAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -251,7 +251,7 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"uniq_pools": {
|
||||
|
||||
@@ -240,7 +240,7 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"uniq_pools": {
|
||||
|
||||
@@ -147,6 +147,10 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
req.IPCIDR = ipcidr.(string)
|
||||
}
|
||||
|
||||
if enableDefaultGateway, ok := d.GetOkExists("enable_default_gateway"); ok {
|
||||
req.EnableDefaultGateway = enableDefaultGateway.(bool)
|
||||
}
|
||||
|
||||
if description, ok := d.GetOk("description"); ok {
|
||||
req.Description = description.(string)
|
||||
}
|
||||
@@ -597,7 +601,10 @@ func ResourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
|
||||
},
|
||||
|
||||
"enable_default_gateway": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"def_net_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -892,7 +899,7 @@ func ResourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"storage_policy_ids": {
|
||||
|
||||
@@ -939,6 +939,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"enable_default_gateway": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"default_qos": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -97,6 +97,8 @@ func DataSourceVinsAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceVinsAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
@@ -395,6 +395,7 @@ func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("enable_default_gateway", vins.EnableDefaultGateway)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
@@ -433,6 +434,7 @@ func flattenVinsData(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("enable_default_gateway", vins.EnableDefaultGateway)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
|
||||
@@ -145,6 +145,7 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
|
||||
req.EnableDefaultGateway = d.Get("enable_default_gateway").(bool)
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
|
||||
if err != nil {
|
||||
@@ -184,6 +185,7 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
|
||||
req.EnableDefaultGateway = d.Get("enable_default_gateway").(bool)
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
|
||||
if err != nil {
|
||||
@@ -918,6 +920,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "enable security groups",
|
||||
}
|
||||
rets["enable_default_gateway"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "Flag indicating whether default gateway is enabled for this VINS",
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -194,6 +194,34 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"reserved_cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reserved_ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,34 @@ func dataSourceZoneListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_alignment_profiles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"model": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"reserved_cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reserved_ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -38,6 +38,18 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
|
||||
)
|
||||
|
||||
func flattenCpuAlignmentProfiles(profiles []zone.CpuAlignmentProfile) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(profiles))
|
||||
for _, p := range profiles {
|
||||
res = append(res, map[string]interface{}{
|
||||
"name": p.Name,
|
||||
"vendor": p.Vendor,
|
||||
"model": p.Model,
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
|
||||
log.Debugf("flattenZone: start decoding RecordZone name %q / ID %d",
|
||||
item.Name, item.ID)
|
||||
@@ -71,6 +83,9 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
|
||||
d.Set("ssl_skip_verify", item.SSLSkipVerify)
|
||||
d.Set("domain", item.Domain)
|
||||
d.Set("sso_type", item.SSOType)
|
||||
d.Set("cpu_alignment_profiles", flattenCpuAlignmentProfiles(item.CpuAlignmentProfiles))
|
||||
d.Set("reserved_cpu", item.ReservedCPU)
|
||||
d.Set("reserved_ram", item.ReservedRAM)
|
||||
|
||||
log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete",
|
||||
item.Name, item.ID)
|
||||
@@ -82,28 +97,31 @@ func flattenZoneList(zone *zone.ListZones) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(zone.Data))
|
||||
for _, zone := range zone.Data {
|
||||
temp := map[string]interface{}{
|
||||
"zone_id": int(zone.ID),
|
||||
"guid": int(zone.GUID),
|
||||
"gid": int(zone.GID),
|
||||
"name": zone.Name,
|
||||
"description": zone.Description,
|
||||
"deletable": zone.Deletable,
|
||||
"status": zone.Status,
|
||||
"created_time": zone.CreatedTime,
|
||||
"updated_time": zone.UpdatedTime,
|
||||
"node_ids": zone.NodeIDs,
|
||||
"auto_start": zone.AutoStart,
|
||||
"drs": zone.DRS,
|
||||
"drs_uid": zone.DRSUID,
|
||||
"drs_name": zone.DRSName,
|
||||
"sso_url": zone.SSOURL,
|
||||
"app_id": zone.AppID,
|
||||
"decort_url": zone.DecortURL,
|
||||
"ping_addr": zone.PingAddr,
|
||||
"broadcast_addr": zone.BroadcastAddr,
|
||||
"ssl_skip_verify": zone.SSLSkipVerify,
|
||||
"domain": zone.Domain,
|
||||
"sso_type": zone.SSOType,
|
||||
"zone_id": int(zone.ID),
|
||||
"guid": int(zone.GUID),
|
||||
"gid": int(zone.GID),
|
||||
"name": zone.Name,
|
||||
"description": zone.Description,
|
||||
"deletable": zone.Deletable,
|
||||
"status": zone.Status,
|
||||
"created_time": zone.CreatedTime,
|
||||
"updated_time": zone.UpdatedTime,
|
||||
"node_ids": zone.NodeIDs,
|
||||
"auto_start": zone.AutoStart,
|
||||
"drs": zone.DRS,
|
||||
"drs_uid": zone.DRSUID,
|
||||
"drs_name": zone.DRSName,
|
||||
"sso_url": zone.SSOURL,
|
||||
"app_id": zone.AppID,
|
||||
"decort_url": zone.DecortURL,
|
||||
"ping_addr": zone.PingAddr,
|
||||
"broadcast_addr": zone.BroadcastAddr,
|
||||
"ssl_skip_verify": zone.SSLSkipVerify,
|
||||
"domain": zone.Domain,
|
||||
"sso_type": zone.SSOType,
|
||||
"cpu_alignment_profiles": flattenCpuAlignmentProfiles(zone.CpuAlignmentProfiles),
|
||||
"reserved_cpu": int(zone.ReservedCPU),
|
||||
"reserved_ram": int(zone.ReservedRAM),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user