Add kickstart template 'url' option
To use a source as a path with the anaconda deployment interface, the kickstart template needs to utilize a 'url' command as opposed to a second stage ramdisk. This allows a seamless automatic switch without a customized kickstart template to just use a URL. Change-Id: I31febd4e131ed0cc1b37adb9318be8cb17136a68
This commit is contained in:
parent
c861423eb5
commit
5c1dd47e6c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user