Merge "Add exception for no default share type configured"
This commit is contained in:
commit
77ef1ce69d
|
@ -3761,6 +3761,10 @@ def _share_type_get(context, id, session=None, inactive=False,
|
|||
first())
|
||||
|
||||
if not result:
|
||||
# The only way that id could be None is if the default share type is
|
||||
# not configured and no other share type was specified.
|
||||
if id is None:
|
||||
raise exception.DefaultShareTypeNotConfigured()
|
||||
raise exception.ShareTypeNotFound(share_type_id=id)
|
||||
|
||||
share_type = _dict_with_specs(result)
|
||||
|
|
|
@ -649,6 +649,11 @@ class ShareTypeDoesNotExist(NotFound):
|
|||
message = _("Share Type %(share_type)s does not exist.")
|
||||
|
||||
|
||||
class DefaultShareTypeNotConfigured(NotFound):
|
||||
message = _("No default share type is configured. Either configure a "
|
||||
"default share type or explicitly specify a share type.")
|
||||
|
||||
|
||||
class ShareGroupTypeExists(ManilaException):
|
||||
message = _("Share group type %(type_id)s already exists.")
|
||||
|
||||
|
|
|
@ -2752,6 +2752,10 @@ class ShareTypeAPITestCase(test.TestCase):
|
|||
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_share_type_get_with_none_id(self):
|
||||
self.assertRaises(exception.DefaultShareTypeNotConfigured,
|
||||
db_api.share_type_get, self.ctxt, None)
|
||||
|
||||
|
||||
class MessagesDatabaseAPITestCase(test.TestCase):
|
||||
|
||||
|
|
|
@ -486,6 +486,11 @@ class ManilaExceptionResponseCode404(test.TestCase):
|
|||
self.assertIn(share_type_id, e.msg)
|
||||
self.assertIn(extra_specs_key, e.msg)
|
||||
|
||||
def test_default_share_type_not_configured(self):
|
||||
# Verify response code for exception.DefaultShareTypeNotConfigured
|
||||
e = exception.DefaultShareTypeNotConfigured()
|
||||
self.assertEqual(404, e.code)
|
||||
|
||||
def test_instance_not_found(self):
|
||||
# verify response code for exception.InstanceNotFound
|
||||
instance_id = "fake_instance_id"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- A new exception will be thrown when a default share type was not
|
||||
configured and no other share type was specified on any sort of
|
||||
share creation.
|
Loading…
Reference in New Issue