Merge "Add users container images file into tarball"
This commit is contained in:
commit
207673e393
|
@ -58,13 +58,14 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
|
|
||||||
mock_subprocess.assert_called_with(['instack-install-undercloud'])
|
mock_subprocess.assert_called_with(['instack-install-undercloud'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_install_with_heat_custom_output(self, mock_subprocess,
|
def test_undercloud_install_with_heat_custom_output(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr,
|
mock_cwd, mock_wr,
|
||||||
mock_os):
|
mock_os, mock_copy):
|
||||||
self.conf.config(output_dir='/foo')
|
self.conf.config(output_dir='/foo')
|
||||||
self.conf.config(roles_file='foo/roles.yaml')
|
self.conf.config(roles_file='foo/roles.yaml')
|
||||||
arglist = ['--use-heat', '--no-validations']
|
arglist = ['--use-heat', '--no-validations']
|
||||||
|
@ -74,7 +75,11 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
# DisplayCommandBase.take_action() returns two tuples
|
# DisplayCommandBase.take_action() returns two tuples
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
mock_os.assert_called_with('/foo/tripleo-config-generated-env-files')
|
mock_os.assert_has_calls(
|
||||||
|
[
|
||||||
|
mock.call('/foo/tripleo-config-generated-env-files'),
|
||||||
|
mock.call('/foo')
|
||||||
|
])
|
||||||
mock_subprocess.assert_called_with(
|
mock_subprocess.assert_called_with(
|
||||||
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
|
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
|
||||||
'--standalone-role', 'Undercloud',
|
'--standalone-role', 'Undercloud',
|
||||||
|
@ -117,6 +122,7 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
'undercloud_parameters.yaml',
|
'undercloud_parameters.yaml',
|
||||||
'--log-file=/tmp/install-undercloud.log'])
|
'--log-file=/tmp/install-undercloud.log'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('tripleoclient.v1.undercloud_config.'
|
@mock.patch('tripleoclient.v1.undercloud_config.'
|
||||||
|
@ -137,7 +143,8 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
mock_get_j2,
|
mock_get_j2,
|
||||||
mock_sroutes,
|
mock_sroutes,
|
||||||
mock_masq,
|
mock_masq,
|
||||||
mock_wr, mock_os):
|
mock_wr, mock_os,
|
||||||
|
mock_copy):
|
||||||
self.conf.config(net_config_override='/foo/net-config.json')
|
self.conf.config(net_config_override='/foo/net-config.json')
|
||||||
self.conf.config(local_interface='ethX')
|
self.conf.config(local_interface='ethX')
|
||||||
self.conf.config(undercloud_public_host='4.3.2.1')
|
self.conf.config(undercloud_public_host='4.3.2.1')
|
||||||
|
@ -277,13 +284,14 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
'undercloud_parameters.yaml',
|
'undercloud_parameters.yaml',
|
||||||
'--log-file=/tmp/install-undercloud.log'])
|
'--log-file=/tmp/install-undercloud.log'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_install_with_heat_and_debug(self, mock_subprocess,
|
def test_undercloud_install_with_heat_and_debug(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr,
|
mock_cwd, mock_wr,
|
||||||
mock_os):
|
mock_os, mock_copy):
|
||||||
arglist = ['--use-heat', '--no-validations']
|
arglist = ['--use-heat', '--no-validations']
|
||||||
verifylist = []
|
verifylist = []
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
@ -335,13 +343,14 @@ class TestUndercloudInstall(TestPluginV1):
|
||||||
'undercloud_parameters.yaml',
|
'undercloud_parameters.yaml',
|
||||||
'--debug', '--log-file=/tmp/install-undercloud.log'])
|
'--debug', '--log-file=/tmp/install-undercloud.log'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_install_with_swift_encryption(self, mock_subprocess,
|
def test_undercloud_install_with_swift_encryption(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr,
|
mock_cwd, mock_wr,
|
||||||
mock_os):
|
mock_os, mock_copy):
|
||||||
arglist = ['--use-heat', '--no-validations']
|
arglist = ['--use-heat', '--no-validations']
|
||||||
verifylist = []
|
verifylist = []
|
||||||
self.conf.set_default('enable_swift_encryption', True)
|
self.conf.set_default('enable_swift_encryption', True)
|
||||||
|
@ -430,12 +439,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_upgrade_with_heat(self, mock_subprocess,
|
def test_undercloud_upgrade_with_heat(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr, mock_os):
|
mock_cwd, mock_wr,
|
||||||
|
mock_os, mock_copy):
|
||||||
arglist = ['--use-heat', '--no-validations']
|
arglist = ['--use-heat', '--no-validations']
|
||||||
verifylist = []
|
verifylist = []
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
@ -487,12 +498,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
||||||
'undercloud_parameters.yaml',
|
'undercloud_parameters.yaml',
|
||||||
'--log-file=/tmp/install-undercloud.log'])
|
'--log-file=/tmp/install-undercloud.log'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_upgrade_with_heat_and_yes(self, mock_subprocess,
|
def test_undercloud_upgrade_with_heat_and_yes(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr, mock_os):
|
mock_cwd, mock_wr,
|
||||||
|
mock_os, mock_copy):
|
||||||
arglist = ['--use-heat', '--no-validations', '-y']
|
arglist = ['--use-heat', '--no-validations', '-y']
|
||||||
verifylist = []
|
verifylist = []
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
@ -544,13 +557,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
||||||
'undercloud_parameters.yaml',
|
'undercloud_parameters.yaml',
|
||||||
'--log-file=/tmp/install-undercloud.log'])
|
'--log-file=/tmp/install-undercloud.log'])
|
||||||
|
|
||||||
|
@mock.patch('shutil.copy')
|
||||||
@mock.patch('os.mkdir')
|
@mock.patch('os.mkdir')
|
||||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||||
@mock.patch('os.getcwd', return_value='/tmp')
|
@mock.patch('os.getcwd', return_value='/tmp')
|
||||||
@mock.patch('subprocess.check_call', autospec=True)
|
@mock.patch('subprocess.check_call', autospec=True)
|
||||||
def test_undercloud_upgrade_with_heat_and_debug(self, mock_subprocess,
|
def test_undercloud_upgrade_with_heat_and_debug(self, mock_subprocess,
|
||||||
mock_cwd, mock_wr,
|
mock_cwd, mock_wr,
|
||||||
mock_os):
|
mock_os, mock_copy):
|
||||||
arglist = ['--use-heat', '--no-validations']
|
arglist = ['--use-heat', '--no-validations']
|
||||||
verifylist = []
|
verifylist = []
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
|
@ -253,7 +253,8 @@ class TestContainerImageConfig(base.TestCase):
|
||||||
self.conf = mock.Mock(**{key: getattr(undercloud_config.CONF, key)
|
self.conf = mock.Mock(**{key: getattr(undercloud_config.CONF, key)
|
||||||
for key in conf_keys})
|
for key in conf_keys})
|
||||||
|
|
||||||
def test_defaults(self):
|
@mock.patch('shutil.copy')
|
||||||
|
def test_defaults(self, mock_copy):
|
||||||
env = {}
|
env = {}
|
||||||
deploy_args = []
|
deploy_args = []
|
||||||
cip_default = getattr(kolla_builder,
|
cip_default = getattr(kolla_builder,
|
||||||
|
@ -271,7 +272,8 @@ class TestContainerImageConfig(base.TestCase):
|
||||||
'tag_from_label': 'five',
|
'tag_from_label': 'five',
|
||||||
}])
|
}])
|
||||||
|
|
||||||
undercloud_config._container_images_config(self.conf, deploy_args, env)
|
undercloud_config._container_images_config(self.conf, deploy_args,
|
||||||
|
env, None)
|
||||||
self.assertEqual([], deploy_args)
|
self.assertEqual([], deploy_args)
|
||||||
cip = env['ContainerImagePrepare'][0]
|
cip = env['ContainerImagePrepare'][0]
|
||||||
set = cip['set']
|
set = cip['set']
|
||||||
|
@ -287,16 +289,19 @@ class TestContainerImageConfig(base.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'five', cip['tag_from_label'])
|
'five', cip['tag_from_label'])
|
||||||
|
|
||||||
def test_container_images_file(self):
|
@mock.patch('shutil.copy')
|
||||||
|
def test_container_images_file(self, mock_copy):
|
||||||
env = {}
|
env = {}
|
||||||
deploy_args = []
|
deploy_args = []
|
||||||
self.conf.container_images_file = '/tmp/container_images_file.yaml'
|
self.conf.container_images_file = '/tmp/container_images_file.yaml'
|
||||||
undercloud_config._container_images_config(self.conf, deploy_args, env)
|
undercloud_config._container_images_config(self.conf, deploy_args,
|
||||||
|
env, None)
|
||||||
self.assertEqual(['-e', '/tmp/container_images_file.yaml'],
|
self.assertEqual(['-e', '/tmp/container_images_file.yaml'],
|
||||||
deploy_args)
|
deploy_args)
|
||||||
self.assertEqual({}, env)
|
self.assertEqual({}, env)
|
||||||
|
|
||||||
def test_custom(self):
|
@mock.patch('shutil.copy')
|
||||||
|
def test_custom(self, mock_copy):
|
||||||
env = {}
|
env = {}
|
||||||
deploy_args = []
|
deploy_args = []
|
||||||
with tempfile.NamedTemporaryFile(mode='w') as f:
|
with tempfile.NamedTemporaryFile(mode='w') as f:
|
||||||
|
@ -315,5 +320,5 @@ class TestContainerImageConfig(base.TestCase):
|
||||||
cif_name = f.name
|
cif_name = f.name
|
||||||
|
|
||||||
undercloud_config._container_images_config(
|
undercloud_config._container_images_config(
|
||||||
self.conf, deploy_args, env)
|
self.conf, deploy_args, env, None)
|
||||||
self.assertEqual(['-e', cif_name], deploy_args)
|
self.assertEqual(['-e', cif_name], deploy_args)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import netaddr
|
import netaddr
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
|
@ -266,6 +267,15 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
|
||||||
_load_config()
|
_load_config()
|
||||||
_load_subnets_config_groups()
|
_load_subnets_config_groups()
|
||||||
|
|
||||||
|
# NOTE(bogdando): the generated env files are stored another path then
|
||||||
|
# picked up later.
|
||||||
|
# NOTE(aschultz): We copy this into the tht root that we save because
|
||||||
|
# we move any user provided environment files into this root later.
|
||||||
|
tempdir = os.path.join(os.path.abspath(CONF['output_dir']),
|
||||||
|
'tripleo-config-generated-env-files')
|
||||||
|
if not os.path.isdir(tempdir):
|
||||||
|
os.mkdir(tempdir)
|
||||||
|
|
||||||
# Set the undercloud home dir parameter so that stackrc is produced in
|
# Set the undercloud home dir parameter so that stackrc is produced in
|
||||||
# the users home directory.
|
# the users home directory.
|
||||||
env_data['UndercloudHomeDir'] = USER_HOME
|
env_data['UndercloudHomeDir'] = USER_HOME
|
||||||
|
@ -348,7 +358,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
|
||||||
"-e", os.path.join(tht_templates, "environments/docker.yaml"),
|
"-e", os.path.join(tht_templates, "environments/docker.yaml"),
|
||||||
"-e", os.path.join(tht_templates, "environments/undercloud.yaml")]
|
"-e", os.path.join(tht_templates, "environments/undercloud.yaml")]
|
||||||
|
|
||||||
_container_images_config(CONF, deploy_args, env_data)
|
# If a container images file is used, copy it into the tempdir to make it
|
||||||
|
# later into other deployment artifacts and user-provided files.
|
||||||
|
_container_images_config(CONF, deploy_args, env_data, tempdir)
|
||||||
|
|
||||||
if env_data['MasqueradeNetworks']:
|
if env_data['MasqueradeNetworks']:
|
||||||
deploy_args += ['-e', os.path.join(
|
deploy_args += ['-e', os.path.join(
|
||||||
|
@ -526,15 +538,7 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
|
||||||
|
|
||||||
env_data['UndercloudNetConfigOverride'] = net_config_json
|
env_data['UndercloudNetConfigOverride'] = net_config_json
|
||||||
|
|
||||||
# NOTE(bogdando): the generated env files are stored another path then
|
|
||||||
# picked up later.
|
|
||||||
# NOTE(aschultz): We copy this into the tht root that we save because
|
|
||||||
# we move any user provided environment files into this root later.
|
|
||||||
tempdir = os.path.join(os.path.abspath(CONF['output_dir']),
|
|
||||||
'tripleo-config-generated-env-files')
|
|
||||||
params_file = os.path.join(tempdir, 'undercloud_parameters.yaml')
|
params_file = os.path.join(tempdir, 'undercloud_parameters.yaml')
|
||||||
if not os.path.isdir(tempdir):
|
|
||||||
os.mkdir(tempdir)
|
|
||||||
utils.write_env_file(env_data, params_file, registry_overwrites)
|
utils.write_env_file(env_data, params_file, registry_overwrites)
|
||||||
deploy_args += ['-e', params_file]
|
deploy_args += ['-e', params_file]
|
||||||
|
|
||||||
|
@ -610,9 +614,16 @@ def _get_public_tls_resource_registry_overwrites(enable_tls_yaml_path):
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
|
|
||||||
|
|
||||||
def _container_images_config(conf, deploy_args, env_data):
|
def _container_images_config(conf, deploy_args, env_data, tempdir):
|
||||||
if conf.container_images_file:
|
if conf.container_images_file:
|
||||||
deploy_args += ['-e', conf.container_images_file]
|
deploy_args += ['-e', conf.container_images_file]
|
||||||
|
try:
|
||||||
|
shutil.copy(os.path.abspath(conf.container_images_file), tempdir)
|
||||||
|
except Exception:
|
||||||
|
msg = _('Cannot copy a container images'
|
||||||
|
'file %s into a tempdir!') % conf.container_images_file
|
||||||
|
LOG.error(msg)
|
||||||
|
raise exceptions.DeploymentError(msg)
|
||||||
else:
|
else:
|
||||||
# no images file was provided. Set a default ContainerImagePrepare
|
# no images file was provided. Set a default ContainerImagePrepare
|
||||||
# parameter to trigger the preparation of the required container list
|
# parameter to trigger the preparation of the required container list
|
||||||
|
|
Loading…
Reference in New Issue