]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Return BadRequest for invalid unicode names (continued)
authorEric Harney <eharney@redhat.com>
Mon, 29 Feb 2016 20:22:07 +0000 (15:22 -0500)
committerEric Harney <eharney@redhat.com>
Mon, 29 Feb 2016 20:40:39 +0000 (15:40 -0500)
Follow-up to "Return BadRequest for invalid Unicode names",
we missed a couple of operations here:
  type-key set
  quota-class-update
  qos-create

Related-Bug: #1531400

Change-Id: Id966b74dce87acb15ede9cb4c02ae0f74d59b08c

cinder/db/sqlalchemy/api.py
cinder/volume/qos_specs.py

index 89afe4a0001b74464d7c0d49a3d233de7f7e689c..66af8310e98c27d789024874729c03e82577fddf 100644 (file)
@@ -689,6 +689,7 @@ def _quota_class_get_all_by_resource(context, resource, session):
     return result
 
 
+@handle_db_data_error
 @require_admin_context
 def quota_class_create(context, class_name, resource, limit):
     quota_class_ref = models.QuotaClass()
@@ -2946,6 +2947,7 @@ def _volume_type_extra_specs_get_item(context, volume_type_id, key,
     return result
 
 
+@handle_db_data_error
 @require_context
 def volume_type_extra_specs_update_or_create(context, volume_type_id,
                                              specs):
@@ -3010,6 +3012,10 @@ def qos_specs_create(context, values):
                 spec_entry = models.QualityOfServiceSpecs()
                 spec_entry.update(item)
                 spec_entry.save(session=session)
+        except db_exc.DBDataError:
+            msg = _('Error writing field to database')
+            LOG.exception(msg)
+            raise exception.Invalid(msg)
         except Exception as e:
             raise db_exc.DBError(e)
 
index 52527d78e23519c73d001ed11145c62329e67a27..49668f2fc102aae691d9a308e82cdb35b6ea1615 100644 (file)
@@ -79,6 +79,10 @@ def create(context, name, specs=None):
 
     try:
         qos_specs_ref = db.qos_specs_create(context, values)
+    except db_exc.DBDataError:
+        msg = _('Error writing field to database')
+        LOG.exception(msg)
+        raise exception.Invalid(msg)
     except db_exc.DBError:
         LOG.exception(_LE('DB error:'))
         raise exception.QoSSpecsCreateFailed(name=name,