Browse Source

Merge "Fix pathing for container image prepare"

changes/51/749051/4
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
e5708c780c
2 changed files with 55 additions and 4 deletions
  1. +43
    -1
      tripleoclient/tests/v1/test_container_image.py
  2. +12
    -3
      tripleoclient/v1/container_image.py

+ 43
- 1
tripleoclient/tests/v1/test_container_image.py View File

@@ -28,6 +28,7 @@ from osc_lib import exceptions as oscexc
from six.moves.urllib import parse
from tripleo_common.image import image_uploader
from tripleo_common.image import kolla_builder
from tripleoclient import constants
from tripleoclient.tests.v1.test_plugin import TestPluginV1
from tripleoclient.v1 import container_image

@@ -825,7 +826,7 @@ class TestTripleoImagePrepare(TestPluginV1):
verifylist = []

self.app.command_options = [
'tripleo', 'container', 'image', 'prepare', 'default'
'tripleo', 'container', 'image', 'prepare'
] + arglist

parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -844,6 +845,47 @@ class TestTripleoImagePrepare(TestPluginV1):
playbook_dir='/usr/share/ansible/tripleo-playbooks',
verbosity=3, workdir=mock.ANY)

@mock.patch('tripleoclient.utils.rel_or_abs_path')
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_tripleo_container_image_prepare_paths(self, mock_playbook,
mock_path):
arglist = ['-e', 'foo.yaml',
'-e', '/bar.yaml',
'--environment-directory', 'foo',
'--environment-directory', '/bar',
'-r', 'foo.yaml']
verifylist = []
self.app.command_options = [
'tripleo', 'container', 'image', 'prepare'
] + arglist

mock_path.return_value = ('/usr/share/openstack-tripleo-heat-templates'
'/foo.yaml')

parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
e_vars = {'roles_file': ('/usr/share/'
'openstack-tripleo-heat-templates/foo.yaml'),
'environment_directories': [
os.path.expanduser(constants.DEFAULT_ENV_DIRECTORY),
os.getcwd() + '/foo',
'/bar'
],
'environment_files': [
os.getcwd() + '/foo.yaml',
'/bar.yaml'
],
'cleanup': 'full', 'dry_run': False,
'log_file': 'container_image_prepare.log', 'debug': True}

mock_playbook.assert_called_with(
extra_vars=e_vars,
inventory='localhost,',
playbook='cli-container-image-prepare.yaml',
playbook_dir='/usr/share/ansible/tripleo-playbooks',
verbosity=3, workdir=mock.ANY)


class TestTripleoImagePrepareDefault(TestPluginV1):



+ 12
- 3
tripleoclient/v1/container_image.py View File

@@ -1054,10 +1054,19 @@ class TripleOImagePrepare(command.Command):
if parsed_args.cleanup not in image_uploader.CLEANUP:
raise oscexc.CommandError('--cleanup must be one of: %s' %
', '.join(image_uploader.CLEANUP))

role_file = None
if parsed_args.roles_file:
role_file = utils.rel_or_abs_path(parsed_args.roles_file,
constants.TRIPLEO_HEAT_TEMPLATES)
env_dirs = [os.path.abspath(x)
for x in parsed_args.environment_directories]
env_files = [os.path.abspath(x)
for x in parsed_args.environment_files]
extra_vars = {
"roles_file": parsed_args.roles_file,
"environment_directories": parsed_args.environment_directories,
"environment_files": parsed_args.environment_files,
"roles_file": role_file,
"environment_directories": env_dirs,
"environment_files": env_files,
"cleanup": parsed_args.cleanup,
"dry_run": parsed_args.dry_run,
"log_file": parsed_args.log_file}


Loading…
Cancel
Save