PXE: Support Extra DHCP Options for IPv6

This patch is adding a new configuration option called "ip_version" in
the "pxe" group which allow passing the IP version to the DHCP
server/Neutron port when updating the extra DHCP options for PXE
booting.

Change-Id: Ib27d977161a5278ffe4be841411404b2326401ed
This commit is contained in:
Lucas Alvares Gomes 2015-10-06 17:09:23 +01:00
parent edda2f2624
commit 8cfaf82a9f
4 changed files with 44 additions and 12 deletions

View File

@ -1747,6 +1747,10 @@
# file. (string value)
#ipxe_boot_script=$pybasedir/drivers/modules/boot.ipxe
# The IP version that will be used for PXE booting. Can be
# either 4 or 6. Defaults to 4. EXPERIMENTAL (integer value)
#ip_version=4
[seamicro]

View File

@ -330,4 +330,9 @@ def dhcp_options_for_instance(task):
'opt_value': CONF.pxe.tftp_server})
dhcp_opts.append({'opt_name': 'tftp-server',
'opt_value': CONF.pxe.tftp_server})
# Append the IP version for all the configuration options
for opt in dhcp_opts:
opt.update({'ip_version': int(CONF.pxe.ip_version)})
return dhcp_opts

View File

@ -80,6 +80,11 @@ pxe_opts = [
'drivers/modules/boot.ipxe'),
help=_('On ironic-conductor node, the path to the main iPXE '
'script file.')),
cfg.StrOpt('ip_version',
default='4',
choices=['4', '6'],
help=_('The IP version that will be used for PXE booting. '
'Can be either 4 or 6. Defaults to 4. EXPERIMENTAL')),
]
LOG = logging.getLogger(__name__)

View File

@ -361,20 +361,30 @@ class TestPXEUtils(db_base.DbTestCase):
'config'),
pxe_utils.get_pxe_config_file_path(self.node.uuid))
def test_dhcp_options_for_instance(self):
def _dhcp_options_for_instance(self, ip_version=4):
self.config(ip_version=ip_version, group='pxe')
self.config(tftp_server='192.0.2.1', group='pxe')
self.config(pxe_bootfile_name='fake-bootfile', group='pxe')
expected_info = [{'opt_name': 'bootfile-name',
'opt_value': 'fake-bootfile'},
'opt_value': 'fake-bootfile',
'ip_version': ip_version},
{'opt_name': 'server-ip-address',
'opt_value': '192.0.2.1'},
'opt_value': '192.0.2.1',
'ip_version': ip_version},
{'opt_name': 'tftp-server',
'opt_value': '192.0.2.1'}
'opt_value': '192.0.2.1',
'ip_version': ip_version},
]
with task_manager.acquire(self.context, self.node.uuid) as task:
self.assertEqual(expected_info,
pxe_utils.dhcp_options_for_instance(task))
def test_dhcp_options_for_instance(self):
self._dhcp_options_for_instance(ip_version=4)
def test_dhcp_options_for_instance_ipv6(self):
self._dhcp_options_for_instance(ip_version=6)
def _test_get_deploy_kr_info(self, expected_dir):
node_uuid = 'fake-node'
driver_info = {
@ -422,13 +432,17 @@ class TestPXEUtils(db_base.DbTestCase):
self.config(dhcp_provider='isc', group='dhcp')
expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe'
expected_info = [{'opt_name': '!175,bootfile-name',
'opt_value': 'fake-bootfile'},
'opt_value': 'fake-bootfile',
'ip_version': 4},
{'opt_name': 'server-ip-address',
'opt_value': '192.0.2.1'},
'opt_value': '192.0.2.1',
'ip_version': 4},
{'opt_name': 'tftp-server',
'opt_value': '192.0.2.1'},
'opt_value': '192.0.2.1',
'ip_version': 4},
{'opt_name': 'bootfile-name',
'opt_value': expected_boot_script_url}]
'opt_value': expected_boot_script_url,
'ip_version': 4}]
with task_manager.acquire(self.context, self.node.uuid) as task:
self.assertItemsEqual(expected_info,
pxe_utils.dhcp_options_for_instance(task))
@ -436,13 +450,17 @@ class TestPXEUtils(db_base.DbTestCase):
self.config(dhcp_provider='neutron', group='dhcp')
expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe'
expected_info = [{'opt_name': 'tag:!ipxe,bootfile-name',
'opt_value': 'fake-bootfile'},
'opt_value': 'fake-bootfile',
'ip_version': 4},
{'opt_name': 'server-ip-address',
'opt_value': '192.0.2.1'},
'opt_value': '192.0.2.1',
'ip_version': 4},
{'opt_name': 'tftp-server',
'opt_value': '192.0.2.1'},
'opt_value': '192.0.2.1',
'ip_version': 4},
{'opt_name': 'tag:ipxe,bootfile-name',
'opt_value': expected_boot_script_url}]
'opt_value': expected_boot_script_url,
'ip_version': 4}]
with task_manager.acquire(self.context, self.node.uuid) as task:
self.assertItemsEqual(expected_info,
pxe_utils.dhcp_options_for_instance(task))