4.7.0
This commit is contained in:
@@ -39,7 +39,6 @@ import (
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||
)
|
||||
|
||||
func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
|
||||
@@ -38,6 +38,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("boot_disk_id", bootDisk.ID)
|
||||
// we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform
|
||||
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||
d.Set("chipset", computeRec.Chipset)
|
||||
d.Set("cd_image_id", computeRec.CdImageId)
|
||||
d.Set("clone_reference", computeRec.CloneReference)
|
||||
d.Set("clones", computeRec.Clones)
|
||||
@@ -156,31 +157,49 @@ func flattenInterfaces(ifaces compute.ListInterfaces) []map[string]interface{} {
|
||||
|
||||
for _, iface := range ifaces {
|
||||
res = append(res, map[string]interface{}{
|
||||
"conn_id": iface.ConnID,
|
||||
"conn_type": iface.ConnType,
|
||||
"def_gw": iface.DefGW,
|
||||
"enabled": iface.Enabled,
|
||||
"flip_group_id": iface.FLIPGroupID,
|
||||
"guid": iface.GUID,
|
||||
"ip_address": iface.IPAddress,
|
||||
"listen_ssh": iface.ListenSSH,
|
||||
"mac": iface.MAC,
|
||||
"name": iface.Name,
|
||||
"net_id": iface.NetID,
|
||||
"netmask": iface.NetMask,
|
||||
"net_type": iface.NetType,
|
||||
"node_id": iface.NodeID,
|
||||
"pci_slot": iface.PCISlot,
|
||||
"qos": flattenQOS(iface.QOS),
|
||||
"target": iface.Target,
|
||||
"type": iface.Type,
|
||||
"vnfs": iface.VNFs,
|
||||
"bus_number": iface.BusNumber,
|
||||
"conn_id": iface.ConnID,
|
||||
"conn_type": iface.ConnType,
|
||||
"def_gw": iface.DefGW,
|
||||
"enabled": iface.Enabled,
|
||||
"flip_group_id": iface.FLIPGroupID,
|
||||
"guid": iface.GUID,
|
||||
"ip_address": iface.IPAddress,
|
||||
"listen_ssh": iface.ListenSSH,
|
||||
"mac": iface.MAC,
|
||||
"mtu": iface.MTU,
|
||||
"name": iface.Name,
|
||||
"net_id": iface.NetID,
|
||||
"netmask": iface.NetMask,
|
||||
"net_type": iface.NetType,
|
||||
"node_id": iface.NodeID,
|
||||
"pci_slot": iface.PCISlot,
|
||||
"qos": flattenQOS(iface.QOS),
|
||||
"target": iface.Target,
|
||||
"type": iface.Type,
|
||||
"vnfs": iface.VNFs,
|
||||
"libvirt_settings": flattenLibvirtSettings(iface.LibvirtSettings),
|
||||
})
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLibvirtSettings(libvirtSettings compute.LibvirtSettings) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"guid": libvirtSettings.GUID,
|
||||
"txmode": libvirtSettings.TXMode,
|
||||
"ioeventfd": libvirtSettings.IOEventFD,
|
||||
"event_idx": libvirtSettings.EventIDx,
|
||||
"queues": libvirtSettings.Queues,
|
||||
"rx_queue_size": libvirtSettings.RXQueueSize,
|
||||
"tx_queue_size": libvirtSettings.TXQueueSize,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenQOS(qos compute.QOS) []map[string]interface{} {
|
||||
return []map[string]interface{}{
|
||||
{
|
||||
@@ -275,6 +294,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"affinity_weight": computeItem.AffinityWeight,
|
||||
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
|
||||
"arch": computeItem.Arch,
|
||||
"chipset": computeItem.Chipset,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
@@ -406,8 +426,9 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, disk := range disks {
|
||||
temp := map[string]interface{}{
|
||||
"disk_id": disk.ID,
|
||||
"pci_slot": disk.PCISlot,
|
||||
"bus_number": disk.BusNumber,
|
||||
"disk_id": disk.ID,
|
||||
"pci_slot": disk.PCISlot,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -593,6 +614,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("anti_affinity_rules", flattenAffinityRules(compFacts.AntiAffinityRules))
|
||||
d.Set("arch", compFacts.Arch)
|
||||
d.Set("boot_order", compFacts.BootOrder)
|
||||
d.Set("chipset", compFacts.Chipset)
|
||||
d.Set("cd_image_id", compFacts.CdImageId)
|
||||
d.Set("clone_reference", compFacts.CloneReference)
|
||||
d.Set("clones", compFacts.Clones)
|
||||
@@ -708,6 +730,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
|
||||
"meta": flattens.FlattenMeta(disk.Meta),
|
||||
"account_id": disk.AccountID,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
"created_time": disk.CreatedTime,
|
||||
"deleted_time": disk.DeletedTime,
|
||||
"desc": disk.Description,
|
||||
|
||||
@@ -2,7 +2,6 @@ package kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
@@ -37,7 +36,7 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
|
||||
|
||||
func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg) []error {
|
||||
var errs []error
|
||||
var vinsIds, extNetIds, vfpoolIds []uint64
|
||||
var vinsIds, extNetIds, vfpoolIds, dpdkIds []uint64
|
||||
|
||||
networksIface, ok := d.GetOk("network")
|
||||
if !ok {
|
||||
@@ -54,10 +53,9 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
|
||||
case "EXTNET":
|
||||
extNetIds = append(extNetIds, uint64(network["net_id"].(int)))
|
||||
case "VFNIC":
|
||||
if d.Get("driver").(string) == "KVM_PPC" {
|
||||
errs = append(errs, errors.New("'VFNIC' net_type is not allowed for driver 'KVM_PPC'"))
|
||||
}
|
||||
vfpoolIds = append(vfpoolIds, uint64(network["net_id"].(int)))
|
||||
case "DPDK":
|
||||
dpdkIds = append(dpdkIds, uint64(network["net_id"].(int)))
|
||||
default:
|
||||
continue
|
||||
}
|
||||
@@ -75,5 +73,9 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
|
||||
errs = append(errs, vfpoolErrs...)
|
||||
}
|
||||
|
||||
if dpdkErrs := ic.ExistDPDKNet(ctx, dpdkIds, c); dpdkErrs != nil {
|
||||
errs = append(errs, dpdkErrs...)
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/kvmppc"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/kvmx86"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
@@ -55,59 +54,48 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
createReqX86 := kvmx86.CreateRequest{}
|
||||
createReqPPC := kvmppc.CreateRequest{}
|
||||
|
||||
if diags := checkParamsExistence(ctx, d, c); diags != nil {
|
||||
return diags
|
||||
}
|
||||
|
||||
if desc, ok := d.GetOk("description"); ok {
|
||||
createReqPPC.Description = desc.(string)
|
||||
createReqX86.Description = desc.(string)
|
||||
}
|
||||
|
||||
if sepID, ok := d.GetOk("sep_id"); ok {
|
||||
createReqPPC.SEPID = uint64(sepID.(int))
|
||||
createReqX86.SEPID = uint64(sepID.(int))
|
||||
}
|
||||
|
||||
if pool, ok := d.GetOk("pool"); ok {
|
||||
createReqPPC.Pool = pool.(string)
|
||||
createReqX86.Pool = pool.(string)
|
||||
}
|
||||
|
||||
if stackID, ok := d.GetOk("stack_id"); ok {
|
||||
createReqPPC.StackID = uint64(stackID.(int))
|
||||
createReqX86.StackID = uint64(stackID.(int))
|
||||
}
|
||||
|
||||
if start, ok := d.GetOk("started"); ok {
|
||||
createReqPPC.Start = start.(bool)
|
||||
createReqX86.Start = start.(bool)
|
||||
}
|
||||
|
||||
if ipaType, ok := d.GetOk("ipa_type"); ok {
|
||||
createReqPPC.IPAType = ipaType.(string)
|
||||
createReqX86.IPAType = ipaType.(string)
|
||||
}
|
||||
|
||||
if bootSize, ok := d.GetOk("boot_disk_size"); ok {
|
||||
createReqPPC.BootDisk = uint64(bootSize.(int))
|
||||
createReqX86.BootDisk = uint64(bootSize.(int))
|
||||
}
|
||||
|
||||
if IS, ok := d.GetOk("is"); ok {
|
||||
createReqPPC.IS = IS.(string)
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
createReqPPC.Interfaces = make([]kvmppc.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
ns := networks.(*schema.Set).List()
|
||||
log.Debugf("BEFORE SORT %v", ns)
|
||||
sort.Slice(ns, func(i, j int) bool {
|
||||
weightI := ns[i].(map[string]interface{})["weight"].(int)
|
||||
weightJ := ns[j].(map[string]interface{})["weight"].(int)
|
||||
@@ -119,9 +107,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
return weightI < weightJ
|
||||
})
|
||||
log.Debugf("AFTER SORT %v", ns)
|
||||
interfacesX86 := make([]kvmx86.Interface, 0)
|
||||
interfacesPPC := make([]kvmppc.Interface, 0)
|
||||
for _, elem := range ns {
|
||||
netInterfaceVal := elem.(map[string]interface{})
|
||||
|
||||
@@ -139,28 +125,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
createReqX86.Interfaces = interfacesX86
|
||||
|
||||
for _, elem := range ns {
|
||||
netInterfaceVal := elem.(map[string]interface{})
|
||||
reqInterface := kvmppc.Interface{
|
||||
NetType: netInterfaceVal["net_type"].(string),
|
||||
NetID: uint64(netInterfaceVal["net_id"].(int)),
|
||||
}
|
||||
|
||||
ipaddr, ipSet := netInterfaceVal["ip_address"]
|
||||
if ipSet {
|
||||
reqInterface.IPAddr = ipaddr.(string)
|
||||
}
|
||||
|
||||
interfacesPPC = append(interfacesPPC, reqInterface)
|
||||
}
|
||||
createReqPPC.Interfaces = interfacesPPC
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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{})
|
||||
@@ -185,95 +154,57 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
userdata := cloudInit.(string)
|
||||
if userdata != "" && userdata != "applied" {
|
||||
createReqPPC.Userdata = strings.TrimSpace(userdata)
|
||||
createReqX86.Userdata = strings.TrimSpace(userdata)
|
||||
}
|
||||
}
|
||||
|
||||
var computeId uint64
|
||||
driver := d.Get("driver").(string)
|
||||
if driver == "KVM_PPC" {
|
||||
createReqPPC.RGID = uint64(d.Get("rg_id").(int))
|
||||
createReqPPC.Name = d.Get("name").(string)
|
||||
createReqPPC.CPU = uint64(d.Get("cpu").(int))
|
||||
createReqPPC.RAM = uint64(d.Get("ram").(int))
|
||||
createReqPPC.ImageID = uint64(d.Get("image_id").(int))
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM PowerPC")
|
||||
apiResp, err := c.CloudBroker().KVMPPC().Create(ctx, createReqPPC)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
createReqX86.RGID = uint64(d.Get("rg_id").(int))
|
||||
createReqX86.Name = d.Get("name").(string)
|
||||
createReqX86.CPU = uint64(d.Get("cpu").(int))
|
||||
createReqX86.RAM = uint64(d.Get("ram").(int))
|
||||
|
||||
d.SetId(strconv.FormatUint(apiResp, 10))
|
||||
computeId = apiResp
|
||||
} else {
|
||||
createReqX86.RGID = uint64(d.Get("rg_id").(int))
|
||||
createReqX86.Name = d.Get("name").(string)
|
||||
createReqX86.CPU = uint64(d.Get("cpu").(int))
|
||||
createReqX86.RAM = uint64(d.Get("ram").(int))
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
createReqX86.Driver = driver
|
||||
|
||||
if custom_fields, ok := d.GetOk("custom_fields"); ok {
|
||||
val := custom_fields.(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
createReqX86.CustomField = 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.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(apiResp, 10))
|
||||
computeId = apiResp
|
||||
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)
|
||||
}
|
||||
|
||||
createReqX86.Driver = driver
|
||||
|
||||
if custom_fields, ok := d.GetOk("custom_fields"); ok {
|
||||
val := custom_fields.(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
createReqX86.CustomField = 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)
|
||||
createReqX86.Chipset = d.Get("chipset").(string)
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||
apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(apiResp, 10))
|
||||
computeId = apiResp
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
@@ -285,9 +216,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
Permanently: true,
|
||||
DetachDisks: true,
|
||||
}
|
||||
if reason, ok := d.Get("reason").(string); ok {
|
||||
req.Reason = reason
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().Compute().Delete(ctx, req); err != nil {
|
||||
log.Errorf("resourceComputeCreate: could not delete compute after failed creation: %v", err)
|
||||
}
|
||||
@@ -439,9 +368,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if int64(pfwItem["public_port_end"].(int)) != 0 {
|
||||
req.PublicPortEnd = int64(pfwItem["public_port_end"].(int))
|
||||
}
|
||||
if pfwItem["reason"].(string) != "" {
|
||||
req.Reason = pfwItem["reason"].(string)
|
||||
}
|
||||
|
||||
pwfId, err := c.CloudBroker().Compute().PFWAdd(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
@@ -499,9 +426,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
ComputeID: computeId,
|
||||
CDROMID: uint64(snapshotItem["cdrom_id"].(int)),
|
||||
}
|
||||
if snapshotItem["reason"].(string) != "" {
|
||||
req.Reason = snapshotItem["reason"].(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().CDInsert(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
@@ -560,6 +485,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ars, ok := d.GetOk("libvirt_settings"); ok {
|
||||
log.Debugf("resourceComputeCreate: Configure libvirt virtio interface parameters on ComputeID: %d", computeId)
|
||||
settings := ars.(*schema.Set).List()
|
||||
if len(settings) > 0 {
|
||||
for _, v := range settings {
|
||||
settingsConv := v.(map[string]interface{})
|
||||
req := compute.SetNetConfigRequest{
|
||||
ComputeID: computeId,
|
||||
MAC: settingsConv["mac"].(string),
|
||||
TXMode: settingsConv["txmode"].(string),
|
||||
IOEventFD: settingsConv["ioeventfd"].(string),
|
||||
EventIDx: settingsConv["event_idx"].(string),
|
||||
Queues: uint64(settingsConv["queues"].(int)),
|
||||
RXQueueSize: uint64(settingsConv["rx_queue_size"].(int)),
|
||||
TXQueueSize: uint64(settingsConv["tx_queue_size"].(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().SetNetConfig(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
||||
@@ -823,6 +773,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("libvirt_settings") {
|
||||
if err := utilityComputeUpdateLibvirtSettings(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceComputeRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,6 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Get compute by id",
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "reason for action",
|
||||
},
|
||||
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -146,6 +141,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -225,6 +224,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -554,6 +557,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -590,6 +597,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -614,6 +625,7 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"qos": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -638,6 +650,42 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"txmode": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ioeventfd": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"event_idx": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"queues": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"tx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -932,6 +980,16 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Find by IP address",
|
||||
},
|
||||
"stack_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by stack ID",
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by image ID",
|
||||
},
|
||||
"extnet_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -1098,6 +1156,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1158,6 +1220,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1198,6 +1264,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1234,6 +1304,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1282,6 +1356,42 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"txmode": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ioeventfd": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"event_idx": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"queues": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"tx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -2153,10 +2263,6 @@ func dataSourceComputeGetAuditsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
@@ -2196,10 +2302,6 @@ func dataSourceComputePfwListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
@@ -2792,7 +2894,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating
|
||||
Description: "Hardware architecture of this compute instance.",
|
||||
},
|
||||
"cpu": {
|
||||
@@ -2815,6 +2917,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "ID of the OS image to base this compute instance on.",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Type of the emulated system.",
|
||||
},
|
||||
"without_boot_disk": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -2900,7 +3008,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS", "VFNIC"}, false), // observe case while validating
|
||||
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS", "VFNIC", "DPDK"}, false), // observe case while validating
|
||||
Description: "Type of the network for this connection, either EXTNET or VINS.",
|
||||
},
|
||||
|
||||
@@ -2934,11 +3042,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "reason for action",
|
||||
},
|
||||
|
||||
"affinity_label": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -2981,6 +3085,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"delete_async_mode": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "async mode",
|
||||
},
|
||||
"anti_affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -3092,11 +3201,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "reason for action",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3152,11 +3256,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "reason for action",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3211,11 +3310,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"reason": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "reason for action",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3317,6 +3411,43 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "ID of the connected pci devices",
|
||||
},
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"txmode": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"ioeventfd": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"event_idx": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"queues": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"rx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"tx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: "Configure libvirt virtio interface parameters. You can only delete values locally. Data on the platform cannot be deleted.",
|
||||
},
|
||||
// Computed properties
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -3436,6 +3567,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -3472,6 +3607,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -3520,6 +3659,42 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"txmode": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ioeventfd": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"event_idx": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"queues": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"tx_queue_size": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -532,10 +532,6 @@ func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
req.ComputeID = uint64(d.Get("compute_id").(int))
|
||||
}
|
||||
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
}
|
||||
|
||||
res, err := c.CloudBroker().Compute().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -586,13 +582,16 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
|
||||
oldSet, newSet := d.GetChange("network")
|
||||
|
||||
oldList := oldSet.(*schema.Set).List()
|
||||
newList := newSet.(*schema.Set).List()
|
||||
|
||||
detachMap, changeIpMap, attachMap := differenceNetwork(oldList, newList)
|
||||
|
||||
apiErrCount := 0
|
||||
var lastSavedError error
|
||||
|
||||
detachSet := oldSet.(*schema.Set).Difference(newSet.(*schema.Set))
|
||||
log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", detachSet.Len(), d.Id())
|
||||
for _, runner := range detachSet.List() {
|
||||
netData := runner.(map[string]interface{})
|
||||
log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", len(detachMap), d.Id())
|
||||
for _, netData := range detachMap {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := compute.NetDetachRequest{
|
||||
ComputeID: computeId,
|
||||
@@ -609,21 +608,40 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeNetworksConfigure: changeIp set has %d items for Compute ID %s", len(changeIpMap), d.Id())
|
||||
for _, netData := range changeIpMap {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := compute.ChangeIPRequest{
|
||||
ComputeID: computeId,
|
||||
NetType: netData["net_type"].(string),
|
||||
NetID: uint64(netData["net_id"].(int)),
|
||||
IPAddr: netData["ip_address"].(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().ChangeIP(ctx, req)
|
||||
if err != nil {
|
||||
log.Errorf("utilityComputeNetworksConfigure: failed to change net ID %d of type %s from Compute ID %s: %s",
|
||||
netData["net_id"].(int), netData["net_type"].(string), d.Id(), err)
|
||||
apiErrCount++
|
||||
lastSavedError = err
|
||||
}
|
||||
}
|
||||
|
||||
needStart := false
|
||||
|
||||
if d.Get("network").(*schema.Set).Len() == 1 || oldSet.(*schema.Set).Len() < 1 {
|
||||
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 {
|
||||
if err := utilityComputeStop(ctx, d, m); err != nil {
|
||||
apiErrCount++
|
||||
lastSavedError = err
|
||||
}
|
||||
needStart = true
|
||||
if start := d.Get("started"); start.(bool) {
|
||||
needStart = true
|
||||
}
|
||||
}
|
||||
|
||||
attachSet := newSet.(*schema.Set).Difference(oldSet.(*schema.Set))
|
||||
attachList := attachSet.List()
|
||||
sort.Slice(attachList, func(i, j int) bool {
|
||||
weightI := attachList[i].(map[string]interface{})["weight"].(int)
|
||||
weightJ := attachList[j].(map[string]interface{})["weight"].(int)
|
||||
sort.Slice(attachMap, func(i, j int) bool {
|
||||
weightI := attachMap[i]["weight"].(int)
|
||||
weightJ := attachMap[j]["weight"].(int)
|
||||
if weightI == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -632,9 +650,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
}
|
||||
return weightI < weightJ
|
||||
})
|
||||
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", attachSet.Len(), d.Id())
|
||||
for _, runner := range attachList {
|
||||
netData := runner.(map[string]interface{})
|
||||
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(attachMap), d.Id())
|
||||
for _, netData := range attachMap {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := compute.NetAttachRequest{
|
||||
ComputeID: computeId,
|
||||
@@ -672,6 +689,53 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
return nil
|
||||
}
|
||||
|
||||
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap []map[string]interface{}) {
|
||||
attachMap = make([]map[string]interface{}, 0)
|
||||
changeIpMap = make([]map[string]interface{}, 0)
|
||||
detachMap = make([]map[string]interface{}, 0)
|
||||
for _, oldNetwork := range oldList {
|
||||
oldMap := oldNetwork.(map[string]interface{})
|
||||
found := false
|
||||
for _, newNetwork := range newList {
|
||||
newMap := newNetwork.(map[string]interface{})
|
||||
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] {
|
||||
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && newMap["ip_address"] != oldMap["ip_address"] {
|
||||
changeIpMap = append(changeIpMap, newMap)
|
||||
found = true
|
||||
break
|
||||
} else if newMap["ip_address"] == oldMap["ip_address"] {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
detachMap = append(detachMap, oldMap)
|
||||
}
|
||||
|
||||
for _, newNetwork := range newList {
|
||||
newMap := newNetwork.(map[string]interface{})
|
||||
found := false
|
||||
for _, oldNetwork := range oldList {
|
||||
oldMap := oldNetwork.(map[string]interface{})
|
||||
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] {
|
||||
if newMap["ip_address"] == oldMap["ip_address"] || ((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && newMap["ip_address"] != oldMap["ip_address"]) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
attachMap = append(attachMap, newMap)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
@@ -697,6 +761,10 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
req.HPBacked = d.Get("hp_backed").(bool)
|
||||
}
|
||||
|
||||
if d.HasChange("chipset") {
|
||||
req.Chipset = d.Get("chipset").(string)
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -947,6 +1015,36 @@ func utilityComputeUpdatePciDevices(ctx context.Context, d *schema.ResourceData,
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateLibvirtSettings(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
oldSet, newSet := d.GetChange("libvirt_settings")
|
||||
|
||||
added := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List()
|
||||
if len(added) > 0 {
|
||||
for _, v := range added {
|
||||
settingsConv := v.(map[string]interface{})
|
||||
req := compute.SetNetConfigRequest{
|
||||
ComputeID: computeId,
|
||||
MAC: settingsConv["mac"].(string),
|
||||
TXMode: settingsConv["txmode"].(string),
|
||||
IOEventFD: settingsConv["ioeventfd"].(string),
|
||||
EventIDx: settingsConv["event_idx"].(string),
|
||||
Queues: uint64(settingsConv["queues"].(int)),
|
||||
RXQueueSize: uint64(settingsConv["rx_queue_size"].(int)),
|
||||
TXQueueSize: uint64(settingsConv["tx_queue_size"].(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().SetNetConfig(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateTags(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
@@ -1013,9 +1111,6 @@ func utilityComputeUpdatePFW(ctx context.Context, d *schema.ResourceData, m inte
|
||||
} else {
|
||||
req.PublicPortEnd = uint64(pfwItem["public_port_end"].(int))
|
||||
}
|
||||
if pfwItem["reason"].(string) != "" {
|
||||
req.Reason = pfwItem["reason"].(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().PFWDel(ctx, req)
|
||||
if err != nil {
|
||||
@@ -1037,9 +1132,6 @@ func utilityComputeUpdatePFW(ctx context.Context, d *schema.ResourceData, m inte
|
||||
if pfwItem["local_port"].(int) != 0 {
|
||||
req.LocalBasePort = uint64(pfwItem["local_port"].(int))
|
||||
}
|
||||
if pfwItem["reason"].(string) != "" {
|
||||
req.Reason = pfwItem["reason"].(string)
|
||||
}
|
||||
|
||||
pwfId, err := c.CloudBroker().Compute().PFWAdd(ctx, req)
|
||||
if err != nil {
|
||||
@@ -1136,9 +1228,17 @@ func utilityComputeUpdateSnapshot(ctx context.Context, d *schema.ResourceData, m
|
||||
Label: snapshotItem["label"].(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().SnapshotDelete(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
asyncMode, ok := d.GetOk("snapshot_delete_async")
|
||||
if ok && asyncMode.(bool) {
|
||||
_, err := c.CloudBroker().Compute().SnapshotDeleteAsync(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
_, err := c.CloudBroker().Compute().SnapshotDelete(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1218,9 +1318,6 @@ func utilityComputeUpdateCD(ctx context.Context, d *schema.ResourceData, m inter
|
||||
req := compute.CDEjectRequest{
|
||||
ComputeID: computeId,
|
||||
}
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().CDEject(ctx, req)
|
||||
if err != nil {
|
||||
@@ -1235,9 +1332,6 @@ func utilityComputeUpdateCD(ctx context.Context, d *schema.ResourceData, m inter
|
||||
ComputeID: computeId,
|
||||
CDROMID: uint64(cdItem["cdrom_id"].(int)),
|
||||
}
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().CDInsert(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -46,10 +46,6 @@ func utilityComputeGetAuditsCheckPresence(ctx context.Context, d *schema.Resourc
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
}
|
||||
|
||||
computeAudits, err := c.CloudBroker().Compute().GetAudits(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -69,6 +69,12 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource
|
||||
if ipAddress, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ipAddress.(string)
|
||||
}
|
||||
if stackID, ok := d.GetOk("stack_id"); ok {
|
||||
req.StackID = stackID.(uint64)
|
||||
}
|
||||
if imageID, ok := d.GetOk("image_id"); ok {
|
||||
req.ImageID = imageID.(uint64)
|
||||
}
|
||||
if extNetName, ok := d.GetOk("extnet_name"); ok {
|
||||
req.ExtNetName = extNetName.(string)
|
||||
}
|
||||
|
||||
@@ -46,10 +46,6 @@ func utilityComputePfwListCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
}
|
||||
|
||||
listPFWs, err := c.CloudBroker().Compute().PFWList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user