diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index b322cd0ee0..6350f7ed67 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -557,6 +557,10 @@ def get_neutron_port_data(port_id, vif_id, client=None, context=None): ], 'networks': [ + ], + + 'services': [ + ] } @@ -624,6 +628,14 @@ def get_neutron_port_data(port_id, vif_id, client=None, context=None): network_data['networks'].append(network) + for dns_nameserver in subnet_config['dns_nameservers']: + service = { + 'type': 'dns', + 'address': dns_nameserver + } + + network_data['services'].append(service) + return network_data diff --git a/ironic/tests/unit/common/json_samples/neutron_subnet_show.json b/ironic/tests/unit/common/json_samples/neutron_subnet_show.json index f1b7ae5a55..f03919c9ae 100644 --- a/ironic/tests/unit/common/json_samples/neutron_subnet_show.json +++ b/ironic/tests/unit/common/json_samples/neutron_subnet_show.json @@ -6,7 +6,7 @@ "segment_id": null, "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e", "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], + "dns_nameservers": ["192.0.2.253","192.0.2.254"], "dns_publish_fixed_ip": false, "allocation_pools": [ { diff --git a/ironic/tests/unit/common/json_samples/neutron_subnet_show_ipv6.json b/ironic/tests/unit/common/json_samples/neutron_subnet_show_ipv6.json index e5bd1e496e..134b2f4819 100644 --- a/ironic/tests/unit/common/json_samples/neutron_subnet_show_ipv6.json +++ b/ironic/tests/unit/common/json_samples/neutron_subnet_show_ipv6.json @@ -6,7 +6,7 @@ "segment_id": null, "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e", "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", - "dns_nameservers": [], + "dns_nameservers": ["2001:db8::ffff:c000:2fe"], "dns_publish_fixed_ip": false, "allocation_pools": [ { diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index d0a8e80e73..650697367d 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -646,6 +646,19 @@ class TestNeutronNetworkActions(db_base.DbTestCase): self.assertEqual(expected_network, network_data['networks'][0]) + expected_services = [ + { + 'type': 'dns', + 'address': '192.0.2.253' + }, + { + 'type': 'dns', + 'address': '192.0.2.254' + } + ] + + self.assertEqual(expected_services, network_data['services']) + def load_ipv6_files(self): port_show_file = os.path.join( os.path.dirname(__file__), 'json_samples', @@ -705,6 +718,13 @@ class TestNeutronNetworkActions(db_base.DbTestCase): self.assertEqual(expected_network, network_data['networks'][0]) + expected_service = { + 'type': 'dns', + 'address': '2001:db8::ffff:c000:2fe' + } + + self.assertEqual(expected_service, network_data['services'][0]) + def test_get_node_portmap(self): with task_manager.acquire(self.context, self.node.uuid) as task: portmap = neutron.get_node_portmap(task) diff --git a/releasenotes/notes/fix-network-data-dns-nameservers-f363b3a66c109b4d.yaml b/releasenotes/notes/fix-network-data-dns-nameservers-f363b3a66c109b4d.yaml new file mode 100644 index 0000000000..80bf61326b --- /dev/null +++ b/releasenotes/notes/fix-network-data-dns-nameservers-f363b3a66c109b4d.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + The network_data fetched from Neutron contained 'links', + 'networks' but was missing 'services'. This patch brings + in 'services' to include dns nameservers that can be + configured by Glean or cloud-init during cleaning and + provisioning operations, especially when virtual media + boot is used without DHCP.