summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakhiljain23 <akhil.jain@india.nec.com>2018-10-30 20:31:13 +0530
committerzhurong <aaronzhu1121@gmail.com>2019-05-16 11:13:43 +0800
commit53321c1a7240967a5076f055e60092786f66b2a0 (patch)
tree8857b9166c923f5cc4a4fd58f8603e5ef6fdfd7b
parent06f66ad26282b89ffba8ed59bddc671c90297ec1 (diff)
downloadceilometer-53321c1a7240967a5076f055e60092786f66b2a0.tar.gz
Add framework for ceilometer-status upgrade check
This commit adds the functionality of ceilometer-status CLI for performing upgrade checks as part of the Stein cycle upgrade-checkers goal. It only includes a sample check which must be replaced by real checks in future. Change-Id: I6e76b74b2f02251ee39025e02de44b13568ebed2 Story: 2003657 Task: 27732
-rw-r--r--ceilometer/cmd/status.py53
-rw-r--r--ceilometer/tests/unit/cmd/__init__.py0
-rw-r--r--ceilometer/tests/unit/cmd/test_status.py30
-rw-r--r--doc/source/cli/ceilometer-status.rst83
-rw-r--r--doc/source/cli/index.rst11
-rw-r--r--doc/source/index.rst1
-rw-r--r--releasenotes/notes/add-upgrade-check-framework-d78858c54cb85f91.yaml13
-rw-r--r--requirements.txt1
-rw-r--r--setup.cfg1
9 files changed, 193 insertions, 0 deletions
diff --git a/ceilometer/cmd/status.py b/ceilometer/cmd/status.py
new file mode 100644
index 00000000..ef7660fa
--- /dev/null
+++ b/ceilometer/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 ceilometer.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='ceilometer', upgrade_command=Checks())
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/ceilometer/tests/unit/cmd/__init__.py b/ceilometer/tests/unit/cmd/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ceilometer/tests/unit/cmd/__init__.py
diff --git a/ceilometer/tests/unit/cmd/test_status.py b/ceilometer/tests/unit/cmd/test_status.py
new file mode 100644
index 00000000..0f536e91
--- /dev/null
+++ b/ceilometer/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 ceilometer.cmd import status
+from ceilometer.tests import base
+
+
+class TestUpgradeChecks(base.BaseTestCase):
+
+ 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/doc/source/cli/ceilometer-status.rst b/doc/source/cli/ceilometer-status.rst
new file mode 100644
index 00000000..699f6eca
--- /dev/null
+++ b/doc/source/cli/ceilometer-status.rst
@@ -0,0 +1,83 @@
+=================
+ceilometer-status
+=================
+
+--------------------------------------------
+CLI interface for Ceilometer status commands
+--------------------------------------------
+
+Synopsis
+========
+
+::
+
+ ceilometer-status <category> <command> [<args>]
+
+Description
+===========
+
+:program:`ceilometer-status` is a tool that provides routines for checking the
+status of a Ceilometer deployment.
+
+Options
+=======
+
+The standard pattern for executing a :program:`ceilometer-status` command is::
+
+ ceilometer-status <category> <command> [<args>]
+
+Run without arguments to see a list of available command categories::
+
+ ceilometer-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::
+
+ ceilometer-status upgrade
+
+These sections describe the available categories and arguments for
+:program:`ceilometer-status`.
+
+Upgrade
+~~~~~~~
+
+.. _ceilometer-status-checks:
+
+``ceilometer-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**
+
+ **12.0.0 (Stein)**
+
+ * Sample check to be filled in with checks as they are added in Stein.
diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst
new file mode 100644
index 00000000..f7cec41a
--- /dev/null
+++ b/doc/source/cli/index.rst
@@ -0,0 +1,11 @@
+============================
+Ceilometer CLI Documentation
+============================
+
+In this section you will find information on Ceilometer’s command line
+interface.
+
+.. toctree::
+ :maxdepth: 1
+
+ ceilometer-status
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 7f466b0a..5624aca6 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -38,6 +38,7 @@ Overview
contributor/index
admin/index
configuration/index
+ cli/index
Appendix
========
diff --git a/releasenotes/notes/add-upgrade-check-framework-d78858c54cb85f91.yaml b/releasenotes/notes/add-upgrade-check-framework-d78858c54cb85f91.yaml
new file mode 100644
index 00000000..9b68f65e
--- /dev/null
+++ b/releasenotes/notes/add-upgrade-check-framework-d78858c54cb85f91.yaml
@@ -0,0 +1,13 @@
+---
+prelude: >
+ Added new tool ``ceilometer-status upgrade check``.
+features:
+ - |
+ New framework for ``ceilometer-status upgrade check`` command is added.
+ This framework allows adding various checks which can be run before a
+ Ceilometer upgrade to ensure if the upgrade can be performed safely.
+upgrade:
+ - |
+ Operator can now use new CLI tool ``ceilometer-status upgrade check``
+ to check if Ceilometer deployment can be safely upgraded from
+ N-1 to N release.
diff --git a/requirements.txt b/requirements.txt
index d12c6bf5..46edc356 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,6 +18,7 @@ oslo.reports>=1.18.0 # Apache-2.0
oslo.rootwrap>=2.0.0 # Apache-2.0
pbr>=2.0.0 # Apache-2.0
oslo.messaging>=6.2.0 # Apache-2.0
+oslo.upgradecheck>=0.1.1 # Apache-2.0
oslo.utils>=3.37.0 # Apache-2.0
oslo.privsep>=1.32.0 # Apache-2.0
pysnmp<5.0.0,>=4.2.3 # BSD
diff --git a/setup.cfg b/setup.cfg
index a5d6aa82..9488926e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -229,6 +229,7 @@ console_scripts =
ceilometer-send-sample = ceilometer.cmd.sample:send_sample
ceilometer-upgrade = ceilometer.cmd.storage:upgrade
ceilometer-rootwrap = oslo_rootwrap.cmd:main
+ ceilometer-status = ceilometer.cmd.status:main
network.statistics.drivers =
opendaylight = ceilometer.network.statistics.opendaylight.driver:OpenDayLightDriver