Use EntityNotFound instead of VolumeSnapshotNotFound/VolumeTypeNotFound

This patch will use EntityNotFound instead of
VolumeSnapshotNotFound and VolumeTypeNotFound.
And will remove the two old exception class definition.

Change-Id: I661c7b6b306da34f30c55914f74eebc6e8e16931
Closes-Bug: #1461343
This commit is contained in:
huangtianhua 2015-06-03 15:11:01 +08:00
parent 96975c0a4b
commit 6640b05806
3 changed files with 10 additions and 16 deletions

View File

@ -231,14 +231,6 @@ class EntityNotFound(HeatException):
msg_fmt = _("The %(entity)s (%(name)s) could not be found.")
class VolumeSnapshotNotFound(HeatException):
msg_fmt = _("The VolumeSnapshot (%(snapshot)s) could not be found.")
class VolumeTypeNotFound(HeatException):
msg_fmt = _("The VolumeType (%(volume_type)s) could not be found.")
class NovaNetworkNotFound(HeatException):
msg_fmt = _("The Nova network (%(network)s) could not be found.")

View File

@ -101,7 +101,8 @@ class CinderClientPlugin(client_plugin.ClientPlugin):
except exceptions.NotFound as ex:
LOG.info(_LI('VolumeSnapshot (%(snapshot)s) not found: %(ex)s'),
{'snapshot': snapshot, 'ex': ex})
raise exception.VolumeSnapshotNotFound(snapshot=snapshot)
raise exception.EntityNotFound(entity='VolumeSnapshot',
name=snapshot)
def get_volume_type(self, volume_type):
vt_id = None
@ -114,7 +115,8 @@ class CinderClientPlugin(client_plugin.ClientPlugin):
vt_id = vt.id
break
if vt_id is None:
raise exception.VolumeTypeNotFound(volume_type=volume_type)
raise exception.EntityNotFound(entity='VolumeType',
name=volume_type)
return vt_id
@ -220,7 +222,7 @@ class VolumeConstraint(constraints.BaseCustomConstraint):
class VolumeSnapshotConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exception.VolumeSnapshotNotFound,)
expected_exceptions = (exception.EntityNotFound,)
def validate_with_client(self, client, snapshot):
client.client_plugin('cinder').get_volume_snapshot(snapshot)
@ -228,7 +230,7 @@ class VolumeSnapshotConstraint(constraints.BaseCustomConstraint):
class VolumeTypeConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exception.VolumeTypeNotFound,)
expected_exceptions = (exception.EntityNotFound,)
def validate_with_client(self, client, volume_type):
client.client_plugin('cinder').get_volume_type(volume_type)

View File

@ -91,8 +91,8 @@ class VolumeSnapshotConstraintTest(common.HeatTestCase):
self.assertTrue(self.constraint.validate("foo", self.ctx))
def test_validation_error(self):
self.mock_get_snapshot.side_effect = exception.VolumeSnapshotNotFound(
snapshot='bar')
self.mock_get_snapshot.side_effect = exception.EntityNotFound(
entity='VolumeSnapshot', name='bar')
self.assertFalse(self.constraint.validate("bar", self.ctx))
@ -111,6 +111,6 @@ class VolumeTypeConstraintTest(common.HeatTestCase):
self.assertTrue(self.constraint.validate("foo", self.ctx))
def test_validation_error(self):
self.mock_get_volume_type.side_effect = exception.VolumeTypeNotFound(
volume_type='bar')
self.mock_get_volume_type.side_effect = exception.EntityNotFound(
entity='VolumeType', name='bar')
self.assertFalse(self.constraint.validate("bar", self.ctx))