Use EntityNotFound instead of NotFound from Manila

Like what we handle other NotFound case, we should use EntityNotFound
instead of NotFound from Manila.

Change-Id: Ife04e43748edd20a2fa3c41ce0d661479a24f6a6
This commit is contained in:
ricolin 2015-11-27 14:26:04 +08:00
parent c265494a98
commit 7264fc5e02
2 changed files with 9 additions and 7 deletions

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common import exception as heat_exception
from heat.engine.clients import client_plugin
from heat.engine import constraints
from manilaclient import client as manila_client
@ -61,7 +62,7 @@ class ManilaClientPlugin(client_plugin.ClientPlugin):
:param resource_list: list of resources
:param resource_type_name: name of resource type that will be used
for exceptions
:raises NotFound, NoUniqueMatch
:raises EntityNotFound, NoUniqueMatch
:return: resource or generate an exception otherwise
"""
search_result_by_id = [res for res in resource_list
@ -81,10 +82,8 @@ class ManilaClientPlugin(client_plugin.ClientPlugin):
elif match_count == 1:
return search_result_by_name[0]
else:
message = ("{0} '{1}' was not found in Manila. Please "
"use the identity of existing {0} in Heat "
"template.").format(resource_type_name, id_or_name)
raise exceptions.NotFound(message=message)
raise heat_exception.EntityNotFound(entity=resource_type_name,
name=id_or_name)
def get_share_type(self, share_type_identity):
return self._find_resource_by_id_or_name(
@ -119,7 +118,8 @@ class ManilaShareBaseConstraint(constraints.BaseCustomConstraint):
# check that exceptions module has been loaded. Without this check
# doc tests on gates will fail
expected_exceptions = (exceptions.NotFound, exceptions.NoUniqueMatch)
expected_exceptions = (heat_exception.EntityNotFound,
exceptions.NoUniqueMatch)
resource_client_name = SERVICE_NAME

View File

@ -15,6 +15,7 @@ import collections
from manilaclient import exceptions
import mock
from heat.common import exception as heat_exception
from heat.tests import common
from heat.tests import utils
@ -66,6 +67,7 @@ class ManilaClientPluginTests(common.HeatTestCase):
# test that get_<method_name> is searching correctly
get_method = getattr(self.manila_plugin, self.method_name)
self.assertEqual(get_method("unique_id").name, "unique_name")
self.assertRaises(exceptions.NotFound, get_method, "non_exist")
self.assertRaises(heat_exception.EntityNotFound,
get_method, "non_exist")
self.assertRaises(exceptions.NoUniqueMatch, get_method,
"duplicated_name")