Renaming ConfigurationError to LookupNodeError

This commit is contained in:
Josh Gachnang 2014-03-18 10:39:47 -07:00
parent 22f3ccd3dc
commit 3f08a0ce7e
3 changed files with 12 additions and 10 deletions

View File

@ -110,13 +110,15 @@ class HeartbeatError(OverlordAPIError):
super(HeartbeatError, self).__init__(details)
class ConfigurationError(OverlordAPIError):
"""Error raised when the configuration lookup to the agent API fails."""
class LookupNodeError(OverlordAPIError):
"""Error raised when the node configuration lookup to the Ironic API
fails.
"""
message = 'Error getting configuration from Ironic.'
def __init__(self, details):
super(ConfigurationError, self).__init__(details)
super(LookupNodeError, self).__init__(details)
class ImageDownloadError(RESTError):

View File

@ -84,20 +84,20 @@ class APIClient(object):
try:
response = self._request('POST', path, data=data)
except Exception as e:
raise errors.ConfigurationError(str(e))
raise errors.LookupNodeError(str(e))
if response.status_code != requests.codes.OK:
msg = 'Invalid status code: {0}'.format(response.status_code)
raise errors.ConfigurationError(msg)
raise errors.LookupNodeError(msg)
try:
content = json.loads(response.content)
except Exception as e:
raise errors.ConfigurationError('Error decoding response: '
raise errors.LookupNodeError('Error decoding response: '
+ str(e))
if 'node' not in content or 'uuid' not in content['node']:
raise errors.ConfigurationError('Got invalid data from the API: '
raise errors.LookupNodeError('Got invalid data from the API: '
'{0}'.format(content))
return content

View File

@ -140,7 +140,7 @@ class TestBaseTeethAgent(unittest.TestCase):
self.api_client.session.request = mock.Mock()
self.api_client.session.request.return_value = response
self.assertRaises(errors.ConfigurationError,
self.assertRaises(errors.LookupNodeError,
self.api_client.lookup_node,
mac_addrs=['aa:bb:cc:dd:ee:ff',
'42:42:42:42:42:42'],
@ -156,7 +156,7 @@ class TestBaseTeethAgent(unittest.TestCase):
self.api_client.session.request = mock.Mock()
self.api_client.session.request.return_value = response
self.assertRaises(errors.ConfigurationError,
self.assertRaises(errors.LookupNodeError,
self.api_client.lookup_node,
mac_addrs=['aa:bb:cc:dd:ee:ff',
'42:42:42:42:42:42'],
@ -174,7 +174,7 @@ class TestBaseTeethAgent(unittest.TestCase):
self.api_client.session.request = mock.Mock()
self.api_client.session.request.return_value = response
self.assertRaises(errors.ConfigurationError,
self.assertRaises(errors.LookupNodeError,
self.api_client.lookup_node,
mac_addrs=['aa:bb:cc:dd:ee:ff',
'42:42:42:42:42:42'],