Improved templates_names method in fuel_agent
This change is to make it possible to find templates for both underline separated and dash separated profiles. 1) ubuntu_1204_x86_64 2) centos-65_x86_64 Change-Id: I5f730b35be67de83338fa3fc34df315929da49df Implements: blueprint image-based-provisioning
This commit is contained in:
parent
ab5f2860dd
commit
e2f469aad1
@ -93,8 +93,13 @@ class ConfigDriveScheme(object):
|
||||
return self._profile
|
||||
|
||||
def template_names(self, what):
|
||||
# such a complicated scheme is used to cover a range of profile names
|
||||
# which might be either dash or underline separated
|
||||
# ubuntu_1204_x86_64
|
||||
# centos-65_x86_64
|
||||
return [
|
||||
'%s_%s.jinja2' % (what, self._profile),
|
||||
'%s_%s.jinja2' % (what, self._profile.split('_')[0]),
|
||||
'%s_%s.jinja2' % (what, self._profile.split('-')[0]),
|
||||
'%s.jinja2' % what
|
||||
]
|
||||
|
@ -26,10 +26,12 @@ class TestConfigDriveScheme(test_base.BaseTestCase):
|
||||
self.cd_scheme = configdrive.ConfigDriveScheme()
|
||||
|
||||
def test_template_names(self):
|
||||
self.cd_scheme._profile = 'pro_fi-le'
|
||||
actual = self.cd_scheme.template_names('what')
|
||||
expected = [
|
||||
'what_%s.jinja2' % self.cd_scheme._profile,
|
||||
'what_%s.jinja2' % self.cd_scheme._profile.split('_')[0],
|
||||
'what_pro_fi-le.jinja2',
|
||||
'what_pro.jinja2',
|
||||
'what_pro_fi.jinja2',
|
||||
'what.jinja2'
|
||||
]
|
||||
self.assertEqual(expected, actual)
|
||||
|
@ -142,18 +142,21 @@ class TestManager(test_base.BaseTestCase):
|
||||
self.mgr.do_configdrive()
|
||||
mock_u_ras_expected_calls = [
|
||||
mock.call(CONF.nc_template_path,
|
||||
['cloud_config_ubuntu_1204_x86_64.jinja2',
|
||||
'cloud_config_ubuntu.jinja2',
|
||||
['cloud_config_pro_fi-le.jinja2',
|
||||
'cloud_config_pro.jinja2',
|
||||
'cloud_config_pro_fi.jinja2',
|
||||
'cloud_config.jinja2'],
|
||||
mock.ANY, '%s/%s' % (CONF.tmp_path, 'cloud_config.txt')),
|
||||
mock.call(CONF.nc_template_path,
|
||||
['boothook_ubuntu_1204_x86_64.jinja2',
|
||||
'boothook_ubuntu.jinja2',
|
||||
['boothook_pro_fi-le.jinja2',
|
||||
'boothook_pro.jinja2',
|
||||
'boothook_pro_fi.jinja2',
|
||||
'boothook.jinja2'],
|
||||
mock.ANY, '%s/%s' % (CONF.tmp_path, 'boothook.txt')),
|
||||
mock.call(CONF.nc_template_path,
|
||||
['meta-data_ubuntu_1204_x86_64.jinja2',
|
||||
'meta-data_ubuntu.jinja2',
|
||||
['meta-data_pro_fi-le.jinja2',
|
||||
'meta-data_pro.jinja2',
|
||||
'meta-data_pro_fi.jinja2',
|
||||
'meta-data.jinja2'],
|
||||
mock.ANY, '%s/%s' % (CONF.tmp_path, 'meta-data'))]
|
||||
self.assertEqual(mock_u_ras_expected_calls, mock_u_ras.call_args_list)
|
||||
|
@ -40,7 +40,7 @@ CEPH_DATA = {
|
||||
"size": 3333
|
||||
}
|
||||
PROVISION_SAMPLE_DATA = {
|
||||
"profile": "ubuntu_1204_x86_64",
|
||||
"profile": "pro_fi-le",
|
||||
"name_servers_search": "\"domain.tld\"",
|
||||
"uid": "1",
|
||||
"interfaces": {
|
||||
@ -467,7 +467,7 @@ class TestNailgun(test_base.BaseTestCase):
|
||||
self.assertEqual('mcollective', cd_scheme.mcollective.user)
|
||||
self.assertEqual('marionette', cd_scheme.mcollective.password)
|
||||
self.assertEqual('rabbitmq', cd_scheme.mcollective.connector)
|
||||
self.assertEqual('ubuntu_1204_x86_64', cd_scheme.profile)
|
||||
self.assertEqual('pro_fi-le', cd_scheme.profile)
|
||||
self.assertEqual({'repo1': 'repo1_url', 'repo2': 'repo2_url'},
|
||||
cd_scheme.common.ks_repos)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user