diff options
author | Jay Faulkner <jay@jvf.cc> | 2014-12-19 13:24:21 -0800 |
---|---|---|
committer | Jay Faulkner <jay@jvf.cc> | 2015-01-08 15:15:13 -0800 |
commit | 2bbec5770c459b339b0924e8ffcd1382e22d44df (patch) | |
tree | 1a1035f408aa3d1557a9d91772c4f5f71e820c2f /ironic_python_agent/errors.py | |
parent | 8dd54446e3a7a1e13fee91a4f7cfa064b085b03b (diff) | |
download | ironic-python-agent-2bbec5770c459b339b0924e8ffcd1382e22d44df.tar.gz |
Allow use of multiple simultaneous HW managers
Currently we pick the most specific manager and use it. Instead, call
each method on each hardware manager in priority order, and consider the
call successful if the method exists and doesn't throw
IncompatibleHardwareMethodError.
This is an API breaking change for anyone with out-of-tree
HardwareManagers.
Closes-bug: 1408469
Change-Id: I30c65c9259acd4f200cb554e7d688344b7486a58
Diffstat (limited to 'ironic_python_agent/errors.py')
-rw-r--r-- | ironic_python_agent/errors.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ironic_python_agent/errors.py b/ironic_python_agent/errors.py index 7219fbda..a7abdb30 100644 --- a/ironic_python_agent/errors.py +++ b/ironic_python_agent/errors.py @@ -247,3 +247,43 @@ class UnknownNodeError(Exception): if message is not None: self.message = message super(UnknownNodeError, self).__init__(self.message) + + +class HardwareManagerNotFound(Exception): + """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) + + +class HardwareManagerMethodNotFound(RESTError): + """Error raised when all HardwareManagers fail to handle a method.""" + + msg = 'No HardwareManager found to handle method' + message = msg + '.' + + def __init__(self, method=None): + if method is not None: + self.details = (self.msg + ': "{0}".').format(method) + else: + self.details = self.message + super(HardwareManagerMethodNotFound, self).__init__(self.details) + + +class IncompatibleHardwareMethodError(RESTError): + """Error raised when HardwareManager method is incompatible with node + hardware. + """ + + message = 'HardwareManager method is not compatible with hardware.' + + def __init__(self, details=None): + if details is not None: + self.details = details + else: + self.details = self.message + super(IncompatibleHardwareMethodError, self).__init__(self.details) |