Make exception more generic
This commit is contained in:
@@ -665,7 +665,7 @@ class TestOpenStackUtils(ut_utils.BaseTestCase):
|
||||
|
||||
# No machine returned
|
||||
self._get_machines.return_value = []
|
||||
with self.assertRaises(exceptions.NoKeystoneFound):
|
||||
with self.assertRaises(exceptions.ApplicationNotFound):
|
||||
openstack_utils.get_current_os_release_pair()
|
||||
|
||||
# No series returned
|
||||
|
||||
@@ -31,10 +31,19 @@ class NeutronBGPSpeakerMissing(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class NoKeystoneFound(Exception):
|
||||
"""No Keystone found in machines."""
|
||||
class ApplicationNotFound(Exception):
|
||||
"""Application not found in machines."""
|
||||
|
||||
pass
|
||||
def __init__(self, application):
|
||||
"""Create Application not found exception.
|
||||
|
||||
:param application: Name of the application
|
||||
:type application: string
|
||||
:returns: ApplicationNotFound Exception
|
||||
"""
|
||||
msg = ("{} application was not found in machines.".
|
||||
format(application))
|
||||
super(ApplicationNotFound, self).__init__(msg)
|
||||
|
||||
|
||||
class SeriesNotFound(Exception):
|
||||
|
||||
@@ -1131,7 +1131,7 @@ def get_current_os_release_pair(application='keystone'):
|
||||
:type application: string
|
||||
:returns: Name of the OpenStack release pair
|
||||
:rtype: str
|
||||
:raises: exceptions.NoKeystoneFound
|
||||
:raises: exceptions.ApplicationNotFound
|
||||
:raises: exceptions.SeriesNotFound
|
||||
:raises: exceptions.OSVersionNotFound
|
||||
"""
|
||||
@@ -1139,7 +1139,7 @@ def get_current_os_release_pair(application='keystone'):
|
||||
if len(machines) >= 1:
|
||||
machine = machines[0]
|
||||
else:
|
||||
raise exceptions.NoKeystoneFound()
|
||||
raise exceptions.ApplicationNotFound(application)
|
||||
|
||||
series = juju_utils.get_machine_series(machine)
|
||||
if not series:
|
||||
|
||||
Reference in New Issue
Block a user