Don't log PXE when your not doing PXE.

So... the neutron common code is modeled around PXE, and when you
go to do something with vmedia, you can get errors logged about not
having PXE enabled ports which is misleading.

The reality is the common code needs to base the decision on if all
ports need to be added or if just PXE enabled ports need to be added
based upon the loaded driver via configuration.

As such, now we consult the boot interface's capabilities field
and alternatively pull in the additional interfaces as appropriate
for virtual media users.

Which then also fixes the misleading error!

Closes-Bug: 2098791
Change-Id: I8c9d07e2ded75f138897ece6a67016a6f0020ce6
This commit is contained in:
Julia Kreger
2025-02-18 11:29:18 -08:00
parent 0b57f5609e
commit 8610346794
2 changed files with 13 additions and 4 deletions

View File

@@ -259,7 +259,8 @@ def add_ports_to_network(task, network_uuid, security_groups=None):
"""
client = get_client(context=task.context)
node = task.node
add_all_ports = CONF.neutron.add_all_ports
pxe_capability = 'pxe_boot' in task.driver.boot.capabilities
add_all_ports = CONF.neutron.add_all_ports or not pxe_capability
# If Security Groups are specified, verify that they exist
_verify_security_groups(security_groups, client)

View File

@@ -224,7 +224,8 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
@mock.patch.object(neutron, 'update_neutron_port', autospec=True)
def _test_add_ports_to_network(self, update_mock, is_client_id,
security_groups=None,
add_all_ports=False):
add_all_ports=False,
boot_not_pxe=False):
# Ports will be created only if pxe_enabled is True
self.node.network_interface = 'neutron'
self.node.save()
@@ -263,7 +264,7 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
expected_create_attrs['extra_dhcp_opts'] = (
[{'opt_name': '61', 'opt_value': self._CLIENT_ID}])
if add_all_ports:
if add_all_ports or boot_not_pxe:
expected_create_attrs2 = copy.deepcopy(expected_create_attrs)
expected_update_attrs2 = copy.deepcopy(expected_update_attrs)
expected_update_attrs2['mac_address'] = port2.address
@@ -284,10 +285,13 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
expected = {port.uuid: self.neutron_port['id']}
with task_manager.acquire(self.context, self.node.uuid) as task:
if boot_not_pxe:
# force override of driver properties, just to keep it simple.
task.driver.boot.capabilities = ['not_pxe']
ports = neutron.add_ports_to_network(
task, self.network_uuid, security_groups=security_groups)
self.assertEqual(expected, ports)
if add_all_ports:
if add_all_ports or boot_not_pxe:
create_calls = [mock.call(**expected_create_attrs),
mock.call(**expected_create_attrs2)]
update_calls = [
@@ -313,6 +317,10 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
security_groups=None,
add_all_ports=True)
def test_add_ports_to_network_all_ports_via_not_pxe(self):
self._test_add_ports_to_network(is_client_id=False,
boot_not_pxe=True)
@mock.patch.object(neutron, '_verify_security_groups', autospec=True)
def test_add_ports_to_network_with_sg(self, verify_mock):
sg_ids = []