From 2bbec5770c459b339b0924e8ffcd1382e22d44df Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Fri, 19 Dec 2014 13:24:21 -0800 Subject: 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 --- ironic_python_agent/errors.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'ironic_python_agent/errors.py') 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) -- cgit v1.2.1