From 64bdbb9bc66c38760989dd7bb2574ccc14069872 Mon Sep 17 00:00:00 2001
From: Alejandro Santoyo <alejandro.santoyo@canonical.com>
Date: Fri, 25 Oct 2024 12:38:40 +0200
Subject: [PATCH] Avoid wrongly passing "no_fixed_ips" to Neutron

For ports without fixed IPs, Neutron expects "fixed_ips = []" as
it does not understand "no_fixed_ips", so Heat should not be
passing that.

The logic to avoid passing this key when creating ports without
fixed IPs via OS::Neutron::Ports was added but never included for
ports created via OS::Nova::Server.

story: 2011249
task: 51221
Change-Id: Id5b89cf3bd816b92b888665b88c26e5c9332e1a6
(cherry picked from commit c5e0a4479a635f46a821d59969428898406ee0cb)
---
 heat/engine/resources/openstack/nova/server_network_mixin.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/heat/engine/resources/openstack/nova/server_network_mixin.py b/heat/engine/resources/openstack/nova/server_network_mixin.py
index 62d5019943..7d3980a4ce 100644
--- a/heat/engine/resources/openstack/nova/server_network_mixin.py
+++ b/heat/engine/resources/openstack/nova/server_network_mixin.py
@@ -120,6 +120,8 @@ class ServerNetworkMixin(object):
         # we should add fixed_ips only if subnet or ip were provided
         if body:
             kwargs.update({'fixed_ips': [body]})
+        if net_data.get(neutron_port.Port.NO_FIXED_IPS):
+            kwargs.update({'fixed_ips': []})
 
         if security_groups:
             sec_uuids = self.client_plugin(
@@ -133,6 +135,7 @@ class ServerNetworkMixin(object):
                 kwargs.update(specs)
             port_extra_keys = list(neutron_port.Port.EXTRA_PROPERTIES)
             port_extra_keys.remove(neutron_port.Port.ALLOWED_ADDRESS_PAIRS)
+            port_extra_keys.remove(neutron_port.Port.NO_FIXED_IPS)
             for key in port_extra_keys:
                 if extra_props.get(key) is not None:
                     kwargs[key] = extra_props.get(key)