summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Turek <mjturek@linux.vnet.ibm.com>2015-01-16 21:56:03 +0000
committerMichael Turek <mjturek@linux.vnet.ibm.com>2015-01-16 21:56:03 +0000
commit0c4aa3dcf2373aa55ccc87f86dc68e2cfd162bf9 (patch)
treeda201d22e5e231ba182e73b19dc28455219abe79
parent166f56da9464c07ee07f537710a37a2f2e8d59fb (diff)
downloadironic-python-agent-0c4aa3dcf2373aa55ccc87f86dc68e2cfd162bf9.tar.gz
Make all IPA error classes inherit from RESTError
Currently several IPA error classes inherit from Exception. This patch makes the base class of those classes RESTError. These error classes are also restructured to initialize in the same manner as other classes which inherit from RESTError. Additionally test cases are added for these error classes. Change-Id: Ie6235e4cc25f072b789b2e72e4592d4cf02bfedc Closes-bug: #1410372
-rw-r--r--ironic_python_agent/errors.py26
-rw-r--r--ironic_python_agent/tests/errors.py4
2 files changed, 19 insertions, 11 deletions
diff --git a/ironic_python_agent/errors.py b/ironic_python_agent/errors.py
index 6058d191..5ec2e3bf 100644
--- a/ironic_python_agent/errors.py
+++ b/ironic_python_agent/errors.py
@@ -228,30 +228,34 @@ class VirtualMediaBootError(RESTError):
super(VirtualMediaBootError, self).__init__(details)
-class ExtensionError(Exception):
+class ExtensionError(RESTError):
pass
-class UnknownNodeError(Exception):
+class UnknownNodeError(RESTError):
"""Error raised when the agent is not associated with an Ironic node."""
message = 'Agent is not associated with an Ironic node.'
- def __init__(self, message=None):
- if message is not None:
- self.message = message
- super(UnknownNodeError, self).__init__(self.message)
+ def __init__(self, details=None):
+ if details is not None:
+ details = details
+ else:
+ details = self.message
+ super(UnknownNodeError, self).__init__(details)
-class HardwareManagerNotFound(Exception):
+class HardwareManagerNotFound(RESTError):
"""Error raised when no valid HardwareManager can be found."""
message = 'No valid HardwareManager found.'
- def __init__(self, message=None):
- if message is not None:
- self.message = message
- super(HardwareManagerNotFound, self).__init__(self.message)
+ def __init__(self, details=None):
+ if details is not None:
+ details = details
+ else:
+ details = self.message
+ super(HardwareManagerNotFound, self).__init__(details)
class HardwareManagerMethodNotFound(RESTError):
diff --git a/ironic_python_agent/tests/errors.py b/ironic_python_agent/tests/errors.py
index cc0c0da3..b36cad86 100644
--- a/ironic_python_agent/tests/errors.py
+++ b/ironic_python_agent/tests/errors.py
@@ -108,6 +108,10 @@ class TestErrors(test_base.BaseTestCase):
(errors.BlockDeviceEraseError(DETAILS), SAME_DETAILS),
(errors.BlockDeviceError(DETAILS), SAME_DETAILS),
(errors.VirtualMediaBootError(DETAILS), SAME_DETAILS),
+ (errors.UnknownNodeError(), SAME_CL_MSG),
+ (errors.UnknownNodeError(DETAILS), SAME_DETAILS),
+ (errors.HardwareManagerNotFound(), SAME_CL_MSG),
+ (errors.HardwareManagerNotFound(DETAILS), SAME_DETAILS),
(errors.HardwareManagerMethodNotFound('method'),
DIFF_CL_DETAILS),
(errors.IncompatibleHardwareMethodError(), SAME_CL_MSG),