From a55573f20a14245526b3abd430754069751e1382 Mon Sep 17 00:00:00 2001 From: Janki Chhatbar Date: Thu, 2 May 2019 17:06:30 +0530 Subject: [PATCH] Add ODL deprecation warning in CLI ODL is deprecated since Rocky. Add a warning before deployment asking the user if he wants to continue with deployment even after deprecation. The logic is to check for neutron-opendaylight.yaml environment file passed to overcloud deploy command. If yes, ask for user confirmation before starting deployment. Change-Id: I1b16aab11591fac610cd4bf49a0927f1ec947146 Closes-Bug: #1827366 (cherry picked from commit 1fee54b9be6e877040a7d62183d72a35948767e0) --- tripleoclient/constants.py | 10 ++++++++ tripleoclient/utils.py | 37 +++++++++++++++++++++++++++ tripleoclient/v1/overcloud_deploy.py | 6 +++++ tripleoclient/v1/overcloud_update.py | 6 +++++ tripleoclient/v1/overcloud_upgrade.py | 7 +++++ 5 files changed, 66 insertions(+) diff --git a/tripleoclient/constants.py b/tripleoclient/constants.py index b3c043cb3..d27fab0d3 100644 --- a/tripleoclient/constants.py +++ b/tripleoclient/constants.py @@ -104,3 +104,13 @@ DEPLOY_ANSIBLE_ACTIONS = { 'online-upgrade': 'external_upgrade_steps_playbook.yaml ' '--tags online_upgrade', } + +# Key-value pair of deprecated service and its warning message +DEPRECATED_SERVICES = {"OS::TripleO::Services::OpenDaylightApi": + "You are using OpenDaylight as your networking" + " driver for OpenStack. OpenDaylight is deprecated" + " starting from Rocky and removed since Stein and " + "there is no upgrade or migration path from " + "OpenDaylight to another networking backend. We " + "recommend you understand other networking " + "alternatives such as OVS or OVN. "} diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 4a974994d..5fd3b98f1 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -41,6 +41,7 @@ from heatclient.common import event_utils from heatclient.common import template_utils from heatclient.common import utils as heat_utils from heatclient.exc import HTTPNotFound +from osc_lib import exceptions as oscexc from osc_lib.i18n import _ from oslo_concurrency import processutils from six.moves import configparser @@ -1715,3 +1716,39 @@ def ansible_symlink(): cmd.extend(['/usr/bin/ansible-playbook', '/usr/bin/' + ansible_playbook_cmd]) run_command(cmd, name='ansible-playbook-3-symlink') + + +def check_file_for_enabled_service(env_file): + # This function checks environment file for the said service. + # If stack to be deployed/updated/upgraded has any deprecated service + # enabled, throw a warning about its deprecation and ask the user + # whether to proceed with deployment despite deprecation. + # For ODL as an example: + # If "OS::TripleO::Services::OpenDaylightApi" service is included + # in any of the parsed env_files, then check its value. + # OS::TripleO::Services::OpenDaylightApi NOT OS::Heat::None + # ODL is enabled. + + if os.path.exists(env_file): + content = yaml.load(open(env_file)) + deprecated_services_enabled = [] + for service in constants.DEPRECATED_SERVICES.keys(): + if ("resource_registry" in content and + service in content["resource_registry"]): + if content["resource_registry"][service] != "OS::Heat::None": + LOG.warn("service " + service + " is enabled in " + + str(env_file) + ". " + + constants.DEPRECATED_SERVICES[service]) + deprecated_services_enabled.append(service) + + if deprecated_services_enabled: + confirm = prompt_user_for_confirmation( + message="Do you still wish to continue with deployment [y/N]", + logger=LOG) + if not confirm: + raise oscexc.CommandError("Action not confirmed, exiting.") + + +def check_deprecated_service_is_enabled(environment_files): + for env_file in environment_files: + check_file_for_enabled_service(env_file) diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 11defe1f0..6d3ef4f27 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -875,6 +875,12 @@ class DeployOvercloud(command.Command): self._validate_args(parsed_args) + # Throw warning if deprecated service is enabled and + # ask user if deployment should still be continued. + if parsed_args.environment_files: + utils.check_deprecated_service_is_enabled( + parsed_args.environment_files) + stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if stack and stack.stack_status == 'IN_PROGRESS': diff --git a/tripleoclient/v1/overcloud_update.py b/tripleoclient/v1/overcloud_update.py index 87b512b60..71aa292eb 100644 --- a/tripleoclient/v1/overcloud_update.py +++ b/tripleoclient/v1/overcloud_update.py @@ -64,6 +64,12 @@ class UpdatePrepare(DeployOvercloud): parsed_args.environment_files, templates_dir, constants.UPDATE_PREPARE_ENV) + # Throw deprecation warning if service is enabled and + # ask user if update should still be continued. + if parsed_args.environment_files: + oooutils.check_deprecated_service_is_enabled( + parsed_args.environment_files) + super(UpdatePrepare, self).take_action(parsed_args) package_update.update(clients, container=stack_name) package_update.get_config(clients, container=stack_name) diff --git a/tripleoclient/v1/overcloud_upgrade.py b/tripleoclient/v1/overcloud_upgrade.py index f4f47dc9a..28d81325d 100644 --- a/tripleoclient/v1/overcloud_upgrade.py +++ b/tripleoclient/v1/overcloud_upgrade.py @@ -47,6 +47,13 @@ class UpgradePrepare(DeployOvercloud): def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) + + # Throw deprecation warning if service is enabled and + # ask user if upgrade should still be continued. + if parsed_args.environment_files: + oooutils.check_deprecated_service_is_enabled( + parsed_args.environment_files) + clients = self.app.client_manager stack = oooutils.get_stack(clients.orchestration,