diff --git a/python/neutron-understack/neutron_understack/neutron_understack_mech.py b/python/neutron-understack/neutron_understack/neutron_understack_mech.py index d7ce95ce9..aa9263bc9 100644 --- a/python/neutron-understack/neutron_understack/neutron_understack_mech.py +++ b/python/neutron-understack/neutron_understack/neutron_understack_mech.py @@ -115,16 +115,18 @@ def _update_port_baremetal(self, context: PortContext) -> None: current_vif_other = context.vif_type == portbindings.VIF_TYPE_OTHER if current_vif_unbound and original_vif_other: - local_link_info = utils.local_link_from_binding_profile( - context.original[portbindings.PROFILE] - ) + port = context.original else: + port = context.current + + vlan_group_name = port[portbindings.PROFILE].get("physical_network") + if vlan_group_name is None: local_link_info = utils.local_link_from_binding_profile( - context.current[portbindings.PROFILE] + port[portbindings.PROFILE] + ) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info ) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) if current_vif_unbound and original_vif_other: self._tenant_network_port_cleanup(context) @@ -178,14 +180,18 @@ def _delete_port_baremetal(self, context: PortContext) -> None: # Only clean up provisioning ports. Ports with tenant networks are cleaned # up in _tenant_network_port_cleanup - local_link_info = utils.local_link_from_binding_profile( - context.current[portbindings.PROFILE] - ) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) + port = context.current - if vlan_group_name and is_provisioning_network(context.current["network_id"]): + vlan_group_name = port[portbindings.PROFILE].get("physical_network") + if vlan_group_name is None: + local_link_info = utils.local_link_from_binding_profile( + port[portbindings.PROFILE] + ) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info + ) + + if vlan_group_name and is_provisioning_network(port["network_id"]): # Signals end of the provisioning / cleaning cycle, so we # put the port back to its normal tenant mode: self.invoke_undersync(vlan_group_name) @@ -232,12 +238,16 @@ def _bind_port_segment(self, context: PortContext, segment): network_id = context.current["network_id"] mac_address = context.current["mac_address"] - local_link_info = utils.local_link_from_binding_profile( - context.current[portbindings.PROFILE] - ) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) + port = context.current + + vlan_group_name = port[portbindings.PROFILE].get("physical_network") + if vlan_group_name is None: + local_link_info = utils.local_link_from_binding_profile( + port[portbindings.PROFILE] + ) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info + ) if not vlan_group_name: LOG.error( diff --git a/python/neutron-understack/neutron_understack/trunk.py b/python/neutron-understack/neutron_understack/trunk.py index 716f59e15..395a6186c 100644 --- a/python/neutron-understack/neutron_understack/trunk.py +++ b/python/neutron-understack/neutron_understack/trunk.py @@ -181,10 +181,12 @@ def _add_subports_networks_to_parent_port_switchport( binding_profile = parent_port.bindings[0].profile binding_host = parent_port.bindings[0].host - local_link_info = utils.local_link_from_binding_profile(binding_profile) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) + vlan_group_name = binding_profile.get("physical_network") + if vlan_group_name is None: + local_link_info = utils.local_link_from_binding_profile(binding_profile) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info + ) self._handle_segment_allocation(subports, vlan_group_name, binding_host) @@ -207,10 +209,13 @@ def _clean_parent_port_switchport_config( return binding_profile = parent_port_obj.bindings[0].profile binding_host = parent_port_obj.bindings[0].host - local_link_info = utils.local_link_from_binding_profile(binding_profile) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) + + vlan_group_name = binding_profile.get("physical_network") + if vlan_group_name is None: + local_link_info = utils.local_link_from_binding_profile(binding_profile) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info + ) self._handle_subports_removal( binding_profile=binding_profile, binding_host=binding_host, @@ -265,10 +270,12 @@ def subports_added_post(self, resource, event, trunk_plugin, payload): if utils.parent_port_is_bound(parent_port): binding_profile = parent_port.bindings[0].profile - local_link_info = utils.local_link_from_binding_profile(binding_profile) - vlan_group_name = self.ironic_client.baremetal_port_physical_network( - local_link_info - ) + vlan_group_name = binding_profile.get("physical_network") + if vlan_group_name is None: + local_link_info = utils.local_link_from_binding_profile(binding_profile) + vlan_group_name = self.ironic_client.baremetal_port_physical_network( + local_link_info + ) LOG.debug("subports_added_post found vlan_group_name=%s", vlan_group_name) self._trigger_undersync(vlan_group_name)