From b942e8db03db330c4059daf535707eabce11dd79 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Thu, 29 Oct 2020 08:50:33 -0600 Subject: [PATCH] Ensure build packages installed at runtime As an alternative to switching this process to ansible, we can handle the installation of the required packages for the overcloud image building process in the command itself. This change adds an install for tripleo-common and the image element packages required to build the overcloud images as part of the `openstack overcloud image build` command itself. Change-Id: I32eb04c81cba0f9688ddf6e40874790f033e84e8 --- ...ges-for-overcloud-images-e3eacb9e0ec53b5b.yaml | 8 ++++++++ .../v1/overcloud_image/test_overcloud_image.py | 6 ++++++ tripleoclient/v1/overcloud_image.py | 15 +++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 releasenotes/notes/install-packages-for-overcloud-images-e3eacb9e0ec53b5b.yaml diff --git a/releasenotes/notes/install-packages-for-overcloud-images-e3eacb9e0ec53b5b.yaml b/releasenotes/notes/install-packages-for-overcloud-images-e3eacb9e0ec53b5b.yaml new file mode 100644 index 000000000..e46d1409e --- /dev/null +++ b/releasenotes/notes/install-packages-for-overcloud-images-e3eacb9e0ec53b5b.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + A dnf installation of tripleo-common, tripleo-ironic-python-agent-builder, + openstack-tripleo-image-elements, openstack-tripleo-puppet-elements, and + xfsprogs has been included as part of the `openstack overcloud image build` + command. This allows us to drop these as always required dependencies for + tripleoclient. diff --git a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py index 994dc86a0..8a35564bf 100644 --- a/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py +++ b/tripleoclient/tests/v1/overcloud_image/test_overcloud_image.py @@ -31,6 +31,9 @@ class TestOvercloudImageBuild(TestPluginV1): def setUp(self): super(TestOvercloudImageBuild, self).setUp() + run_cmd = mock.patch('tripleoclient.utils.run_command') + self.mock_run_command = run_cmd.start() + self.addCleanup(run_cmd.stop) # Get the command object to test self.cmd = overcloud_image.BuildOvercloudImage(self.app, None) @@ -51,6 +54,9 @@ class TestOvercloudImageBuild(TestPluginV1): output_directory='.', skip=True, images=None) + cmd = ['sudo', 'dnf', 'install', '-y'] + self.cmd.REQUIRED_PACKAGES + self.mock_run_command.assert_called_once_with( + cmd, name="Install required packages") @mock.patch('tripleo_common.image.build.ImageBuildManager', autospec=True) def test_overcloud_image_build_yaml(self, mock_manager): diff --git a/tripleoclient/v1/overcloud_image.py b/tripleoclient/v1/overcloud_image.py index 0ad9b64b8..33341e996 100644 --- a/tripleoclient/v1/overcloud_image.py +++ b/tripleoclient/v1/overcloud_image.py @@ -44,6 +44,13 @@ class BuildOvercloudImage(command.Command): IMAGE_YAML_PATH = "/usr/share/openstack-tripleo-common/image-yaml" DEFAULT_YAML = ['overcloud-images-python3.yaml', 'overcloud-images-centos8.yaml'] + REQUIRED_PACKAGES = [ + 'openstack-tripleo-common', + 'openstack-ironic-python-agent-builder', + 'openstack-tripleo-image-elements', + 'openstack-tripleo-puppet-elements', + 'xfsprogs' + ] def get_parser(self, prog_name): parser = super(BuildOvercloudImage, self).get_parser(prog_name) @@ -90,9 +97,17 @@ class BuildOvercloudImage(command.Command): ) return parser + def _ensure_packages_installed(self): + cmd = ['sudo', 'dnf', 'install', '-y'] + self.REQUIRED_PACKAGES + output = plugin_utils.run_command(cmd, + name="Install required packages") + self.log.info(output) + def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) + self._ensure_packages_installed() + if not parsed_args.config_files: parsed_args.config_files = [os.path.join(self.IMAGE_YAML_PATH, f) for f in self.DEFAULT_YAML]