|
|
|
|
@@ -224,7 +224,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|
|
|
|
|
|
|
|
|
needStart := false
|
|
|
|
|
|
|
|
|
|
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 {
|
|
|
|
|
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) {
|
|
|
|
|
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
|
|
|
if err := utilityComputeStop(ctx, computeId, m); err != nil {
|
|
|
|
|
apiErrCount++
|
|
|
|
|
@@ -259,6 +259,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|
|
|
|
req.IPAddr = netData["ip_address"].(string)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if req.NetType == "DPDK" {
|
|
|
|
|
req.MTU = uint64(netData["mtu"].(int))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := c.CloudAPI().Compute().NetAttach(ctx, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Errorf("utilityComputeNetworksConfigure: failed to attach net ID %d of type %s to Compute ID %s: %s",
|
|
|
|
|
@@ -285,6 +289,15 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func hasDPDKnetwork(networkAttachMap []map[string]interface{}) bool {
|
|
|
|
|
for _, elem := range networkAttachMap {
|
|
|
|
|
if elem["net_type"].(string) == "DPDK" {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (compute.RecordCompute, error) {
|
|
|
|
|
c := m.(*controller.ControllerCfg)
|
|
|
|
|
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
|
|
|
@@ -374,12 +387,12 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
|
|
|
|
|
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"] {
|
|
|
|
|
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 (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
|
|
|
|
|
changeIpMap = append(changeIpMap, newMap)
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
} else if newMap["ip_address"] == oldMap["ip_address"] {
|
|
|
|
|
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" {
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
@@ -396,8 +409,10 @@ 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"] {
|
|
|
|
|
if newMap["ip_address"] == oldMap["ip_address"] || ((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && newMap["ip_address"] != oldMap["ip_address"]) {
|
|
|
|
|
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 newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" ||
|
|
|
|
|
((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") &&
|
|
|
|
|
newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|