This commit is contained in:
2024-05-31 14:05:21 +03:00
parent 84b7a80e1b
commit db1760cb72
815 changed files with 58194 additions and 11049 deletions

View File

@@ -360,6 +360,39 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"replication": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
Description: "Replication status",
},
"reality_device_number": {
Type: schema.TypeInt,
Computed: true,
@@ -489,6 +522,10 @@ func computeInterfacesSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"node_id": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
@@ -615,7 +652,11 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
},
},
"boot_disk_size": {
"bootdisk_size": {
Type: schema.TypeInt,
Computed: true,
},
"cd_image_id": {
Type: schema.TypeInt,
Computed: true,
},
@@ -634,6 +675,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"cpu_pin": {
Type: schema.TypeBool,
Computed: true,
},
"cpus": {
Type: schema.TypeInt,
Computed: true,
@@ -685,6 +730,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"hp_backed": {
Type: schema.TypeBool,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
@@ -720,10 +769,18 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"need_reboot" : {
"need_reboot": {
Type: schema.TypeBool,
Computed: true,
},
"numa_affinity": {
Type: schema.TypeString,
Computed: true,
},
"numa_node_id": {
Type: schema.TypeInt,
Computed: true,
},
"natable_vins_id": {
Type: schema.TypeInt,
Computed: true,
@@ -771,6 +828,13 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"reserved_node_cpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -124,7 +124,11 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
},
},
"boot_disk_size": {
"bootdisk_size": {
Type: schema.TypeInt,
Computed: true,
},
"cd_image_id": {
Type: schema.TypeInt,
Computed: true,
},
@@ -143,6 +147,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"cpu_pin": {
Type: schema.TypeBool,
Computed: true,
},
"cpus": {
Type: schema.TypeInt,
Computed: true,
@@ -194,6 +202,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"hp_backed": {
Type: schema.TypeBool,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
@@ -237,6 +249,14 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"numa_affinity": {
Type: schema.TypeString,
Computed: true,
},
"numa_node_id": {
Type: schema.TypeInt,
Computed: true,
},
"pinned": {
Type: schema.TypeBool,
Computed: true,
@@ -257,6 +277,13 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"reserved_node_cpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
@@ -394,6 +421,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Optional: true,
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -109,6 +109,11 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Find by Extnet ID",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -80,6 +80,11 @@ func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Find by status",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
@@ -93,8 +98,49 @@ func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"hwpath": {
Type: schema.TypeString,
Computed: true,
},
"device_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"stack_id": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"system_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {

View File

@@ -80,6 +80,11 @@ func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
@@ -93,8 +98,81 @@ func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"vgpu_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vm_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {

View File

@@ -33,7 +33,6 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
package kvmvm
import (
"context"
"encoding/json"
"sort"
"strconv"
@@ -83,6 +82,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
"net_id": interfaceItem.NetID,
"netmask": interfaceItem.NetMask,
"net_type": interfaceItem.NetType,
"node_id": interfaceItem.NodeID,
"pci_slot": interfaceItem.PCISlot,
"qos": flattenQOS(interfaceItem.QOS),
"target": interfaceItem.Target,
@@ -164,10 +164,12 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"anti_affinity_rules": flattenListRules(compute.AntiAffinityRules),
"arch": compute.Architecture,
"boot_order": compute.BootOrder,
"boot_disk_size": compute.BootDiskSize,
"bootdisk_size": compute.BootDiskSize,
"cd_image_id": compute.CdImageId,
"clone_reference": compute.CloneReference,
"clones": compute.Clones,
"computeci_id": compute.ComputeCIID,
"cpu_pin": compute.CPUPin,
"cpus": compute.CPU,
"created_by": compute.CreatedBy,
"created_time": compute.CreatedTime,
@@ -180,6 +182,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"driver": compute.Driver,
"gid": compute.GID,
"guid": compute.GUID,
"hp_backed": compute.HPBacked,
"compute_id": compute.ID,
"image_id": compute.ImageID,
"interfaces": flattenInterfaces(compute.Interfaces),
@@ -190,11 +193,14 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"milestones": compute.Milestones,
"name": compute.Name,
"need_reboot": compute.NeedReboot,
"numa_affinity": compute.NumaAffinity,
"numa_node_id": compute.NumaNodeId,
"pinned": compute.Pinned,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"reserved_node_cpus": compute.ReservedNodeCpus,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
@@ -239,17 +245,25 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
return res
}
func flattenComputeDisksDemo(ctx context.Context, d *schema.ResourceData, disksList compute.ListComputeDisks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(disksList))
if len(disksBlocks) == 0 {
return res
}
sort.Slice(disksList, func(i, j int) bool {
return disksList[i].ID < disksList[j].ID
})
indexDataDisks := 0
for _, disk := range disksList {
if disk.ID == bootDiskId || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
continue
}
permanently, ok := ctx.Value(DiskKey(strconv.Itoa(int(disk.ID)))).(bool) // get permamently from Create or Update context
if !ok {
permanently = getPermanentlyByDiskID(d, disk.ID) // get permanently from state when Read is not after Create/Update
}
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
temp := map[string]interface{}{
"disk_name": disk.Name,
@@ -263,32 +277,15 @@ func flattenComputeDisksDemo(ctx context.Context, d *schema.ResourceData, disksL
"desc": disk.Description,
"image_id": disk.ImageID,
"size": disk.SizeMax,
"permanently": permanently,
"permanently": pernamentlyValue,
}
res = append(res, temp)
indexDataDisks++
}
sort.Slice(res, func(i, j int) bool {
return res[i]["disk_id"].(uint64) < res[j]["disk_id"].(uint64)
})
return res
}
// getPermanentlyByDiskID gets permanently value of specific disk (by diskId) from disks current state
func getPermanentlyByDiskID(d *schema.ResourceData, diskId uint64) bool {
disks := d.Get("disks").([]interface{})
for _, diskItem := range disks {
disk := diskItem.(map[string]interface{})
if uint64(disk["disk_id"].(int)) == diskId {
return disk["permanently"].(bool)
}
}
log.Infof("getPermanentlyByDiskID: disk with id %d not found in state", diskId)
return false
}
func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(interfaces))
@@ -310,10 +307,10 @@ func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
return &disk
}
}
return nil
return &compute.ItemComputeDisk{}
}
func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec compute.RecordCompute) error {
func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) error {
// This function expects that compFacts string contains response from API compute/get,
// i.e. detailed information about compute instance.
//
@@ -336,6 +333,7 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
d.Set("boot_disk_size", bootDisk.SizeMax)
d.Set("boot_disk", flattenBootDisk(bootDisk))
d.Set("boot_disk_id", bootDisk.ID)
d.Set("cd_image_id", computeRec.CdImageId)
d.Set("sep_id", bootDisk.SepID)
d.Set("pool", bootDisk.Pool)
d.Set("clone_reference", computeRec.CloneReference)
@@ -348,7 +346,7 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
d.Set("deleted_time", computeRec.DeletedTime)
d.Set("description", computeRec.Description)
d.Set("devices", string(devices))
err := d.Set("disks", flattenComputeDisksDemo(ctx, d, computeRec.Disks, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID))
err := d.Set("disks", flattenComputeDisksDemo(computeRec.Disks, d.Get("disks").([]interface{}), d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID))
if err != nil {
return err
}
@@ -370,6 +368,7 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
d.Set("milestones", computeRec.Milestones)
d.Set("name", computeRec.Name)
d.Set("need_reboot", computeRec.NeedReboot)
d.Set("numa_node_id", computeRec.NumaNodeId)
d.Set("natable_vins_id", computeRec.NatableVINSID)
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
d.Set("natable_vins_name", computeRec.NatableVINSName)
@@ -383,6 +382,7 @@ func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec comp
d.Set("reference_id", computeRec.ReferenceID)
d.Set("registered", computeRec.Registered)
d.Set("res_name", computeRec.ResName)
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
d.Set("rg_id", computeRec.RGID)
d.Set("rg_name", computeRec.RGName)
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
@@ -513,6 +513,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"pool": disk.Pool,
"present_to": disk.PresentTo,
"purge_time": disk.PurgeTime,
"replication": flattenDiskReplication(disk.Replication),
"reality_device_number": disk.RealityDeviceNumber,
"res_id": disk.ResID,
"role": disk.Role,
@@ -532,6 +533,20 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
return res
}
func flattenDiskReplication(rep compute.ItemReplication) []map[string]interface{} {
res := []map[string]interface{}{
{
"disk_id": rep.DiskID,
"pool_id": rep.PoolID,
"role": rep.Role,
"self_volume_id": rep.SelfVolumeID,
"storage_id": rep.StorageID,
"volume_id": rep.VolumeID,
},
}
return res
}
func flattenCustomFields(customFields map[string]interface{}) string {
encoded, _ := json.Marshal(customFields)
return string(encoded)
@@ -563,10 +578,12 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("anti_affinity_rules", flattenListRules(computeRec.AntiAffinityRules))
d.Set("arch", computeRec.Architecture)
d.Set("boot_order", computeRec.BootOrder)
d.Set("boot_disk_size", computeRec.BootDiskSize)
d.Set("bootdisk_size", computeRec.BootDiskSize)
d.Set("cd_image_id", computeRec.CdImageId)
d.Set("clone_reference", computeRec.CloneReference)
d.Set("clones", computeRec.Clones)
d.Set("computeci_id", computeRec.ComputeCIID)
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("cpus", computeRec.CPU)
d.Set("created_by", computeRec.CreatedBy)
d.Set("created_time", computeRec.CreatedTime)
@@ -579,6 +596,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("driver", computeRec.Driver)
d.Set("gid", computeRec.GID)
d.Set("guid", computeRec.GUID)
d.Set("hp_backed", computeRec.HPBacked)
d.Set("compute_id", computeRec.ID)
d.Set("image_id", computeRec.ImageID)
d.Set("image_name", computeRec.ImageName)
@@ -590,6 +608,8 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("milestones", computeRec.Milestones)
d.Set("name", computeRec.Name)
d.Set("need_reboot", computeRec.NeedReboot)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("numa_node_id", computeRec.NumaNodeId)
d.Set("natable_vins_id", computeRec.NatableVINSID)
d.Set("natable_vins_ip", computeRec.NatableVINSIP)
d.Set("natable_vins_name", computeRec.NatableVINSName)
@@ -601,6 +621,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("reference_id", computeRec.ReferenceID)
d.Set("registered", computeRec.Registered)
d.Set("res_name", computeRec.ResName)
d.Set("reserved_node_cpus", computeRec.ReservedNodeCpus)
d.Set("rg_id", computeRec.RGID)
d.Set("rg_name", computeRec.RGName)
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
@@ -696,40 +717,50 @@ func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []ma
// return res
// }
func flattenVGPU(m []interface{}) []string {
output := []string{}
for _, item := range m {
switch d := item.(type) {
case string:
output = append(output, d)
case int:
output = append(output, strconv.Itoa(d))
case int64:
output = append(output, strconv.FormatInt(d, 10))
case float64:
output = append(output, strconv.FormatInt(int64(d), 10))
default:
output = append(output, "")
func flattenVGPU(vgpuList []compute.ItemVGPU) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(vgpuList))
for _, dev := range vgpuList {
temp := map[string]interface{}{
"account_id": dev.AccountID,
"created_time": dev.CreatedTime,
"deleted_time": dev.DeletedTime,
"gid": dev.GID,
"guid": dev.GUID,
"vgpu_id": dev.ID,
"last_claimed_by": dev.LastClaimedBy,
"last_update_time": dev.LastUpdateTime,
"mode": dev.Mode,
"pci_slot": dev.PCISlot,
"pgpuid": dev.PGPUID,
"profile_id": dev.ProfileID,
"ram": dev.RAM,
"reference_id": dev.ReferenceID,
"rg_id": dev.RGID,
"status": dev.Status,
"type": dev.Type,
"vm_id": dev.VMID,
}
res = append(res, temp)
}
return output
return res
}
func flattenPCIDevice(m []interface{}) []string {
output := []string{}
for _, item := range m {
switch d := item.(type) {
case string:
output = append(output, d)
case int:
output = append(output, strconv.Itoa(d))
case int64:
output = append(output, strconv.FormatInt(d, 10))
case float64:
output = append(output, strconv.FormatInt(int64(d), 10))
default:
output = append(output, "")
func flattenPCIDevice(deviceList []compute.ItemPCIDevice) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(deviceList))
for _, dev := range deviceList {
temp := map[string]interface{}{
"compute_id": dev.ComputeID,
"description": dev.Description,
"guid": dev.GUID,
"hwpath": dev.HwPath,
"device_id": dev.ID,
"name": dev.Name,
"rg_id": dev.RGID,
"stack_id": dev.StackID,
"status": dev.Status,
"system_name": dev.SystemName,
}
res = append(res, temp)
}
return output
return res
}

View File

@@ -128,7 +128,7 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Required: true,
StateFunc: statefuncs.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS", "VFNIC"}, false), // observe case while validating
Description: "Type of the network for this connection, either EXTNET or VINS.",
},

View File

@@ -33,13 +33,13 @@ func resourceComputeResourceV1() *schema.Resource {
"cpu": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
ValidateFunc: validation.IntBetween(1, constants.MAX_CPUS_PER_COMPUTE),
Description: "Number of CPUs to allocate to this compute instance.",
},
"ram": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
ValidateFunc: validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"image_id": {
@@ -191,7 +191,7 @@ func resourceComputeResourceV1() *schema.Resource {
"extra_disks": {
Type: schema.TypeSet,
Optional: true,
MaxItems: constants.MaxExtraDisksPerCompute,
MaxItems: constants.MAX_EXTRA_DISKS_PER_COMPUTE,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
@@ -202,7 +202,7 @@ func resourceComputeResourceV1() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MaxNetworksPerCompute,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(),
},
@@ -575,13 +575,13 @@ func resourceComputeResourceV2() *schema.Resource {
"cpu": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
ValidateFunc: validation.IntBetween(1, constants.MAX_CPUS_PER_COMPUTE),
Description: "Number of CPUs to allocate to this compute instance.",
},
"ram": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
ValidateFunc: validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"image_id": {
@@ -853,7 +853,7 @@ func resourceComputeResourceV2() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Computed: true,
MaxItems: constants.MaxExtraDisksPerCompute,
MaxItems: constants.MAX_EXTRA_DISKS_PER_COMPUTE,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
@@ -864,7 +864,7 @@ func resourceComputeResourceV2() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MaxNetworksPerCompute,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"net_type": {

View File

@@ -41,6 +41,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vfpool"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
@@ -128,3 +129,36 @@ func existExtNetId(ctx context.Context, m interface{}, id int) (int, bool) {
return 0, true
}
func existVFPoolId(ctx context.Context, m interface{}, id int) (int, bool) {
c := m.(*controller.ControllerCfg)
req := vfpool.ListRequest{ByID: uint64(id)}
vfpoolList, err := c.CloudAPI().VFPool().List(ctx, req)
if err != nil {
log.Debugf("Unable to retrieve vfpool list, %s", err)
return id, false
}
if len(vfpoolList.Data) == 1 {
return 0, true
}
return id, false
}
func isMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) bool {
count := 0
for _, elem := range disks.([]interface{}) {
diskVal := elem.(map[string]interface{})
if diskVal["disk_type"].(string) == "B" {
count++
}
if count > 1 {
return true
}
}
return false
}

View File

@@ -55,9 +55,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
// DiskKey is custom string type to set up context Key for Disk ID
type DiskKey string
func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceComputeCreate: called for Compute name %q, RG ID %d", d.Get("name").(string), d.Get("rg_id").(int))
c := m.(*controller.ControllerCfg)
@@ -82,6 +79,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
}
if disks, ok := d.GetOk("disks"); ok {
if isMoreThanOneDisksTypeB(ctx, disks) {
return diag.Errorf("resourceComputeCreate: can't create Compute because block disks have more 1 disk type 'B'")
}
}
if network, ok := d.GetOk("network"); ok {
networkList := network.(*schema.Set).List()
for _, elem := range networkList {
@@ -96,7 +99,13 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
}
case "VFNIC":
if d.Get("driver").(string) == "KVM_PPC" {
return diag.Errorf("resourceComputeCreate: can't create compute because 'VFNIC' net_type is not allowed for driver 'KVM_PPC'")
}
if vfpoolId, ok := existVFPoolId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because vfpool ID %d is not allowed or does not exist", vfpoolId)
}
default:
continue
}
@@ -186,6 +195,57 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if disks, ok := d.GetOk("disks"); ok {
disksX86 := make([]kvmx86.DataDisk, 0)
disksPPC := make([]kvmppc.DataDisk, 0)
for _, elem := range disks.([]interface{}) {
diskVal := elem.(map[string]interface{})
reqDataDisk := kvmx86.DataDisk{
DiskName: diskVal["disk_name"].(string),
Size: uint64(diskVal["size"].(int)),
}
if sepId, ok := diskVal["sep_id"]; ok {
reqDataDisk.SepID = uint64(sepId.(int))
}
if pool, ok := diskVal["pool"]; ok {
reqDataDisk.Pool = pool.(string)
}
if desc, ok := diskVal["desc"]; ok {
reqDataDisk.Description = desc.(string)
}
if imageID, ok := diskVal["image_id"]; ok {
reqDataDisk.ImageID = uint64(imageID.(int))
}
disksX86 = append(disksX86, reqDataDisk)
}
createReqX86.DataDisks = disksX86
for _, elem := range disks.([]interface{}) {
diskVal := elem.(map[string]interface{})
reqDataDisk := kvmppc.DataDisk{
DiskName: diskVal["disk_name"].(string),
Size: uint64(diskVal["size"].(int)),
}
if sepId, ok := diskVal["sep_id"]; ok {
reqDataDisk.SepID = uint64(sepId.(int))
}
if pool, ok := diskVal["pool"]; ok {
reqDataDisk.Pool = pool.(string)
}
if desc, ok := diskVal["desc"]; ok {
reqDataDisk.Description = desc.(string)
}
if imageID, ok := diskVal["image_id"]; ok {
reqDataDisk.ImageID = uint64(imageID.(int))
}
disksPPC = append(disksPPC, reqDataDisk)
}
createReqPPC.DataDisks = disksPPC
}
argVal, ok = d.GetOk("cloud_init")
if ok {
userdata := argVal.(string)
@@ -217,10 +277,16 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.Name = d.Get("name").(string)
createReqX86.CPU = uint64(d.Get("cpu").(int))
createReqX86.RAM = uint64(d.Get("ram").(int))
createReqX86.ImageID = uint64(d.Get("image_id").(int))
createReqX86.Driver = driver
if image, ok := d.GetOk("image_id"); ok {
createReqX86.ImageID = uint64(image.(int))
}
if withoutBootDisk, ok := d.GetOk("without_boot_disk"); ok {
createReqX86.WithoutBootDisk = withoutBootDisk.(bool)
}
if custom_fields, ok := d.GetOk("custom_fields"); ok {
val := custom_fields.(string)
val = strings.ReplaceAll(val, "\\", "")
@@ -231,6 +297,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.CustomFields = val
}
if numaAffinity, ok := d.GetOk("numa_affinity"); ok {
createReqX86.NumaAffinity = numaAffinity.(string)
}
createReqX86.CPUPin = d.Get("cpu_pin").(bool)
createReqX86.HPBacked = d.Get("hp_backed").(bool)
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
if err != nil {
@@ -273,46 +345,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if disks, ok := d.GetOk("disks"); ok {
log.Debugf("resourceComputeCreate: Create disks on ComputeID: %d", computeId)
addedDisks := disks.([]interface{})
if len(addedDisks) > 0 {
for _, disk := range addedDisks {
diskConv := disk.(map[string]interface{})
req := compute.DiskAddRequest{
ComputeID: computeId,
DiskName: diskConv["disk_name"].(string),
Size: uint64(diskConv["size"].(int)),
}
if diskConv["sep_id"].(int) != 0 {
req.SepID = uint64(diskConv["sep_id"].(int))
}
if diskConv["disk_type"].(string) != "" {
req.DiskType = diskConv["disk_type"].(string)
}
if diskConv["pool"].(string) != "" {
req.Pool = diskConv["pool"].(string)
}
if diskConv["desc"].(string) != "" {
req.Description = diskConv["desc"].(string)
}
if diskConv["image_id"].(int) != 0 {
req.ImageID = uint64(diskConv["image_id"].(int))
}
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
if err != nil {
cleanup = true
return diag.FromErr(err)
}
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
}
}
}
if !cleanup {
if enabled, ok := d.GetOk("enabled"); ok {
if enabled.(bool) {
req := compute.EnableRequest{ComputeID: computeId}
@@ -435,9 +469,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.PFWAddRequest{
ComputeID: computeId,
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
LocalBasePort: uint64(pfwItem["local_port"].(int)),
Proto: pfwItem["proto"].(string),
}
if pfwItem["local_port"].(int) != 0 {
req.LocalBasePort = uint64(pfwItem["local_port"].(int))
}
if pfwItem["public_port_end"].(int) != 0 {
req.PublicPortEnd = int64(pfwItem["public_port_end"].(int))
}
@@ -587,7 +624,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
}
}
if err = flattenCompute(ctx, d, computeRec); err != nil {
if err = flattenCompute(d, computeRec); err != nil {
return diag.FromErr(err)
}
@@ -621,6 +658,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeUpdate: can't update Compute bacause imageID %d not allowed or does not exist", d.Get("image_id").(int))
}
if disks, ok := d.GetOk("disks"); ok {
if isMoreThanOneDisksTypeB(ctx, disks) {
return diag.Errorf("resourceComputeUpdate: can't update Compute because block disks have more 1 disk type 'B'")
}
}
if network, ok := d.GetOk("network"); ok {
networkList := network.(*schema.Set).List()
for _, elem := range networkList {
@@ -629,13 +672,19 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
switch networkData["net_type"].(string) {
case "VINS":
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
return diag.Errorf("resourceComputeUpdate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
}
case "EXTNET":
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
return diag.Errorf("resourceComputeUpdate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
}
case "VFNIC":
if d.Get("driver").(string) == "KVM_PPC" {
return diag.Errorf("resourceComputeUpdate: can't create compute because 'VFNIC' net_type is not allowed for driver 'KVM_PPC'")
}
if vfpoolId, ok := existVFPoolId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeUpdate: can't create compute because vfpool ID %d is not allowed or does not exist", vfpoolId)
}
default:
continue
}
@@ -839,7 +888,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChanges("description", "name") {
if d.HasChanges("description", "name", "numa_affinity", "cpu_pin", "hp_backed") {
req := compute.UpdateRequest{
ComputeID: computeRec.ID,
}
@@ -850,10 +899,39 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if d.HasChange("description") {
req.Description = d.Get("description").(string)
}
if d.HasChange("numa_affinity") {
req.NumaAffinity = d.Get("numa_affinity").(string)
}
if d.HasChange("cpu_pin") {
req.CPUPin = d.Get("cpu_pin").(bool)
}
if d.HasChange("hp_backed") {
req.HPBacked = d.Get("hp_backed").(bool)
}
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
// If STARTED, we need to stop it before update
var isStopRequired bool
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed") && d.Get("started").(bool) {
isStopRequired = true
}
if isStopRequired {
if _, err := c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeRec.ID}); err != nil {
return diag.FromErr(err)
}
}
// perform update
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
return diag.FromErr(err)
}
// If used to be STARTED, we need to start it after update
if isStopRequired {
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
return diag.FromErr(err)
}
}
}
if d.HasChange("disks") {
@@ -862,14 +940,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0)
// save permanently in disks based on disk_id to context
for _, diskItemInterface := range d.Get("disks").([]interface{}) {
diskItem := diskItemInterface.(map[string]interface{})
diskId := diskItem["disk_id"].(int)
permanently := diskItem["permanently"].(bool)
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(diskId)), permanently)
}
oldDisks, newDisks := d.GetChange("disks")
oldConv := oldDisks.([]interface{})
newConv := newDisks.([]interface{})
@@ -975,12 +1045,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["image_id"].(int) != 0 {
req.ImageID = uint64(diskConv["image_id"].(int))
}
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
}
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
}
}
@@ -1244,10 +1312,11 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.PFWDelRequest{
ComputeID: computeRec.ID,
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
LocalBasePort: uint64(pfwItem["local_port"].(int)),
Proto: pfwItem["proto"].(string),
}
if pfwItem["local_port"].(int) != 0 {
req.LocalBasePort = uint64(pfwItem["local_port"].(int))
}
if pfwItem["public_port_end"].(int) == -1 {
req.PublicPortEnd = req.PublicPortStart
} else {
@@ -1269,10 +1338,11 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
ComputeID: computeRec.ID,
PublicPortStart: uint64(pfwItem["public_port_start"].(int)),
PublicPortEnd: int64(pfwItem["public_port_end"].(int)),
LocalBasePort: uint64(pfwItem["local_port"].(int)),
Proto: pfwItem["proto"].(string),
}
if pfwItem["local_port"].(int) != 0 {
req.LocalBasePort = uint64(pfwItem["local_port"].(int))
}
_, err := c.CloudAPI().Compute().PFWAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -1711,7 +1781,7 @@ func portForwardingSubresourceSchemaMake() map[string]*schema.Schema {
},
"local_port": {
Type: schema.TypeInt,
Required: true,
Optional: true,
},
"proto": {
Type: schema.TypeString,
@@ -1786,24 +1856,30 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
"cpu": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
ValidateFunc: validation.IntBetween(1, constants.MAX_CPUS_PER_COMPUTE),
Description: "Number of CPUs to allocate to this compute instance.",
},
"ram": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
validation.IntAtLeast(constants.MIN_RAM_PER_COMPUTE),
validators.DivisibleBy(constants.RAM_DIVISIBILITY),
),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"image_id": {
Type: schema.TypeInt,
Required: true,
Optional: true,
//ForceNew: true, //REDEPLOY
Description: "ID of the OS image to base this compute instance on.",
},
"without_boot_disk": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
},
"boot_disk_size": {
Type: schema.TypeInt,
Optional: true,
@@ -1926,29 +2002,26 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
// ForceNew: true,
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
},
"extra_disks": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
MaxItems: constants.MaxExtraDisksPerCompute,
MaxItems: constants.MAX_EXTRA_DISKS_PER_COMPUTE,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
Description: "Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.",
},
"network": {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MaxNetworksPerCompute,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(),
},
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
},
"tags": {
Type: schema.TypeSet,
Optional: true,
@@ -1956,7 +2029,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: tagsSubresourceSchemaMake(),
},
},
"port_forwarding": {
Type: schema.TypeSet,
Optional: true,
@@ -1964,7 +2036,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: portForwardingSubresourceSchemaMake(),
},
},
"user_access": {
Type: schema.TypeSet,
Optional: true,
@@ -1972,7 +2043,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: userAccessSubresourceSchemaMake(),
},
},
"snapshot": {
Type: schema.TypeSet,
Optional: true,
@@ -1980,7 +2050,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: snapshotSubresourceSchemaMake(),
},
},
"rollback": {
Type: schema.TypeSet,
MaxItems: 1,
@@ -1989,7 +2058,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: snapshotRollbackSubresourceSchemaMake(),
},
},
"cd": {
Type: schema.TypeSet,
Optional: true,
@@ -1998,50 +2066,42 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: cdSubresourceSchemaMake(),
},
},
"pin_to_stack": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "Optional text description of this compute instance.",
},
"cloud_init": {
Type: schema.TypeString,
Optional: true,
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "If true - enable compute, else - disable",
},
"pause": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"reset": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"restore": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"auto_start": {
Type: schema.TypeBool,
Optional: true,
@@ -2093,6 +2153,26 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "compute purpose",
},
"numa_affinity": {
Type: schema.TypeString,
Optional: true,
Default: "none",
ValidateFunc: validation.StringInSlice([]string{"none", "strict", "loose"}, false), // observe case while validating
Description: "Rule for VM placement with NUMA affinity.",
},
"cpu_pin": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.",
},
"hp_backed": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node.",
},
// The rest are Compute properties, which are "computed" once it is created
"account_id": {
Type: schema.TypeInt,
@@ -2124,6 +2204,10 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "This compute instance boot disk ID.",
},
"cd_image_id": {
Type: schema.TypeInt,
Computed: true,
},
"clone_reference": {
Type: schema.TypeInt,
Computed: true,
@@ -2202,6 +2286,10 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"numa_node_id": {
Type: schema.TypeInt,
Computed: true,
},
"natable_vins_id": {
Type: schema.TypeInt,
Computed: true,
@@ -2246,6 +2334,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"reserved_node_cpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"rg_name": {
Type: schema.TypeString,
Computed: true,

View File

@@ -77,6 +77,9 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
req.IncludeDeleted = includeDeleted.(bool)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}

View File

@@ -71,6 +71,9 @@ func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.R
if extnetId, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnetId.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}

View File

@@ -57,6 +57,9 @@ func utilityComputePCIDeviceListCheckPresence(ctx context.Context, d *schema.Res
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}

View File

@@ -57,6 +57,9 @@ func utilityComputeVGPUListCheckPresence(ctx context.Context, d *schema.Resource
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
req.IncludeDeleted = includeDeleted.(bool)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}