From b10ca31475ab2c62c64ed3145199b67d09fba4e4 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 10 Jul 2018 16:44:49 -0500 Subject: [PATCH] Switch the undercloud to be containerized by default The undercloud is now by default containerized and the deployment is not driven by instack-undercloud anymore but by TripleO Heat Templates like it's done for the overcloud. Note: if the undercloud isn't containerized and we don't support upgrades from Queens at this point. Depends-On: I910b15f78dc5a10e304d5aaf249516c56c82f6d0 Change-Id: I9e754a7efff4113c50c0c825d58461e6bc94aa24 --- .../use_heat_default-366fe9593a72642a.yaml | 10 ++ .../tests/v1/undercloud/test_undercloud.py | 125 +++++++++++++++--- tripleoclient/v1/undercloud.py | 12 +- 3 files changed, 121 insertions(+), 26 deletions(-) create mode 100644 releasenotes/notes/use_heat_default-366fe9593a72642a.yaml diff --git a/releasenotes/notes/use_heat_default-366fe9593a72642a.yaml b/releasenotes/notes/use_heat_default-366fe9593a72642a.yaml new file mode 100644 index 000000000..ad4c2d34f --- /dev/null +++ b/releasenotes/notes/use_heat_default-366fe9593a72642a.yaml @@ -0,0 +1,10 @@ +--- +prelude: > + The undercloud is now by default containerized and the deployment + is not driven by instack-undercloud anymore but by TripleO Heat Templates + like it's done for the overcloud. +upgrade: + - | + The upgrade from a non-containerized undercloud to a containerized + undercloud is supported and can be executed with ``openstack undercloud + upgrade`` command (same as before). diff --git a/tripleoclient/tests/v1/undercloud/test_undercloud.py b/tripleoclient/tests/v1/undercloud/test_undercloud.py index ddaf58f01..8e2024c88 100644 --- a/tripleoclient/tests/v1/undercloud/test_undercloud.py +++ b/tripleoclient/tests/v1/undercloud/test_undercloud.py @@ -47,16 +47,68 @@ class TestUndercloudInstall(TestPluginV1): app_args.verbose_level = 1 self.cmd = undercloud.InstallUndercloud(self.app, app_args) + # TODO(cjeanner) drop once we have proper oslo.privsep + @mock.patch('getpass.getuser', return_value='stack') + @mock.patch('six.moves.builtins.open') + @mock.patch('shutil.copy') + @mock.patch('os.mkdir') + @mock.patch('tripleoclient.utils.write_env_file', autospec=True) @mock.patch('subprocess.check_call', autospec=True) - def test_undercloud_install_default(self, mock_subprocess): - arglist = [] + def test_undercloud_install_default(self, mock_subprocess, + mock_wr, + mock_os, mock_copy, + mock_open, mock_user): + arglist = ['--no-validations'] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # DisplayCommandBase.take_action() returns two tuples self.cmd.take_action(parsed_args) - mock_subprocess.assert_called_with(['instack-install-undercloud']) + mock_subprocess.assert_called_with( + ['sudo', 'openstack', 'tripleo', 'deploy', '--standalone', + '--standalone-role', 'Undercloud', '--stack', 'undercloud', + '--local-domain=localdomain', + '--local-ip=192.168.24.1/24', + '--templates=/usr/share/openstack-tripleo-heat-templates/', + '--heat-native', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'docker.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'undercloud.yaml', '-e', '/home/stack/foo.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic.yaml', + '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic-inspector.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/mistral.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/zaqar.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tripleo-ui.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tempest.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'public-tls-undercloud.yaml', + '--public-virtual-ip', '192.168.24.2', + '--control-virtual-ip', '192.168.24.3', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'ssl/tls-endpoints-public-ip.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'use-dns-for-vips.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-haproxy.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-keepalived.yaml', + # TODO(cjeanner) drop once we have proper oslo.privsep + '--deployment-user', 'stack', + '--output-dir=/home/stack', '--cleanup', + '-e', '/home/stack/tripleo-config-generated-env-files/' + 'undercloud_parameters.yaml', + '--log-file=install-undercloud.log', '-e', + '/usr/share/openstack-tripleo-heat-templates/' + 'undercloud-stack-vstate-dropin.yaml']) @mock.patch('subprocess.check_call', autospec=True) def test_undercloud_install_with_heat_disabled(self, mock_subprocess): @@ -502,28 +554,69 @@ class TestUndercloudUpgrade(TestPluginV1): app_args.verbose_level = 1 self.cmd = undercloud.UpgradeUndercloud(self.app, app_args) + # TODO(cjeanner) drop once we have proper oslo.privsep + @mock.patch('getpass.getuser', return_value='stack') + @mock.patch('shutil.copy') @mock.patch('os.mkdir') @mock.patch('tripleoclient.utils.write_env_file', autospec=True) @mock.patch('subprocess.check_call', autospec=True) - def test_undercloud_upgrade_default(self, mock_subprocess, mock_wr, - mock_os): - arglist = [] + def test_undercloud_upgrade_default(self, mock_subprocess, + mock_wr, + mock_os, mock_copy, mock_user): + arglist = ['--no-validations'] verifylist = [] parsed_args = self.check_parser(self.cmd, arglist, verifylist) # DisplayCommandBase.take_action() returns two tuples self.cmd.take_action(parsed_args) - mock_subprocess.assert_has_calls( - [ - mock.call(['sudo', 'yum', 'update', '-y', - 'instack-undercloud']), - mock.call('instack-pre-upgrade-undercloud'), - mock.call('instack-upgrade-undercloud'), - mock.call(['sudo', 'systemctl', 'restart', - 'openstack-nova-api']) - ] - ) + mock_subprocess.assert_called_with( + ['sudo', 'openstack', 'tripleo', 'deploy', '--standalone', + '--standalone-role', 'Undercloud', '--stack', 'undercloud', + '--local-domain=localdomain', + '--local-ip=192.168.24.1/24', + '--templates=/usr/share/openstack-tripleo-heat-templates/', + '--upgrade', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'lifecycle/undercloud-upgrade-prepare.yaml', + '--heat-native', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'docker.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'undercloud.yaml', '-e', '/home/stack/foo.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic.yaml', + '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic-inspector.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/mistral.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/zaqar.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tripleo-ui.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tempest.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'public-tls-undercloud.yaml', + '--public-virtual-ip', '192.168.24.2', + '--control-virtual-ip', '192.168.24.3', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'ssl/tls-endpoints-public-ip.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'use-dns-for-vips.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-haproxy.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-keepalived.yaml', + # TODO(cjeanner) drop once we have proper oslo.privsep + '--deployment-user', 'stack', + '--output-dir=/home/stack', '--cleanup', + '-e', '/home/stack/tripleo-config-generated-env-files/' + 'undercloud_parameters.yaml', + '--log-file=install-undercloud.log', '-e', + '/usr/share/openstack-tripleo-heat-templates/' + 'undercloud-stack-vstate-dropin.yaml']) @mock.patch('os.mkdir') @mock.patch('tripleoclient.utils.write_env_file', autospec=True) diff --git a/tripleoclient/v1/undercloud.py b/tripleoclient/v1/undercloud.py index 1cbdf2438..a6a31b61b 100644 --- a/tripleoclient/v1/undercloud.py +++ b/tripleoclient/v1/undercloud.py @@ -132,11 +132,7 @@ class InstallUndercloud(command.Command): utils.ensure_run_as_normal_user() if parsed_args.use_heat is not None: self.log.warning('--use-heat is deprecated in Rocky') - # NOTE(EmilienM): For backwards compatibility until CI has been - # switched we need to still run instack-undercloud when --use-heat - # is not provided. This will be removed in a follow up patch - # once CI has been converted to pass in --use-heat=False - if parsed_args.use_heat is None or \ + if parsed_args.use_heat is not None and \ parsed_args.use_heat.lower() == "false": self.log.warning(_('Non-containerized undercloud deployment is ' 'deprecated in Rocky cycle.')) @@ -183,11 +179,7 @@ class UpgradeUndercloud(InstallUndercloud): utils.ensure_run_as_normal_user() if parsed_args.use_heat is not None: self.log.warning('--use-heat is deprecated in Rocky') - # NOTE(EmilienM): For backwards compatibility until CI has been - # switched we need to still run instack-undercloud when --use-heat - # is not provided. This will be removed in a follow up patch - # once CI has been converted to pass in --use-heat=False - if parsed_args.use_heat is None or \ + if parsed_args.use_heat is not None and \ parsed_args.use_heat.lower() == "false": self.log.warning(_('Non-containerized undercloud deployment is ' 'deprecated in Rocky cycle.'))