Fix DHCP-less operations with the noop network interface

The base implementation of get_node_network_data returns {} and is
not overridden in the noop network. Update the base implementation
to use task.node.network_data and remove the excessive logging.

Change-Id: Ie50dcd1c2a151f5dd09794467792527032249809
(cherry picked from commit 2e5d01d48d)
This commit is contained in:
Dmitry Tantsur 2020-11-10 18:51:55 +01:00
parent e2b55a8cb8
commit 5cbf7f51f9
5 changed files with 8 additions and 33 deletions

View File

@ -1575,7 +1575,7 @@ class NetworkInterface(BaseInterface):
:returns: a dict holding network configuration information adhearing
Nova network metadata layout (`network_data.json`).
"""
return {}
return task.node.network_data or {}
class StorageInterface(BaseInterface, metaclass=abc.ABCMeta):

View File

@ -459,6 +459,8 @@ def prepare_deploy_iso(task, params, mode, d_info):
network_data = task.driver.network.get_node_network_data(task)
if network_data:
LOG.debug('Injecting custom network data for node %s',
task.node.uuid)
with tempfile.NamedTemporaryFile(dir=CONF.tempdir,
suffix='.iso') as metadata_fileobj:

View File

@ -402,30 +402,6 @@ class VIFPortIDMixin(object):
or p_obj.internal_info.get('inspection_vif_port_id')
or self._get_vif_id_by_port_like_obj(p_obj) or None)
def get_node_network_data(self, task):
"""Get network configuration data for node's ports/portgroups.
Gather L2 and L3 network settings from ironic node `network_data`
field. Ironic would eventually pass network configuration to the node
being managed out-of-band.
:param task: A TaskManager instance.
:raises: InvalidParameterValue, if the network interface configuration
is invalid.
:raises: MissingParameterValue, if some parameters are missing.
:returns: a dict holding network configuration information adhearing
Nova network metadata layout (`network_data.json`).
"""
node = task.node
network_data = node.network_data
# TODO(etingof): remove or truncate `network_data` logging
LOG.debug('Collected network data for node %(node)s: %(data)s',
{'node': node.uuid, 'data': network_data})
return network_data
class NeutronVIFPortIDMixin(VIFPortIDMixin):
"""VIF port ID mixin class for neutron network interfaces.

View File

@ -739,14 +739,6 @@ class TestVifPortIDMixin(db_base.DbTestCase):
vif = self.interface.get_current_vif(task, self.port)
self.assertIsNone(vif)
def test_get_node_network_data_complete(self):
self.node.network_data = self.network_data
self.node.save()
with task_manager.acquire(self.context, self.node.id) as task:
network_data = self.interface.get_node_network_data(task)
self.assertEqual(self.network_data, network_data)
class TestNeutronVifPortIDMixin(db_base.DbTestCase):

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Correctly handles the node's custom network data when the ``noop`` network
interface is used. Previously it was ignored.