Convert volume_type id from int to uuid.
This converts the volume_type id from int to uuid. In addition, this also corrects an issue of deleting volume_types by name. Even though the client/api is taking the id, it was converting to the name of the volume_type for the db access. We also want to continue enforcing that the name is unique on creation so as to avoid any confusion and for clarity in Horizon. The api has also been enhanced to allow you to specify the type by name or by uuid. This does NOT modify the things like the volume details display field (currently shows the type 'name' not 'uuid'), these types of changes will go in to V2 of the API. Implements blueprint vol-type-to-uuid Change-Id: I1c54ff2a1e0c5df5891408fc11b15176db4028c3
This commit is contained in:

committed by
John Griffith

parent
b1e4232996
commit
51a438c8f3
@@ -34,22 +34,23 @@ LOG = logging.getLogger(__name__)
|
||||
def create(context, name, extra_specs={}):
|
||||
"""Creates volume types."""
|
||||
try:
|
||||
db.volume_type_create(context,
|
||||
dict(name=name,
|
||||
extra_specs=extra_specs))
|
||||
type_ref = db.volume_type_create(context,
|
||||
dict(name=name,
|
||||
extra_specs=extra_specs))
|
||||
except exception.DBError, e:
|
||||
LOG.exception(_('DB error: %s') % e)
|
||||
raise exception.VolumeTypeCreateFailed(name=name,
|
||||
extra_specs=extra_specs)
|
||||
return type_ref
|
||||
|
||||
|
||||
def destroy(context, name):
|
||||
def destroy(context, id):
|
||||
"""Marks volume types as deleted."""
|
||||
if name is None:
|
||||
msg = _("name cannot be None")
|
||||
if id is None:
|
||||
msg = _("id cannot be None")
|
||||
raise exception.InvalidVolumeType(reason=msg)
|
||||
else:
|
||||
db.volume_type_destroy(context, name)
|
||||
db.volume_type_destroy(context, id)
|
||||
|
||||
|
||||
def get_all_types(context, inactive=0, search_opts={}):
|
||||
|
Reference in New Issue
Block a user