Use EntityNotFound instead of Keystone*NotFound
This patch will use EntityNotFound instead of Keystone*NotFound. And will remove related exception class definition. Change-Id: I2b74a96edb84a250b6304b44533ff4ed435584fc Closes-Bug: #1461343
This commit is contained in:
parent
6640b05806
commit
2235165ab3
|
@ -467,26 +467,6 @@ class ObjectFieldInvalid(HeatException):
|
|||
msg_fmt = _('Field %(field)s of %(objname)s is not an instance of Field')
|
||||
|
||||
|
||||
class KeystoneRoleNotFound(HeatException):
|
||||
msg_fmt = _("Keystone role %(role_id)s not found")
|
||||
|
||||
|
||||
class KeystoneProjectNotFound(HeatException):
|
||||
msg_fmt = _("Keystone project %(project_id)s not found")
|
||||
|
||||
|
||||
class KeystoneDomainNotFound(HeatException):
|
||||
msg_fmt = _("Keystone domain %(domain_id)s not found")
|
||||
|
||||
|
||||
class KeystoneGroupNotFound(HeatException):
|
||||
msg_fmt = _("Keystone group %(group_id)s not found")
|
||||
|
||||
|
||||
class KeystoneServiceNotFound(HeatException):
|
||||
msg_fmt = _("Keystone service %(service_id)s not found")
|
||||
|
||||
|
||||
class KeystoneServiceNameConflict(HeatException):
|
||||
msg_fmt = _("Keystone has more than one service with same name "
|
||||
"%(service)s. Please use service id instead of name")
|
||||
|
|
|
@ -45,7 +45,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
|||
if role_obj.name == role:
|
||||
return role_obj.id
|
||||
|
||||
raise exception.KeystoneRoleNotFound(role_id=role)
|
||||
raise exception.EntityNotFound(entity='KeystoneRole', name=role)
|
||||
|
||||
def get_project_id(self, project):
|
||||
try:
|
||||
|
@ -57,7 +57,8 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
|||
if project_obj.name == project:
|
||||
return project_obj.id
|
||||
|
||||
raise exception.KeystoneProjectNotFound(project_id=project)
|
||||
raise exception.EntityNotFound(entity='KeystoneProject',
|
||||
name=project)
|
||||
|
||||
def get_domain_id(self, domain):
|
||||
try:
|
||||
|
@ -69,7 +70,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
|||
if domain_obj.name == domain:
|
||||
return domain_obj.id
|
||||
|
||||
raise exception.KeystoneDomainNotFound(domain_id=domain)
|
||||
raise exception.EntityNotFound(entity='KeystoneDomain', name=domain)
|
||||
|
||||
def get_group_id(self, group):
|
||||
try:
|
||||
|
@ -81,7 +82,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
|||
if group_obj.name == group:
|
||||
return group_obj.id
|
||||
|
||||
raise exception.KeystoneGroupNotFound(group_id=group)
|
||||
raise exception.EntityNotFound(entity='KeystoneGroup', name=group)
|
||||
|
||||
def get_service_id(self, service):
|
||||
try:
|
||||
|
@ -95,12 +96,13 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
|
|||
elif len(service_list) > 1:
|
||||
raise exception.KeystoneServiceNameConflict(service=service)
|
||||
else:
|
||||
raise exception.KeystoneServiceNotFound(service_id=service)
|
||||
raise exception.EntityNotFound(entity='KeystoneService',
|
||||
name=service)
|
||||
|
||||
|
||||
class KeystoneRoleConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.KeystoneRoleNotFound,)
|
||||
expected_exceptions = (exception.EntityNotFound,)
|
||||
|
||||
def validate_with_client(self, client, role):
|
||||
client.client_plugin('keystone').get_role_id(role)
|
||||
|
@ -108,7 +110,7 @@ class KeystoneRoleConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
class KeystoneDomainConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.KeystoneDomainNotFound,)
|
||||
expected_exceptions = (exception.EntityNotFound,)
|
||||
|
||||
def validate_with_client(self, client, domain):
|
||||
client.client_plugin('keystone').get_domain_id(domain)
|
||||
|
@ -116,7 +118,7 @@ class KeystoneDomainConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
class KeystoneProjectConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.KeystoneProjectNotFound,)
|
||||
expected_exceptions = (exception.EntityNotFound,)
|
||||
|
||||
def validate_with_client(self, client, project):
|
||||
client.client_plugin('keystone').get_project_id(project)
|
||||
|
@ -124,7 +126,7 @@ class KeystoneProjectConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
class KeystoneGroupConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.KeystoneGroupNotFound,)
|
||||
expected_exceptions = (exception.EntityNotFound,)
|
||||
|
||||
def validate_with_client(self, client, group):
|
||||
client.client_plugin('keystone').get_group_id(group)
|
||||
|
@ -132,7 +134,7 @@ class KeystoneGroupConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
class KeystoneServiceConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.KeystoneServiceNotFound,
|
||||
expected_exceptions = (exception.EntityNotFound,
|
||||
exception.KeystoneServiceNameConflict,)
|
||||
|
||||
def validate_with_client(self, client, service):
|
||||
|
|
|
@ -24,7 +24,7 @@ from heat.tests import common
|
|||
class KeystoneRoleConstraintTest(common.HeatTestCase):
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.KeystoneRoleNotFound,),
|
||||
self.assertEqual((exception.EntityNotFound,),
|
||||
client.KeystoneRoleConstraint.expected_exceptions,
|
||||
"KeystoneRoleConstraint expected exceptions error")
|
||||
|
||||
|
@ -44,7 +44,7 @@ class KeystoneRoleConstraintTest(common.HeatTestCase):
|
|||
class KeystoneProjectConstraintTest(common.HeatTestCase):
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.KeystoneProjectNotFound,),
|
||||
self.assertEqual((exception.EntityNotFound,),
|
||||
client.KeystoneProjectConstraint.expected_exceptions,
|
||||
"KeystoneProjectConstraint expected exceptions error")
|
||||
|
||||
|
@ -64,7 +64,7 @@ class KeystoneProjectConstraintTest(common.HeatTestCase):
|
|||
class KeystoneGroupConstraintTest(common.HeatTestCase):
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.KeystoneGroupNotFound,),
|
||||
self.assertEqual((exception.EntityNotFound,),
|
||||
client.KeystoneGroupConstraint.expected_exceptions,
|
||||
"KeystoneGroupConstraint expected exceptions error")
|
||||
|
||||
|
@ -84,7 +84,7 @@ class KeystoneGroupConstraintTest(common.HeatTestCase):
|
|||
class KeystoneDomainConstraintTest(common.HeatTestCase):
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.KeystoneDomainNotFound,),
|
||||
self.assertEqual((exception.EntityNotFound,),
|
||||
client.KeystoneDomainConstraint.expected_exceptions,
|
||||
"KeystoneDomainConstraint expected exceptions error")
|
||||
|
||||
|
@ -106,7 +106,7 @@ class KeystoneServiceConstraintTest(common.HeatTestCase):
|
|||
sample_uuid = '477e8273-60a7-4c41-b683-fdb0bc7cd151'
|
||||
|
||||
def test_expected_exceptions(self):
|
||||
self.assertEqual((exception.KeystoneServiceNotFound,
|
||||
self.assertEqual((exception.EntityNotFound,
|
||||
exception.KeystoneServiceNameConflict,),
|
||||
client.KeystoneServiceConstraint.expected_exceptions,
|
||||
"KeystoneServiceConstraint expected exceptions error")
|
||||
|
@ -207,9 +207,9 @@ class KeystoneClientPluginServiceTest(common.HeatTestCase):
|
|||
context=mock.MagicMock()
|
||||
)
|
||||
|
||||
ex = self.assertRaises(exception.KeystoneServiceNotFound,
|
||||
ex = self.assertRaises(exception.EntityNotFound,
|
||||
client_plugin.get_service_id,
|
||||
self.sample_name)
|
||||
msg = ("Keystone service %s not found" %
|
||||
self.sample_name)
|
||||
msg = ("The KeystoneService (%(name)s) could not be found." %
|
||||
{'name': self.sample_name})
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
|
Loading…
Reference in New Issue