Rename instance type exceptions to flavors
Change-Id: I731ae3a2d5490b0824d3c90fb67902b60fa8f437
This commit is contained in:
parent
a7224e4ba9
commit
6fe3d0d43d
@ -172,7 +172,7 @@ class FlavorsController(rest.RestController):
|
||||
try:
|
||||
flavor_in_db = objects.InstanceType.get(
|
||||
pecan.request.context, flavor_uuid)
|
||||
except exception.InstanceTypeNotFound:
|
||||
except exception.FlavorTypeNotFound:
|
||||
msg = (_("InstanceType %s could not be found") %
|
||||
flavor_uuid)
|
||||
raise wsme.exc.ClientSideError(
|
||||
|
@ -609,8 +609,8 @@ class InstanceController(InstanceControllerBase):
|
||||
key_name=key_name,
|
||||
min_count=min_count,
|
||||
max_count=max_count)
|
||||
except exception.InstanceTypeNotFound:
|
||||
msg = (_("InstanceType %s could not be found") %
|
||||
except exception.FlavorNotFound:
|
||||
msg = (_("Flavor %s could not be found") %
|
||||
instance_type_uuid)
|
||||
raise wsme.exc.ClientSideError(
|
||||
msg, status_code=http_client.BAD_REQUEST)
|
||||
|
@ -148,12 +148,12 @@ class InvalidUUID(Invalid):
|
||||
_msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
||||
|
||||
|
||||
class InstanceTypeAlreadyExists(MoganException):
|
||||
_msg_fmt = _("InstanceType with uuid %(uuid)s already exists.")
|
||||
class FlavorAlreadyExists(MoganException):
|
||||
_msg_fmt = _("Flavor with uuid %(uuid)s already exists.")
|
||||
|
||||
|
||||
class InstanceTypeNotFound(NotFound):
|
||||
_msg_fmt = _("InstanceType %(type_id)s could not be found.")
|
||||
class FlavorNotFound(NotFound):
|
||||
_msg_fmt = _("Flavor %(type_id)s could not be found.")
|
||||
|
||||
|
||||
class InstanceAlreadyExists(MoganException):
|
||||
@ -241,13 +241,13 @@ class NoValidNode(MoganException):
|
||||
message = _("No valid node was found. %(reason)s")
|
||||
|
||||
|
||||
class TypeExtraSpecUpdateCreateFailed(MoganException):
|
||||
_msg_fmt = _("Instance Type %(id)s extra spec cannot be updated or"
|
||||
class FlavorExtraSpecUpdateCreateFailed(MoganException):
|
||||
_msg_fmt = _("Flavor %(id)s extra spec cannot be updated or"
|
||||
"created after %(retries)d retries.")
|
||||
|
||||
|
||||
class InstanceTypeExtraSpecsNotFound(NotFound):
|
||||
_msg_fmt = _("Instance Type %(type_id)s has no extra specs with "
|
||||
class FlavorExtraSpecsNotFound(NotFound):
|
||||
_msg_fmt = _("Flavor %(flavor_id)s has no extra specs with "
|
||||
"key %(extra_specs_key)s.")
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ class Connection(api.Connection):
|
||||
session.add(instance_type)
|
||||
session.flush()
|
||||
except db_exc.DBDuplicateEntry:
|
||||
raise exception.InstanceTypeAlreadyExists(uuid=values['uuid'])
|
||||
raise exception.FlavorAlreadyExists(uuid=values['uuid'])
|
||||
return _dict_with_extra_specs(instance_type)
|
||||
|
||||
def instance_type_get(self, context, instance_type_uuid):
|
||||
@ -134,7 +134,7 @@ class Connection(api.Connection):
|
||||
try:
|
||||
return _dict_with_extra_specs(query.one())
|
||||
except NoResultFound:
|
||||
raise exception.InstanceTypeNotFound(
|
||||
raise exception.FlavorNotFound(
|
||||
type_id=instance_type_uuid)
|
||||
|
||||
def instance_type_update(self, context, instance_type_id, values):
|
||||
@ -144,7 +144,7 @@ class Connection(api.Connection):
|
||||
try:
|
||||
ref = query.with_lockmode('update').one()
|
||||
except NoResultFound:
|
||||
raise exception.InstanceTypeNotFound(
|
||||
raise exception.FlavorNotFound(
|
||||
type_id=instance_type_id)
|
||||
|
||||
ref.update(values)
|
||||
@ -170,7 +170,7 @@ class Connection(api.Connection):
|
||||
|
||||
count = query.delete()
|
||||
if count != 1:
|
||||
raise exception.InstanceTypeNotFound(
|
||||
raise exception.FlavorNotFound(
|
||||
type_id=instance_type_uuid)
|
||||
|
||||
def instance_create(self, context, values):
|
||||
@ -454,7 +454,7 @@ class Connection(api.Connection):
|
||||
# a concurrent transaction has been committed,
|
||||
# try again unless this was the last attempt
|
||||
if attempt == max_retries - 1:
|
||||
raise exception.TypeExtraSpecUpdateCreateFailed(
|
||||
raise exception.FlavorExtraSpecUpdateCreateFailed(
|
||||
id=instance_type_uuid, retries=max_retries)
|
||||
|
||||
def instance_type_extra_specs_get(self, context, type_id):
|
||||
@ -467,8 +467,8 @@ class Connection(api.Connection):
|
||||
delete(synchronize_session=False)
|
||||
# did not find the extra spec
|
||||
if result == 0:
|
||||
raise exception.InstanceTypeExtraSpecsNotFound(
|
||||
extra_specs_key=key, type_id=type_id)
|
||||
raise exception.FlavorExtraSpecsNotFound(
|
||||
extra_specs_key=key, flavor_id=type_id)
|
||||
|
||||
def instance_nic_update_or_create(self, context, port_id, values):
|
||||
with _session_for_write() as session:
|
||||
@ -877,7 +877,7 @@ def _type_get_id_from_type_query(context, type_id):
|
||||
def _type_get_id_from_type(context, type_id):
|
||||
result = _type_get_id_from_type_query(context, type_id).first()
|
||||
if not result:
|
||||
raise exception.InstanceTypeNotFound(type_id=type_id)
|
||||
raise exception.FlavorNotFound(type_id=type_id)
|
||||
return result.uuid
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
||||
else:
|
||||
# TODO(liusheng) we shouldn't depend on the default
|
||||
# type created by devstack
|
||||
raise exception.InstanceTypeNotFound("'small' type not found.")
|
||||
raise exception.FlavorNotFound("'small' flavor not found.")
|
||||
|
||||
@classmethod
|
||||
def _get_net_id(cls):
|
||||
|
@ -60,7 +60,7 @@ class DbInstanceTypeExtraSpecsTestCase(base.DbTestCase):
|
||||
def test_delete_extra_specs_does_not_exist(self):
|
||||
self.dbapi.extra_specs_update_or_create(
|
||||
self.context, self.instance_type['uuid'], self.specs)
|
||||
self.assertRaises(exception.InstanceTypeExtraSpecsNotFound,
|
||||
self.assertRaises(exception.FlavorExtraSpecsNotFound,
|
||||
self.dbapi.type_extra_specs_delete,
|
||||
self.context,
|
||||
self.instance_type['uuid'],
|
||||
|
@ -34,7 +34,7 @@ class DbInstanceTypeTestCase(base.DbTestCase):
|
||||
utils.create_test_instance_type(name='testing')
|
||||
|
||||
def test_create_instance_type_already_exists(self):
|
||||
self.assertRaises(exception.InstanceTypeAlreadyExists,
|
||||
self.assertRaises(exception.FlavorAlreadyExists,
|
||||
utils.create_test_instance_type,
|
||||
uuid=self.instance_type['uuid'])
|
||||
|
||||
@ -56,7 +56,7 @@ class DbInstanceTypeTestCase(base.DbTestCase):
|
||||
self.assertEqual(self.instance_type['uuid'], instance_type['uuid'])
|
||||
|
||||
def test_get_instance_type_that_does_not_exist(self):
|
||||
self.assertRaises(exception.InstanceTypeNotFound,
|
||||
self.assertRaises(exception.FlavorNotFound,
|
||||
self.dbapi.instance_type_get,
|
||||
self.context,
|
||||
uuidutils.generate_uuid())
|
||||
@ -65,13 +65,13 @@ class DbInstanceTypeTestCase(base.DbTestCase):
|
||||
self.dbapi.instance_type_destroy(self.context,
|
||||
self.instance_type['uuid'])
|
||||
|
||||
self.assertRaises(exception.InstanceTypeNotFound,
|
||||
self.assertRaises(exception.FlavorNotFound,
|
||||
self.dbapi.instance_type_destroy,
|
||||
self.context,
|
||||
self.instance_type['uuid'])
|
||||
|
||||
def test_destroy_instance_type_that_does_not_exist(self):
|
||||
self.assertRaises(exception.InstanceTypeNotFound,
|
||||
self.assertRaises(exception.FlavorNotFound,
|
||||
self.dbapi.instance_type_destroy,
|
||||
self.context,
|
||||
uuidutils.generate_uuid())
|
||||
|
Loading…
Reference in New Issue
Block a user