@@ -182,10 +182,16 @@ def _add_subports_networks_to_parent_port_switchport(
182182 binding_host = parent_port .bindings [0 ].host
183183
184184 vlan_group_name = binding_profile .get ("physical_network" )
185- if vlan_group_name is None :
186- local_link_info = utils .local_link_from_binding_profile (binding_profile )
187- vlan_group_name = self .ironic_client .baremetal_port_physical_network (
188- local_link_info
185+ if not vlan_group_name :
186+ raise exc .BadRequest (
187+ resource = "port" ,
188+ msg = (
189+ "physical_network is required in binding_profile for baremetal "
190+ f"port trunk configuration. Port { parent_port .id } does not have "
191+ "physical_network in its binding_profile. "
192+ "Please ensure the port's binding_profile contains "
193+ "physical_network in local_link_information."
194+ ),
189195 )
190196
191197 self ._handle_segment_allocation (subports , vlan_group_name , binding_host )
@@ -211,10 +217,17 @@ def _clean_parent_port_switchport_config(
211217 binding_host = parent_port_obj .bindings [0 ].host
212218
213219 vlan_group_name = binding_profile .get ("physical_network" )
214- if vlan_group_name is None :
215- local_link_info = utils .local_link_from_binding_profile (binding_profile )
216- vlan_group_name = self .ironic_client .baremetal_port_physical_network (
217- local_link_info
220+ if not vlan_group_name :
221+ port_id = parent_port_obj .id
222+ raise exc .BadRequest (
223+ resource = "port" ,
224+ msg = (
225+ "physical_network is required in binding_profile for baremetal "
226+ f"port trunk configuration. Port { port_id } does not have "
227+ "physical_network in its binding_profile. "
228+ "Please ensure the port's binding_profile contains "
229+ "physical_network in local_link_information."
230+ ),
218231 )
219232 self ._handle_subports_removal (
220233 binding_profile = binding_profile ,
@@ -265,10 +278,17 @@ def subports_added_post(self, resource, event, trunk_plugin, payload):
265278 if utils .parent_port_is_bound (parent_port ):
266279 binding_profile = parent_port .bindings [0 ].profile
267280 vlan_group_name = binding_profile .get ("physical_network" )
268- if vlan_group_name is None :
269- local_link_info = utils .local_link_from_binding_profile (binding_profile )
270- vlan_group_name = self .ironic_client .baremetal_port_physical_network (
271- local_link_info
281+ if not vlan_group_name :
282+ port_id = parent_port .id
283+ raise exc .BadRequest (
284+ resource = "port" ,
285+ msg = (
286+ "physical_network is required in binding_profile for "
287+ f"baremetal port trunk configuration. Port { port_id } does not "
288+ "have physical_network in its binding_profile. "
289+ "Please ensure the port's binding_profile contains "
290+ "physical_network in local_link_information."
291+ ),
272292 )
273293 LOG .debug ("subports_added_post found vlan_group_name=%s" , vlan_group_name )
274294 self .undersync .sync (vlan_group_name )
0 commit comments