diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index 40ad982176..1849aaa7d6 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -1001,8 +1001,10 @@ def build_kickstart_config_options(task): manager_utils.add_secret_token(node, pregenerated=True) node.save() params['liveimg_url'] = node.instance_info['image_url'] + if node.driver_internal_info.get('is_source_a_path', False): + # Record a value so it matches as the template opts in. + params['is_source_a_path'] = 'true' params['agent_token'] = node.driver_internal_info['agent_secret_token'] - heartbeat_url = '%s/v1/heartbeat/%s' % ( deploy_utils.get_ironic_api_url().rstrip('/'), node.uuid diff --git a/ironic/drivers/modules/ks.cfg.template b/ironic/drivers/modules/ks.cfg.template index 825ea38c8c..ca799953a4 100644 --- a/ironic/drivers/modules/ks.cfg.template +++ b/ironic/drivers/modules/ks.cfg.template @@ -15,11 +15,24 @@ zerombr clearpart --all --initlabel autopart -# Downloading and installing OS image using liveimg section is mandatory -# in a *default* ironic configuration. Users (infrastructure operators) +# Downloading and installing OS image using "liveimg" section is the +# default mode of operation for an OpenStack-integrated Ironic +# deployment where Glance is in use. Users (infrastructure operators) # may choose to customize this pattern, or use release specific kickstart # configurations which may already point to a mirror. +# +# An alternative is "url", which points to a repository of files used for +# the deploy, similar to mounting an ISO media and exposing the files. + +{% if 'is_source_a_path' in ks_options -%} +url --url {{ks_options.liveimg_url }} + +# If packages are not selected, a URL based auto-deployment fails. +%packages --ignoremissing +%end +{% else -%} liveimg --url {{ ks_options.liveimg_url }} +{% endif -%} # Following %pre and %onerror sections are mandatory %pre diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 037ad7449f..f9d7818305 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -1608,6 +1608,27 @@ class PXEBuildKickstartConfigOptionsTestCase(db_base.DbTestCase): self.assertTrue(params['ks_options'].pop('agent_token')) self.assertEqual(expected, params['ks_options']) + @mock.patch.object(deploy_utils, 'get_ironic_api_url', autospec=True) + def test_build_kickstart_config_options_pxe_source_path(self, + api_url_mock): + api_url_mock.return_value = 'http://ironic-api' + d_info = self.node.driver_internal_info + d_info['is_source_a_path'] = True + self.node.driver_internal_info = d_info + self.node.save() + with task_manager.acquire(self.context, self.node.uuid, + shared=True) as task: + expected = {} + expected['liveimg_url'] = task.node.instance_info['image_url'] + expected['config_drive'] = '' + expected['heartbeat_url'] = ( + 'http://ironic-api/v1/heartbeat/%s' % task.node.uuid + ) + expected['is_source_a_path'] = 'true' + params = pxe_utils.build_kickstart_config_options(task) + self.assertTrue(params['ks_options'].pop('agent_token')) + self.assertEqual(expected, params['ks_options']) + @mock.patch('ironic.common.utils.render_template', autospec=True) def test_prepare_instance_kickstart_config_not_anaconda_boot(self, render_mock): diff --git a/releasenotes/notes/adds-kickstart-auto-url-in-template-9f716c244adff159.yaml b/releasenotes/notes/adds-kickstart-auto-url-in-template-9f716c244adff159.yaml new file mode 100644 index 0000000000..df7e0bdcf5 --- /dev/null +++ b/releasenotes/notes/adds-kickstart-auto-url-in-template-9f716c244adff159.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adds an automatic switch to ``url`` for the kickstart template when + the source is a URL path as opposed to a ``stage2`` ramdisk.