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)
|
manager_utils.add_secret_token(node, pregenerated=True)
|
||||||
node.save()
|
node.save()
|
||||||
params['liveimg_url'] = node.instance_info['image_url']
|
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']
|
params['agent_token'] = node.driver_internal_info['agent_secret_token']
|
||||||
|
|
||||||
heartbeat_url = '%s/v1/heartbeat/%s' % (
|
heartbeat_url = '%s/v1/heartbeat/%s' % (
|
||||||
deploy_utils.get_ironic_api_url().rstrip('/'),
|
deploy_utils.get_ironic_api_url().rstrip('/'),
|
||||||
node.uuid
|
node.uuid
|
||||||
|
@ -15,11 +15,24 @@ zerombr
|
|||||||
clearpart --all --initlabel
|
clearpart --all --initlabel
|
||||||
autopart
|
autopart
|
||||||
|
|
||||||
# Downloading and installing OS image using liveimg section is mandatory
|
# Downloading and installing OS image using "liveimg" section is the
|
||||||
# in a *default* ironic configuration. Users (infrastructure operators)
|
# 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
|
# may choose to customize this pattern, or use release specific kickstart
|
||||||
# configurations which may already point to a mirror.
|
# 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 }}
|
liveimg --url {{ ks_options.liveimg_url }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
# Following %pre and %onerror sections are mandatory
|
# Following %pre and %onerror sections are mandatory
|
||||||
%pre
|
%pre
|
||||||
|
@ -1608,6 +1608,27 @@ class PXEBuildKickstartConfigOptionsTestCase(db_base.DbTestCase):
|
|||||||
self.assertTrue(params['ks_options'].pop('agent_token'))
|
self.assertTrue(params['ks_options'].pop('agent_token'))
|
||||||
self.assertEqual(expected, params['ks_options'])
|
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)
|
@mock.patch('ironic.common.utils.render_template', autospec=True)
|
||||||
def test_prepare_instance_kickstart_config_not_anaconda_boot(self,
|
def test_prepare_instance_kickstart_config_not_anaconda_boot(self,
|
||||||
render_mock):
|
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…
x
Reference in New Issue
Block a user