summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhoami-rajat <rajatdhasmana@gmail.com>2018-10-31 17:01:31 +0530
committerJulia Kreger <juliaashleykreger@gmail.com>2018-11-01 19:58:13 +0000
commit1f1a2c3bd8938fd94e3a7d22eaeb31be8d3c6113 (patch)
tree520a701e5fd85d5805eebd4c6c7e6551f6b33f64
parent7e47264ece751939aab9d54306ea61a2d02b36e9 (diff)
downloadironic-1f1a2c3bd8938fd94e3a7d22eaeb31be8d3c6113.tar.gz
Add ironic-status upgrade check command framework
This adds basic framework for ironic-status upgrade check commands. For now it has only "check_placeholder" check implemented. Real checks can be added to this tool in the future. Change-Id: I7d5f018656322b92c663a2adaaf6330a55c00fb8 Story: 2003657 Task: 26133
-rw-r--r--doc/source/cli/index.rst1
-rw-r--r--doc/source/cli/ironic-status.rst78
-rw-r--r--ironic/cmd/status.py54
-rw-r--r--ironic/tests/unit/cmd/test_status.py30
-rw-r--r--lower-constraints.txt1
-rw-r--r--releasenotes/notes/ironic-status-upgrade-check-framework-9cd216ddf3afb271.yaml11
-rw-r--r--requirements.txt1
-rw-r--r--setup.cfg1
8 files changed, 177 insertions, 0 deletions
diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst
index 7d5fd5e8c..aa11f86f4 100644
--- a/doc/source/cli/index.rst
+++ b/doc/source/cli/index.rst
@@ -7,3 +7,4 @@ Here are references for commands not elsewhere documented.
:maxdepth: 1
ironic-dbsync
+ ironic-status
diff --git a/doc/source/cli/ironic-status.rst b/doc/source/cli/ironic-status.rst
new file mode 100644
index 000000000..ea7c2b2ae
--- /dev/null
+++ b/doc/source/cli/ironic-status.rst
@@ -0,0 +1,78 @@
+=============
+ironic-status
+=============
+
+Synopsis
+========
+
+::
+
+ ironic-status <category> <command> [<args>]
+
+Description
+===========
+
+:program:`ironic-status` is a tool that provides routines for checking the
+status of a Ironic deployment.
+
+Options
+=======
+
+The standard pattern for executing a :program:`ironic-status` command is::
+
+ ironic-status <category> <command> [<args>]
+
+Run without arguments to see a list of available command categories::
+
+ ironic-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::
+
+ ironic-status upgrade
+
+These sections describe the available categories and arguments for
+:program:`ironic-status`.
+
+Upgrade
+~~~~~~~
+
+.. _ironic-status-checks:
+
+``ironic-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.
+
+ **History of Checks**
+
+ **12.0.0 (Stein)**
+
+ * Placeholder to be filled in with checks as they are added in Stein.
diff --git a/ironic/cmd/status.py b/ironic/cmd/status.py
new file mode 100644
index 000000000..c1366bb4c
--- /dev/null
+++ b/ironic/cmd/status.py
@@ -0,0 +1,54 @@
+# 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 ironic.common.i18n import _
+
+
+class Checks(upgradecheck.UpgradeCommands):
+
+ """Upgrade checks for the ironic-status upgrade check command
+
+ Upgrade checks should be added as separate methods in this class
+ and added to _upgrade_checks tuple.
+ """
+
+ def _check_placeholder(self):
+ # This is just a placeholder for upgrade checks, it should be
+ # removed when the actual checks are 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 = (
+ # In the future there should be some real checks added here
+ (_('Placeholder'), _check_placeholder),
+ )
+
+
+def main():
+ return upgradecheck.main(
+ cfg.CONF, project='ironic', upgrade_command=Checks())
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/ironic/tests/unit/cmd/test_status.py b/ironic/tests/unit/cmd/test_status.py
new file mode 100644
index 000000000..49ce00b11
--- /dev/null
+++ b/ironic/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 ironic.cmd import status
+from ironic.tests.unit.db import base as db_base
+
+
+class TestUpgradeChecks(db_base.DbTestCase):
+
+ def setUp(self):
+ super(TestUpgradeChecks, self).setUp()
+ self.cmd = status.Checks()
+
+ def test__check_placeholder(self):
+ check_result = self.cmd._check_placeholder()
+ self.assertEqual(
+ Code.SUCCESS, check_result.code)
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 911ba412e..82846cf2c 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -82,6 +82,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
oslotest==3.2.0
diff --git a/releasenotes/notes/ironic-status-upgrade-check-framework-9cd216ddf3afb271.yaml b/releasenotes/notes/ironic-status-upgrade-check-framework-9cd216ddf3afb271.yaml
new file mode 100644
index 000000000..c52219829
--- /dev/null
+++ b/releasenotes/notes/ironic-status-upgrade-check-framework-9cd216ddf3afb271.yaml
@@ -0,0 +1,11 @@
+---
+features:
+ - |
+ New framework for ``ironic-status upgrade check`` command is added.
+ This framework allows adding various checks which can be run before a
+ Ironic upgrade to ensure if the upgrade can be performed safely.
+upgrade:
+ - |
+ Operator can now use new CLI tool ``ironic-status upgrade check``
+ to check if Ironic deployment can be safely upgraded from
+ N-1 to N release.
diff --git a/requirements.txt b/requirements.txt
index 507bf933d..0bcdf484a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -28,6 +28,7 @@ oslo.policy>=1.30.0 # Apache-2.0
oslo.reports>=1.18.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
osprofiler>=1.5.0 # Apache-2.0
os-traits>=0.4.0 # Apache-2.0
diff --git a/setup.cfg b/setup.cfg
index 1cf0f0e87..28ce49ca4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -44,6 +44,7 @@ console_scripts =
ironic-dbsync = ironic.cmd.dbsync:main
ironic-conductor = ironic.cmd.conductor:main
ironic-rootwrap = oslo_rootwrap.cmd:main
+ ironic-status = ironic.cmd.status:main
wsgi_scripts =
ironic-api-wsgi = ironic.api.wsgi:initialize_wsgi_app