4.10.0
This commit is contained in:
@@ -103,6 +103,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("boot_type", computeRec.BootType)
|
||||
d.Set("hot_resize", computeRec.HotResize)
|
||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -161,7 +162,6 @@ func flattenOSUsers(users compute.ListOSUsers) []map[string]interface{} {
|
||||
|
||||
func flattenInterfaces(ifaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(ifaces))
|
||||
|
||||
for _, iface := range ifaces {
|
||||
res = append(res, map[string]interface{}{
|
||||
"bus_number": iface.BusNumber,
|
||||
@@ -182,13 +182,14 @@ func flattenInterfaces(ifaces compute.ListInterfaces) []map[string]interface{} {
|
||||
"node_id": iface.NodeID,
|
||||
"pci_slot": iface.PCISlot,
|
||||
"qos": flattenQOS(iface.QOS),
|
||||
"sdn_interface_id": iface.SDNInterfaceID,
|
||||
"target": iface.Target,
|
||||
"type": iface.Type,
|
||||
"trunk_tags": iface.TrunkTags,
|
||||
"vnfs": iface.VNFs,
|
||||
"libvirt_settings": flattenLibvirtSettings(iface.LibvirtSettings),
|
||||
})
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -290,6 +291,7 @@ func flattenAffinityRules(rules compute.ListRules) []map[string]interface{} {
|
||||
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computes.Data))
|
||||
for _, computeItem := range computes.Data {
|
||||
|
||||
customFields, _ := json.Marshal(computeItem.CustomFields)
|
||||
devices, _ := json.Marshal(computeItem.Devices)
|
||||
userData, _ := json.Marshal(computeItem.Userdata)
|
||||
@@ -327,6 +329,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"image_id": computeItem.ImageID,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"live_migration_job_id": computeItem.LiveMigrationJobID,
|
||||
"lock_status": computeItem.LockStatus,
|
||||
"manager_id": computeItem.ManagerID,
|
||||
"manager_type": computeItem.ManagerType,
|
||||
@@ -340,6 +343,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"os_users": flattenOSUsers(computeItem.OSUsers),
|
||||
"pinned": computeItem.PinnedToStack,
|
||||
"preferred_cpu": computeItem.PreferredCPU,
|
||||
"qemu_guest": flattenQemuQuest(computeItem.QemuQuest),
|
||||
"ram": computeItem.RAM,
|
||||
"reference_id": computeItem.ReferenceID,
|
||||
"registered": computeItem.Registered,
|
||||
@@ -367,9 +371,11 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"boot_type": computeItem.BootType,
|
||||
"hot_resize": computeItem.HotResize,
|
||||
"network_interface_naming": computeItem.NetworkInterfaceNaming,
|
||||
"zone_id": computeItem.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -452,6 +458,7 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri
|
||||
"boot_type": computeItem.BootType,
|
||||
"hot_resize": computeItem.HotResize,
|
||||
"network_interface_naming": computeItem.NetworkInterfaceNaming,
|
||||
"zone_id": computeItem.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -738,6 +745,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("image_id", compFacts.ImageID)
|
||||
d.Set("image_name", compFacts.ImageName)
|
||||
d.Set("interfaces", flattenInterfaces(compFacts.Interfaces))
|
||||
d.Set("live_migration_job_id", compFacts.LiveMigrationJobID)
|
||||
d.Set("lock_status", compFacts.LockStatus)
|
||||
d.Set("manager_id", compFacts.ManagerID)
|
||||
d.Set("manager_type", compFacts.ManagerType)
|
||||
@@ -755,6 +763,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("os_users", flattenOSUsers(compFacts.OSUsers))
|
||||
d.Set("pinned", compFacts.PinnedToStack)
|
||||
d.Set("preferred_cpu", compFacts.PreferredCPU)
|
||||
d.Set("qemu_guest", flattenQemuQuest(compFacts.QemuQuest))
|
||||
d.Set("ram", compFacts.RAM)
|
||||
d.Set("reference_id", compFacts.ReferenceID)
|
||||
d.Set("registered", compFacts.Registered)
|
||||
@@ -783,6 +792,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("boot_type", compFacts.BootType)
|
||||
d.Set("hot_resize", compFacts.HotResize)
|
||||
d.Set("network_interface_naming", compFacts.NetworkInterfaceNaming)
|
||||
d.Set("zone_id", compFacts.ZoneID)
|
||||
//extra fields setting
|
||||
bootDisk := findBootDisk(compFacts.Disks)
|
||||
if bootDisk != nil {
|
||||
@@ -811,6 +821,7 @@ func parseComputeInterfacesToNetworks(networks []interface{}, ifaces compute.Lis
|
||||
elem["ip_address"] = value.IPAddress
|
||||
elem["mac"] = value.MAC
|
||||
elem["mtu"] = value.MTU
|
||||
elem["sdn_interface_id"] = value.SDNInterfaceID
|
||||
elem["weight"] = flattenNetworkWeight(networks, value.NetID, value.NetType)
|
||||
|
||||
result = append(result, elem)
|
||||
@@ -854,7 +865,6 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
|
||||
"login": disk.Login,
|
||||
"milestones": disk.Milestones,
|
||||
"name": disk.Name,
|
||||
"order": disk.Order,
|
||||
"params": disk.Params,
|
||||
"parent_id": disk.ParentID,
|
||||
"passwd": disk.Password,
|
||||
@@ -878,7 +888,6 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
|
||||
"status": disk.Status,
|
||||
"tech_status": disk.TechStatus,
|
||||
"type": disk.Type,
|
||||
"vmid": disk.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -969,3 +978,19 @@ func flattenVGPUs(vgpus []compute.VGPUItem) []map[string]interface{} {
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenQemuQuest(qemuQuest compute.QemuQuest) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
|
||||
temp := map[string]interface{}{
|
||||
"enabled": qemuQuest.Enabled,
|
||||
"enabled_agent_features": qemuQuest.EnabledAgentFeatures,
|
||||
"guid": qemuQuest.GUID,
|
||||
"last_update": uint64(qemuQuest.LastUpdate),
|
||||
"user": qemuQuest.User,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ 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, dpdkIds []uint64
|
||||
var vinsIds, extNetIds, vfpoolIds, dpdkIds, trunkIds []uint64
|
||||
//TODO
|
||||
//var sdnIds []string
|
||||
|
||||
networksIface, ok := d.GetOk("network")
|
||||
if !ok {
|
||||
@@ -56,6 +58,12 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
|
||||
vfpoolIds = append(vfpoolIds, uint64(network["net_id"].(int)))
|
||||
case "DPDK":
|
||||
dpdkIds = append(dpdkIds, uint64(network["net_id"].(int)))
|
||||
case "TRUNK":
|
||||
trunkIds = append(trunkIds, uint64(network["net_id"].(int)))
|
||||
|
||||
//TODO
|
||||
//case "SDN": sdnIds = append(sdnIds, network["sdn_interface_id"].(string))
|
||||
|
||||
default:
|
||||
continue
|
||||
}
|
||||
@@ -77,5 +85,14 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
|
||||
errs = append(errs, dpdkErrs...)
|
||||
}
|
||||
|
||||
if trunkErrs := ic.ExistTrunkNet(ctx, trunkIds, c); trunkErrs != nil {
|
||||
errs = append(errs, trunkErrs...)
|
||||
}
|
||||
|
||||
//TODO
|
||||
//if sdnErrs := ic.ExistSDNNet(ctx, sdnIds, c); sdnErrs != nil {
|
||||
// errs = append(errs, sdnErrs...)
|
||||
//}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
createReqX86.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
@@ -112,7 +116,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
NetID: uint64(netInterfaceVal["net_id"].(int)),
|
||||
}
|
||||
|
||||
if reqInterface.NetType == "DPDK" {
|
||||
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" {
|
||||
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
|
||||
}
|
||||
|
||||
@@ -126,6 +130,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
reqInterface.MAC = macaddr.(string)
|
||||
}
|
||||
|
||||
sdnID, sdnSet := netInterfaceVal["sdn_interface_id"]
|
||||
if sdnSet {
|
||||
reqInterface.SDNInterfaceID = sdnID.(string)
|
||||
}
|
||||
|
||||
interfacesX86 = append(interfacesX86, reqInterface)
|
||||
}
|
||||
createReqX86.Interfaces = interfacesX86
|
||||
@@ -861,6 +870,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("zone_id") {
|
||||
if err := utilityComputeUpdateZoneID(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceComputeRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"explicit": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
@@ -366,10 +366,6 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"order": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"params": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -522,10 +518,6 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -702,6 +694,14 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"trunk_tags": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"sdn_interface_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vnfs": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -712,6 +712,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"live_migration_job_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"lock_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -803,6 +807,37 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"qemu_guest": {
|
||||
Type: schema.TypeList,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"enabled_agent_features": {
|
||||
Type: schema.TypeList,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"last_update": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1047,6 +1082,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -1146,7 +1185,6 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "If set to true, ignores any VMs associated with any k8s cluster",
|
||||
},
|
||||
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1158,7 +1196,7 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"explicit": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
@@ -1519,6 +1557,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"sdn_interface_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1527,6 +1569,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"trunk_tags": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vnfs": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1537,6 +1583,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"live_migration_job_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"lock_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1612,6 +1662,37 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"qemu_guest": {
|
||||
Type: schema.TypeList,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"enabled_agent_features": {
|
||||
Type: schema.TypeList,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"last_update": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1762,6 +1843,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1851,7 +1936,7 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"explicit": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
@@ -2208,6 +2293,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"sdn_interface_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -2216,6 +2305,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"trunk_tags": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vnfs": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -2447,6 +2540,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3133,7 +3230,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating
|
||||
ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false), // observe case while validating
|
||||
Description: "Hardware architecture of this compute instance.",
|
||||
},
|
||||
"cpu": {
|
||||
@@ -3156,6 +3253,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "ID of the OS image to base this compute instance on.",
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -3241,8 +3343,8 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
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.",
|
||||
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating
|
||||
Description: "Type of the network for this connection",
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -3277,6 +3379,13 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
ValidateFunc: validation.IntBetween(1, 9216),
|
||||
Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216",
|
||||
},
|
||||
"sdn_interface_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
|
||||
Description: "unique_identifier of LogicalPort on SDN side",
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
@@ -3749,7 +3858,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"explicit": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
@@ -3979,6 +4088,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"sdn_interface_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -3987,6 +4100,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"trunk_tags": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vnfs": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -589,8 +589,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
oldList := oldSet.(*schema.Set).List()
|
||||
newList := newSet.(*schema.Set).List()
|
||||
|
||||
detachMap, changeIpMap, changeMacMap, attachMap := differenceNetwork(oldList, newList)
|
||||
|
||||
detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap := differenceNetwork(oldList, newList)
|
||||
apiErrCount := 0
|
||||
var lastSavedError error
|
||||
|
||||
@@ -697,6 +696,14 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
req.MACAddr = netData["mac"].(string)
|
||||
}
|
||||
|
||||
if req.NetType == "DPDK" {
|
||||
req.MTU = uint64(netData["mtu"].(int))
|
||||
}
|
||||
|
||||
if netData["sdn_interface_id"].(string) != "" {
|
||||
req.SDNInterfaceID = netData["sdn_interface_id"].(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().NetAttach(ctx, req)
|
||||
if err != nil {
|
||||
log.Errorf("utilityComputeNetworksConfigure: failed to attach net ID %d of type %s to Compute ID %s: %s",
|
||||
@@ -759,6 +766,24 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeNetworksConfigure: changeMTU set has %d items for Compute ID %s", len(changeMTUMap), d.Id())
|
||||
for _, netData := range changeMTUMap {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := compute.ChangeMTURequest{
|
||||
ComputeID: computeId,
|
||||
Interface: netData["mac"].(string),
|
||||
MTU: uint64(netData["mtu"].(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().ChangeMTU(ctx, req)
|
||||
if err != nil {
|
||||
log.Errorf("utilityComputeNetworksConfigure: failed to change MTU ID %d of type %s from Compute ID %s: %s",
|
||||
netData["net_id"].(int), netData["net_type"].(string), d.Id(), err)
|
||||
apiErrCount++
|
||||
lastSavedError = err
|
||||
}
|
||||
}
|
||||
|
||||
if apiErrCount > 0 {
|
||||
log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s",
|
||||
apiErrCount, d.Id(), lastSavedError)
|
||||
@@ -768,17 +793,18 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
return nil
|
||||
}
|
||||
|
||||
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, attachMap []map[string]interface{}) {
|
||||
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap []map[string]interface{}) {
|
||||
attachMap = make([]map[string]interface{}, 0)
|
||||
changeIpMap = make([]map[string]interface{}, 0)
|
||||
changeMacMap = make([]map[string]interface{}, 0)
|
||||
changeMTUMap = 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"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
|
||||
if compareNetwork(newMap, oldMap) {
|
||||
found = true
|
||||
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
|
||||
changeIpMap = append(changeIpMap, newMap)
|
||||
@@ -787,6 +813,9 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
||||
newMap["old_mac"] = oldMap["mac"]
|
||||
changeMacMap = append(changeMacMap, newMap)
|
||||
}
|
||||
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "DPDK") && (newMap["mtu"] != oldMap["mtu"] && newMap["mtu"].(int) != 0) {
|
||||
changeMTUMap = append(changeMTUMap, newMap)
|
||||
}
|
||||
}
|
||||
if found {
|
||||
break
|
||||
@@ -803,7 +832,7 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
||||
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"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
|
||||
if compareNetwork(newMap, oldMap) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -817,6 +846,10 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
||||
return
|
||||
}
|
||||
|
||||
func compareNetwork(newMap, oldMap map[string]interface{}) bool {
|
||||
return newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["sdn_interface_id"] == oldMap["sdn_interface_id"] && newMap["weight"] == oldMap["weight"]
|
||||
}
|
||||
|
||||
func hasDPDKnetwork(networkAttachMap []map[string]interface{}) bool {
|
||||
for _, elem := range networkAttachMap {
|
||||
if elem["net_type"].(string) == "DPDK" {
|
||||
@@ -1587,6 +1620,28 @@ func utilityComputeUpdateImage(ctx context.Context, d *schema.ResourceData, m in
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateZoneID(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
req := compute.MigrateToZoneRequest{
|
||||
ComputeID: computeId,
|
||||
}
|
||||
|
||||
zoneID, ok := d.GetOk("zone_id")
|
||||
if ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().MigrateToZone(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateCustomFields(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user