def update(context, id, name, description, is_public=None): """Update volume type by id.""" if id is None: msg = _("id cannot be None") raise exception.InvalidVolumeType(reason=msg) elevated = context if context.is_admin else context.elevated() old_volume_type = get_volume_type(elevated, id) try: db.volume_type_update(elevated, id, dict(name=name, description=description, is_public=is_public)) # Rename resource in quota if volume type name is changed. if name: old_type_name = old_volume_type.get('name') if old_type_name != name: old_description = old_volume_type.get('description') old_public = old_volume_type.get('is_public') try: QUOTAS.update_quota_resource(elevated, old_type_name, name) # Rollback the updated information to the original except db_exc.DBError: db.volume_type_update(elevated, id, dict(name=old_type_name, description=old_description, is_public=old_public)) raise except db_exc.DBError: LOG.exception('DB error:') raise exception.VolumeTypeUpdateFailed(id=id)
def test_volume_type_update(self): vol_type_ref = volume_types.create(self.ctxt, 'fake volume type') updates = dict(name='test_volume_type_update', description=None, is_public=None) db.volume_type_update(self.ctxt, vol_type_ref.id, updates) updated_vol_type = db.volume_type_get(self.ctxt, vol_type_ref.id) self.assertEqual('test_volume_type_update', updated_vol_type['name']) volume_types.destroy(self.ctxt, vol_type_ref.id)
def update(context, id, name, description): """Update volume type by id.""" if id is None: msg = _("id cannot be None") raise exception.InvalidVolumeType(reason=msg) try: type_updated = db.volume_type_update(context, id, dict(name=name, description=description)) except db_exc.DBError: LOG.exception(_LE("DB error:")) raise exception.VolumeTypeUpdateFailed(id=id) return type_updated
def update(context, id, name, description): """Update volume type by id.""" if id is None: msg = _("id cannot be None") raise exception.InvalidVolumeType(reason=msg) try: type_updated = db.volume_type_update( context, id, dict(name=name, description=description)) except db_exc.DBError as e: LOG.exception(_LE('DB error: %s') % six.text_type(e)) raise exception.VolumeTypeUpdateFailed(id=id) return type_updated
def update(context, id, name, description, is_public=None): """Update volume type by id.""" if id is None: msg = _("id cannot be None") raise exception.InvalidVolumeType(reason=msg) old_volume_type = get_volume_type(context, id) try: type_updated = db.volume_type_update(context, id, dict(name=name, description=description, is_public=is_public)) # Rename resource in quota if volume type name is changed. if name: old_type_name = old_volume_type.get("name") if old_type_name != name: QUOTAS.update_quota_resource(context, old_type_name, name) except db_exc.DBError: LOG.exception(_LE("DB error:")) raise exception.VolumeTypeUpdateFailed(id=id) return type_updated
def update(context, id, name, description, is_public=None): """Update volume type by id.""" if id is None: msg = _("id cannot be None") raise exception.InvalidVolumeType(reason=msg) old_volume_type = get_volume_type(context, id) try: type_updated = db.volume_type_update( context, id, dict(name=name, description=description, is_public=is_public)) # Rename resource in quota if volume type name is changed. if name: old_type_name = old_volume_type.get('name') if old_type_name != name: QUOTAS.update_quota_resource(context, old_type_name, name) except db_exc.DBError: LOG.exception(_LE('DB error:')) raise exception.VolumeTypeUpdateFailed(id=id) return type_updated