mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-14 01:13:59 -06:00
Merge pull request #5365 from jtopjian/openstack-instance-network-update-guard
provider/openstack: Safely typecast network during instance update
This commit is contained in:
commit
ba8033bf74
@ -654,16 +654,23 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
|||||||
oldNetworkList := oldNetworks.([]interface{})
|
oldNetworkList := oldNetworks.([]interface{})
|
||||||
newNetworkList := newNetworks.([]interface{})
|
newNetworkList := newNetworks.([]interface{})
|
||||||
for i, oldNet := range oldNetworkList {
|
for i, oldNet := range oldNetworkList {
|
||||||
oldNetRaw := oldNet.(map[string]interface{})
|
var oldFIP, newFIP string
|
||||||
oldFIP := oldNetRaw["floating_ip"].(string)
|
var oldFixedIP, newFixedIP string
|
||||||
oldFixedIP := oldNetRaw["fixed_ip_v4"].(string)
|
|
||||||
|
|
||||||
newNetRaw := newNetworkList[i].(map[string]interface{})
|
if oldNetRaw, ok := oldNet.(map[string]interface{}); ok {
|
||||||
newFIP := newNetRaw["floating_ip"].(string)
|
oldFIP = oldNetRaw["floating_ip"].(string)
|
||||||
newFixedIP := newNetRaw["fixed_ip_v4"].(string)
|
oldFixedIP = oldNetRaw["fixed_ip_v4"].(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(newNetworkList) > i {
|
||||||
|
if newNetRaw, ok := newNetworkList[i].(map[string]interface{}); ok {
|
||||||
|
newFIP = newNetRaw["floating_ip"].(string)
|
||||||
|
newFixedIP = newNetRaw["fixed_ip_v4"].(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only changes to the floating IP are supported
|
// Only changes to the floating IP are supported
|
||||||
if oldFIP != newFIP {
|
if oldFIP != "" && newFIP != "" && oldFIP != newFIP {
|
||||||
log.Printf("[DEBUG] Attempting to disassociate %s from %s", oldFIP, d.Id())
|
log.Printf("[DEBUG] Attempting to disassociate %s from %s", oldFIP, d.Id())
|
||||||
if err := disassociateFloatingIPFromInstance(computeClient, oldFIP, d.Id(), oldFixedIP); err != nil {
|
if err := disassociateFloatingIPFromInstance(computeClient, oldFIP, d.Id(), oldFixedIP); err != nil {
|
||||||
return fmt.Errorf("Error disassociating Floating IP during update: %s", err)
|
return fmt.Errorf("Error disassociating Floating IP during update: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user