Shorten UpgradeCheck class names
When this library is used, the classes get referred to as something like upgradecheck.UpgradeCheckResult, which is redundant and wordy. Shortening the class names to remove the "UpgradeCheck" part fixes both problems. Change-Id: I621434585ed84256b9fe44d88a516d8c27eb05b3
This commit is contained in:
parent
32c53f2992
commit
a7a6f991de
@ -21,12 +21,11 @@ from oslo_upgradecheck import upgradecheck
|
|||||||
|
|
||||||
class Checks(upgradecheck.UpgradeCommands):
|
class Checks(upgradecheck.UpgradeCommands):
|
||||||
def success(self):
|
def success(self):
|
||||||
return upgradecheck.UpgradeCheckResult(
|
return upgradecheck.Result(upgradecheck.Code.SUCCESS,
|
||||||
upgradecheck.UpgradeCheckCode.SUCCESS, 'Always succeeds')
|
'Always succeeds')
|
||||||
|
|
||||||
def failure(self):
|
def failure(self):
|
||||||
return upgradecheck.UpgradeCheckResult(
|
return upgradecheck.Result(upgradecheck.Code.FAILURE, 'Always fails')
|
||||||
upgradecheck.UpgradeCheckCode.FAILURE, 'Always fails')
|
|
||||||
|
|
||||||
_upgrade_checks = (('always succeeds', success),
|
_upgrade_checks = (('always succeeds', success),
|
||||||
('always fails', failure),
|
('always fails', failure),
|
||||||
|
@ -30,25 +30,21 @@ from oslo_upgradecheck import upgradecheck
|
|||||||
class TestUpgradeCheckResult(base.BaseTestCase):
|
class TestUpgradeCheckResult(base.BaseTestCase):
|
||||||
|
|
||||||
def test_details(self):
|
def test_details(self):
|
||||||
result = upgradecheck.UpgradeCheckResult(
|
result = upgradecheck.Result(upgradecheck.Code.SUCCESS, 'test details')
|
||||||
upgradecheck.UpgradeCheckCode.SUCCESS,
|
|
||||||
'test details')
|
|
||||||
self.assertEqual(0, result.code)
|
self.assertEqual(0, result.code)
|
||||||
self.assertEqual('test details', result.details)
|
self.assertEqual('test details', result.details)
|
||||||
|
|
||||||
|
|
||||||
class TestCommands(upgradecheck.UpgradeCommands):
|
class TestCommands(upgradecheck.UpgradeCommands):
|
||||||
def success(self):
|
def success(self):
|
||||||
return upgradecheck.UpgradeCheckResult(
|
return upgradecheck.Result(upgradecheck.Code.SUCCESS,
|
||||||
upgradecheck.UpgradeCheckCode.SUCCESS, 'Always succeeds')
|
'Always succeeds')
|
||||||
|
|
||||||
def warning(self):
|
def warning(self):
|
||||||
return upgradecheck.UpgradeCheckResult(
|
return upgradecheck.Result(upgradecheck.Code.WARNING, 'Always warns')
|
||||||
upgradecheck.UpgradeCheckCode.WARNING, 'Always warns')
|
|
||||||
|
|
||||||
def failure(self):
|
def failure(self):
|
||||||
return upgradecheck.UpgradeCheckResult(
|
return upgradecheck.Result(upgradecheck.Code.FAILURE, 'Always fails')
|
||||||
upgradecheck.UpgradeCheckCode.FAILURE, 'Always fails')
|
|
||||||
|
|
||||||
_upgrade_checks = (('always succeeds', success),
|
_upgrade_checks = (('always succeeds', success),
|
||||||
('always warns', warning),
|
('always warns', warning),
|
||||||
@ -62,9 +58,7 @@ class SuccessCommands(TestCommands):
|
|||||||
|
|
||||||
class TestUpgradeCommands(base.BaseTestCase):
|
class TestUpgradeCommands(base.BaseTestCase):
|
||||||
def test_get_details(self):
|
def test_get_details(self):
|
||||||
result = upgradecheck.UpgradeCheckResult(
|
result = upgradecheck.Result(upgradecheck.Code.SUCCESS, '*' * 70)
|
||||||
upgradecheck.UpgradeCheckCode.SUCCESS,
|
|
||||||
'*' * 70)
|
|
||||||
upgrade_commands = upgradecheck.UpgradeCommands()
|
upgrade_commands = upgradecheck.UpgradeCommands()
|
||||||
details = upgrade_commands._get_details(result)
|
details = upgrade_commands._get_details(result)
|
||||||
wrapped = '*' * 60 + '\n ' + '*' * 10
|
wrapped = '*' * 60 + '\n ' + '*' * 10
|
||||||
@ -73,7 +67,7 @@ class TestUpgradeCommands(base.BaseTestCase):
|
|||||||
def test_check(self):
|
def test_check(self):
|
||||||
inst = TestCommands()
|
inst = TestCommands()
|
||||||
result = inst.check()
|
result = inst.check()
|
||||||
self.assertEqual(upgradecheck.UpgradeCheckCode.FAILURE, result)
|
self.assertEqual(upgradecheck.Code.FAILURE, result)
|
||||||
|
|
||||||
|
|
||||||
class TestMain(base.BaseTestCase):
|
class TestMain(base.BaseTestCase):
|
||||||
@ -85,7 +79,7 @@ class TestMain(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
inst = TestCommands()
|
inst = TestCommands()
|
||||||
self._run_test(inst.check, upgradecheck.UpgradeCheckCode.FAILURE)
|
self._run_test(inst.check, upgradecheck.Code.FAILURE)
|
||||||
|
|
||||||
def test_main_exception(self):
|
def test_main_exception(self):
|
||||||
def raises():
|
def raises():
|
||||||
|
@ -25,7 +25,7 @@ import prettytable
|
|||||||
from oslo_upgradecheck._i18n import _
|
from oslo_upgradecheck._i18n import _
|
||||||
|
|
||||||
|
|
||||||
class UpgradeCheckCode(enum.IntEnum):
|
class Code(enum.IntEnum):
|
||||||
"""Status codes for the upgrade check command"""
|
"""Status codes for the upgrade check command"""
|
||||||
|
|
||||||
# All upgrade readiness checks passed successfully and there is
|
# All upgrade readiness checks passed successfully and there is
|
||||||
@ -42,23 +42,23 @@ class UpgradeCheckCode(enum.IntEnum):
|
|||||||
|
|
||||||
|
|
||||||
UPGRADE_CHECK_MSG_MAP = {
|
UPGRADE_CHECK_MSG_MAP = {
|
||||||
UpgradeCheckCode.SUCCESS: _('Success'),
|
Code.SUCCESS: _('Success'),
|
||||||
UpgradeCheckCode.WARNING: _('Warning'),
|
Code.WARNING: _('Warning'),
|
||||||
UpgradeCheckCode.FAILURE: _('Failure'),
|
Code.FAILURE: _('Failure'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class UpgradeCheckResult(object):
|
class Result(object):
|
||||||
"""Class used for 'nova-status upgrade check' results.
|
"""Class used for 'nova-status upgrade check' results.
|
||||||
|
|
||||||
The 'code' attribute is an UpgradeCheckCode enum.
|
The 'code' attribute is a Code enum.
|
||||||
The 'details' attribute is a translated message generally only used for
|
The 'details' attribute is a translated message generally only used for
|
||||||
checks that result in a warning or failure code. The details should provide
|
checks that result in a warning or failure code. The details should provide
|
||||||
information on what issue was discovered along with any remediation.
|
information on what issue was discovered along with any remediation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, code, details=None):
|
def __init__(self, code, details=None):
|
||||||
super(UpgradeCheckResult, self).__init__()
|
super(Result, self).__init__()
|
||||||
self.code = code
|
self.code = code
|
||||||
self.details = details
|
self.details = details
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ class UpgradeCommands(object):
|
|||||||
new code. These checks also require access to potentially all of the
|
new code. These checks also require access to potentially all of the
|
||||||
Nova databases (nova, nova_api, nova_api_cell0) and external services
|
Nova databases (nova, nova_api, nova_api_cell0) and external services
|
||||||
such as the placement API service.
|
such as the placement API service.
|
||||||
:returns: UpgradeCheckCode
|
:returns: Code
|
||||||
"""
|
"""
|
||||||
return_code = UpgradeCheckCode.SUCCESS
|
return_code = Code.SUCCESS
|
||||||
# This is a list if 2-item tuples for the check name and it's results.
|
# This is a list if 2-item tuples for the check name and it's results.
|
||||||
check_results = []
|
check_results = []
|
||||||
for name, func in self._upgrade_checks:
|
for name, func in self._upgrade_checks:
|
||||||
|
Loading…
Reference in New Issue
Block a user