Add neutron-status upgrade check command framework
This adds basic framework for neutron-status upgrade check commands. For now it has only "check_nothing" check implemented. Real checks can be added to this tool in the future. Depends-On: https://review.openstack.org/#/c/610061/ Change-Id: Ib08119e1bb8de80856edb6a39769d4bc9d98c587 Story: 2003657 Task: 26144
This commit is contained in:
parent
c232f3686c
commit
152364dbc8
@ -10,3 +10,4 @@ Command-Line Interface Reference
|
||||
|
||||
neutron-debug
|
||||
neutron-sanity-check
|
||||
neutron-status
|
||||
|
61
doc/source/cli/neutron-status.rst
Normal file
61
doc/source/cli/neutron-status.rst
Normal file
@ -0,0 +1,61 @@
|
||||
.. This file is manually generated, unlike many of the other chapters.
|
||||
|
||||
==================================
|
||||
neutron-status command-line client
|
||||
==================================
|
||||
|
||||
The :command:`neutron-status` provides routines for checking the status of
|
||||
Neutron deployment.
|
||||
|
||||
.. _neutron-status_usage:
|
||||
|
||||
neutron-status usage
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
usage: neutron-status [-h] [--config-dir DIR] [--config-file PATH]
|
||||
<category> <command>
|
||||
|
||||
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::
|
||||
|
||||
neutron-status upgrade
|
||||
|
||||
These sections describe the available categories and arguments for
|
||||
:command:`neutron-status`.
|
||||
|
||||
Command details
|
||||
---------------
|
||||
|
||||
``neutron-status upgrade check``
|
||||
Performs a release-specific readiness check before restarting services
|
||||
with new code. This command expects to have complete configuration and access
|
||||
to databases and services.
|
||||
|
||||
**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.
|
@ -78,6 +78,7 @@ oslo.reports==1.18.0
|
||||
oslo.rootwrap==5.8.0
|
||||
oslo.serialization==2.18.0
|
||||
oslo.service==1.24.0
|
||||
oslo.upgradecheck==0.1.0
|
||||
oslo.utils==3.33.0
|
||||
oslo.versionedobjects==1.31.2
|
||||
oslosphinx==4.7.0
|
||||
|
53
neutron/cmd/status.py
Normal file
53
neutron/cmd/status.py
Normal file
@ -0,0 +1,53 @@
|
||||
# Copyright 2018 Red Hat Inc.
|
||||
#
|
||||
# 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_config import cfg
|
||||
from oslo_upgradecheck import upgradecheck
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
|
||||
class Checks(upgradecheck.UpgradeCommands):
|
||||
|
||||
"""Various upgrade checks should be added as separate methods in this class
|
||||
and added to _upgrade_checks tuple.
|
||||
|
||||
Check methods here must not rely on the neutron object model since they
|
||||
should be able to run against both N and N-1 releases. Any queries to
|
||||
the database should be done through the sqlalchemy query language directly
|
||||
like the database schema migrations.
|
||||
"""
|
||||
|
||||
def _check_nothing(self):
|
||||
# NOTE(slaweq) This is only example Noop check, it can be removed when
|
||||
# some real check methods will be added
|
||||
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
|
||||
|
||||
# The format of the check functions is to return an
|
||||
# oslo_upgradecheck.upgradecheck.Result
|
||||
# object with the appropriate
|
||||
# oslo_upgradecheck.upgradecheck.Code and details set.
|
||||
# If the check hits warnings or failures then those should be stored
|
||||
# in the returned Result's "details" attribute. The
|
||||
# summary will be rolled up at the end of the check() method.
|
||||
_upgrade_checks = (
|
||||
# Check nothing
|
||||
# In the future there should be some real checks added here
|
||||
(_('Check nothing'), _check_nothing),
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
return upgradecheck.main(
|
||||
cfg.CONF, project='neutron', upgrade_command=Checks())
|
29
neutron/tests/unit/cmd/test_status.py
Normal file
29
neutron/tests/unit/cmd/test_status.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2018 Red Hat Inc.
|
||||
#
|
||||
# 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 neutron.cmd import status
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestUpgradeChecks(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestUpgradeChecks, self).setUp()
|
||||
self.cmd = status.Checks()
|
||||
|
||||
def test__check_nothing(self):
|
||||
check_result = self.cmd._check_nothing()
|
||||
self.assertEqual(Code.SUCCESS, check_result.code)
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
prelude: >
|
||||
Add new tool ``neutron-status upgrade check``.
|
||||
features:
|
||||
- |
|
||||
New framework for ``neutron-status upgrade check`` command is added.
|
||||
This framework allows adding various checks which can be run before a
|
||||
Neutron upgrade to ensure if the upgrade can be performed safely.
|
||||
upgrade:
|
||||
- |
|
||||
Operator can now use new CLI tool ``neutron-status upgrade check``
|
||||
to check if Neutron deployment can be safely upgraded from
|
||||
N-1 to N release.
|
@ -40,6 +40,7 @@ oslo.reports>=1.18.0 # Apache-2.0
|
||||
oslo.rootwrap>=5.8.0 # Apache-2.0
|
||||
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
|
||||
oslo.upgradecheck>=0.1.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
oslo.versionedobjects>=1.31.2 # Apache-2.0
|
||||
osprofiler>=1.4.0 # Apache-2.0
|
||||
|
@ -56,6 +56,7 @@ console_scripts =
|
||||
neutron-metering-agent = neutron.cmd.eventlet.services.metering_agent:main
|
||||
neutron-sriov-nic-agent = neutron.cmd.eventlet.plugins.sriov_nic_neutron_agent:main
|
||||
neutron-sanity-check = neutron.cmd.sanity_check:main
|
||||
neutron-status = neutron.cmd.status:main
|
||||
neutron.core_plugins =
|
||||
ml2 = neutron.plugins.ml2.plugin:Ml2Plugin
|
||||
neutron.service_plugins =
|
||||
|
Loading…
Reference in New Issue
Block a user