diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst new file mode 100644 index 000000000..02f244763 --- /dev/null +++ b/doc/source/cli/index.rst @@ -0,0 +1,11 @@ +======================== +Murano CLI Documentation +======================== + +In this section you will find information on Murano's command line +interface. + +.. toctree:: + :maxdepth: 1 + + murano-status diff --git a/doc/source/cli/murano-status.rst b/doc/source/cli/murano-status.rst new file mode 100644 index 000000000..28c2f5ff6 --- /dev/null +++ b/doc/source/cli/murano-status.rst @@ -0,0 +1,83 @@ +============= +murano-status +============= + +---------------------------------------- +CLI interface for Murano status commands +---------------------------------------- + +Synopsis +======== + +:: + + murano-status [] + +Description +=========== + +:program:`murano-status` is a tool that provides routines for checking the +status of a Murano deployment. + +Options +======= + +The standard pattern for executing a :program:`murano-status` command is:: + + murano-status [] + +Run without arguments to see a list of available command categories:: + + murano-status + +Categories are: + +* ``upgrade`` + +Detailed descriptions are below: + +You can also run with a category argument such as ``upgrade`` to see a list of +all commands in that category:: + + murano-status upgrade + +These sections describe the available categories and arguments for +:program:`murano-status`. + +Upgrade +~~~~~~~ + +.. _murano-status-checks: + +``murano-status upgrade check`` + Performs a release-specific readiness check before restarting services with + new code. For example, missing or changed configuration options, + incompatible object states, or other conditions that could lead to + failures while upgrading. + + **Return Codes** + + .. list-table:: + :widths: 20 80 + :header-rows: 1 + + * - Return code + - Description + * - 0 + - All upgrade readiness checks passed successfully and there is nothing + to do. + * - 1 + - At least one check encountered an issue and requires further + investigation. This is considered a warning but the upgrade may be OK. + * - 2 + - There was an upgrade status check failure that needs to be + investigated. This should be considered something that stops an + upgrade. + * - 255 + - An unexpected error occurred. + + **History of Checks** + + **7.0.0 (Stein)** + + * Sample check to be filled in with checks as they are added in Stein. diff --git a/doc/source/index.rst b/doc/source/index.rst index 6b7226730..babae481d 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -67,6 +67,14 @@ Configuration configuration/index +CLI Guide +~~~~~~~~~ + +.. toctree:: + :maxdepth: 2 + + cli/index + Administrator Documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lower-constraints.txt b/lower-constraints.txt index cff1b2c3b..4f2c91d86 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -78,6 +78,7 @@ oslo.middleware==3.31.0 oslo.policy==1.30.0 oslo.serialization==2.18.0 oslo.service==1.24.0 +oslo.upgradecheck==0.1.0 oslo.utils==3.33.0 oslotest==3.2.0 packaging==17.1 diff --git a/murano/cmd/status.py b/murano/cmd/status.py new file mode 100644 index 000000000..d4eed88eb --- /dev/null +++ b/murano/cmd/status.py @@ -0,0 +1,53 @@ +# Copyright (c) 2018 NEC, Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import sys + +from oslo_config import cfg +from oslo_upgradecheck import upgradecheck + +from murano.common.i18n import _ + +CONF = cfg.CONF + + +class Checks(upgradecheck.UpgradeCommands): + + """Contains upgrade checks + + Various upgrade checks should be added as separate methods in this class + and added to _upgrade_checks tuple. + """ + + def _sample_check(self): + """This is sample check added to test the upgrade check framework + + It needs to be removed after adding any real upgrade check + """ + return upgradecheck.Result(upgradecheck.Code.SUCCESS, 'Sample detail') + + _upgrade_checks = ( + # Sample check added for now. + # Whereas in future real checks must be added here in tuple + (_('Sample Check'), _sample_check), + ) + + +def main(): + return upgradecheck.main( + CONF, project='murano', upgrade_command=Checks()) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/murano/tests/unit/cmd/test_status.py b/murano/tests/unit/cmd/test_status.py new file mode 100644 index 000000000..f9cef9a1a --- /dev/null +++ b/murano/tests/unit/cmd/test_status.py @@ -0,0 +1,30 @@ +# Copyright (c) 2018 NEC, Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_upgradecheck.upgradecheck import Code + +from murano.cmd import status +from murano.tests.unit import base + + +class TestUpgradeChecks(base.MuranoTestCase): + + def setUp(self): + super(TestUpgradeChecks, self).setUp() + self.cmd = status.Checks() + + def test__sample_check(self): + check_result = self.cmd._sample_check() + self.assertEqual( + Code.SUCCESS, check_result.code) diff --git a/releasenotes/notes/add-upgrade-check-framework-1c069e5a54125d1b.yaml b/releasenotes/notes/add-upgrade-check-framework-1c069e5a54125d1b.yaml new file mode 100644 index 000000000..64d87ae34 --- /dev/null +++ b/releasenotes/notes/add-upgrade-check-framework-1c069e5a54125d1b.yaml @@ -0,0 +1,13 @@ +--- +prelude: > + Added new tool ``murano-status upgrade check``. +features: + - | + New framework for ``murano-status upgrade check`` command is added. + This framework allows adding various checks which can be run before a + Murano upgrade to ensure if the upgrade can be performed safely. +upgrade: + - | + Operator can now use new CLI tool ``murano-status upgrade check`` + to check if Murano deployment can be safely upgraded from + N-1 to N release. diff --git a/requirements.txt b/requirements.txt index 578d4ec97..e8795e971 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,5 +46,6 @@ oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0 +oslo.upgradecheck>=0.1.0 # Apache-2.0 semantic-version>=2.3.1 # BSD castellan>=0.16.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index b823bef63..c5fc427b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,7 @@ console_scripts = murano-cfapi-db-manage = murano.cmd.cfapi_db_manage:main murano-test-runner = murano.cmd.test_runner:main murano-cfapi = murano.cmd.cfapi:main + murano-status = murano.cmd.status:main wsgi_scripts = murano-wsgi-api = murano.httpd.murano_api:init_application