Add a "Conflict" exception
Provider drivers may need to raise a "Conflict" exception. For example when the requested VIP address is already in use as is the case in the related bug. This patch adds this exception for provider drivers to use. Partial-Bug: #2052682 Change-Id: I42e14233eb040412774db61f211603f7b6528341
This commit is contained in:
@@ -203,3 +203,29 @@ class NotFound(Exception):
|
||||
self.operator_fault_string = kwargs.pop('operator_fault_string',
|
||||
self.operator_fault_string)
|
||||
super().__init__(self.user_fault_string, *args, **kwargs)
|
||||
|
||||
|
||||
class Conflict(Exception):
|
||||
"""Exception raised when the driver has a resource conflict.
|
||||
|
||||
This exception includes two strings: The user fault string and the
|
||||
optional operator fault string. The user fault string,
|
||||
"user_fault_string", will be provided to the API requester. The operator
|
||||
fault string, "operator_fault_string", will be logged in the Octavia API
|
||||
log file for the operator to use when debugging.
|
||||
|
||||
:param user_fault_string: String provided to the API requester.
|
||||
:type user_fault_string: string
|
||||
:param operator_fault_string: Optional string logged by the Octavia API
|
||||
for the operator to use when debugging.
|
||||
:type operator_fault_string: string
|
||||
"""
|
||||
user_fault_string = _("The provider driver had a resource conflict.")
|
||||
operator_fault_string = _("The provider driver had a resource conflict.")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user_fault_string = kwargs.pop('user_fault_string',
|
||||
self.user_fault_string)
|
||||
self.operator_fault_string = kwargs.pop('operator_fault_string',
|
||||
self.operator_fault_string)
|
||||
super().__init__(self.user_fault_string, *args, **kwargs)
|
||||
|
||||
@@ -99,3 +99,14 @@ class TestProviderExceptions(base.TestCase):
|
||||
self.assertEqual(self.operator_fault_string,
|
||||
not_found_error.operator_fault_string)
|
||||
self.assertIsInstance(not_found_error, Exception)
|
||||
|
||||
def test_Conflict(self):
|
||||
conflict_error = exceptions.Conflict(
|
||||
user_fault_string=self.user_fault_string,
|
||||
operator_fault_string=self.operator_fault_string)
|
||||
|
||||
self.assertEqual(self.user_fault_string,
|
||||
conflict_error.user_fault_string)
|
||||
self.assertEqual(self.operator_fault_string,
|
||||
conflict_error.operator_fault_string)
|
||||
self.assertIsInstance(conflict_error, Exception)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Adds a "Conflict" exception drivers can raise when a resource conflict
|
||||
occurs. This is part of a fix for error reporting when the requested VIP
|
||||
address is already in use on the subnet.
|
||||
Reference in New Issue
Block a user