def create(self, req, vol_type_id, body): context = req.environ['nova.context'] authorize(context) self._check_body(body) specs = body.get('extra_specs') db.volume_type_extra_specs_update_or_create(context, vol_type_id, specs) return body
def test_volume_type_extra_specs_update(self): expected_specs = self.vol_type1_specs.copy() expected_specs['vol_extra3'] = "4" db.volume_type_extra_specs_update_or_create( context.get_admin_context(), self.volume_type1_id, dict(vol_extra3=4)) actual_specs = db.volume_type_extra_specs_get( context.get_admin_context(), self.volume_type1_id) self.assertEquals(expected_specs, actual_specs)
def create(self, req, vol_type_id, body): self._check_body(body) context = req.environ["nova.context"] specs = body.get("extra_specs") try: db.volume_type_extra_specs_update_or_create(context, vol_type_id, specs) except exception.QuotaError as error: self._handle_quota_error(error) return body
def create(self, req, vol_type_id, body): context = req.environ['nova.context'] authorize(context) self._check_body(body) specs = body.get('extra_specs') db.volume_type_extra_specs_update_or_create(context, vol_type_id, specs) return body
def test_volume_type_extra_specs_create(self): expected_specs = self.vol_type1_specs.copy() expected_specs['vol_extra4'] = 'value4' expected_specs['vol_extra5'] = 'value5' db.volume_type_extra_specs_update_or_create( context.get_admin_context(), self.volume_type1_id, dict(vol_extra4="value4", vol_extra5="value5")) actual_specs = db.volume_type_extra_specs_get( context.get_admin_context(), self.volume_type1_id) self.assertEquals(expected_specs, actual_specs)
def create(self, req, vol_type_id, body): self._check_body(body) context = req.environ['nova.context'] specs = body.get('extra_specs') try: db.volume_type_extra_specs_update_or_create( context, vol_type_id, specs) except exception.QuotaError as error: self._handle_quota_error(error) return body
def test_volume_type_extra_specs_update(self): expected_specs = self.vol_type1_specs.copy() expected_specs['vol_extra3'] = "4" db.volume_type_extra_specs_update_or_create( context.get_admin_context(), self.volume_type1_id, dict(vol_extra3=4)) actual_specs = db.volume_type_extra_specs_get( context.get_admin_context(), self.volume_type1_id) self.assertEquals(expected_specs, actual_specs)
def create(self, req, type_id, body=None): context = req.environ["nova.context"] authorize(context) self._check_type(context, type_id) self._check_body(body) specs = body.get("extra_specs") if not isinstance(specs, dict): expl = _("Malformed extra specs") raise webob.exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, type_id, specs) return body
def create(self, req, type_id, body=None): context = req.environ['nova.context'] authorize(context) self._check_type(context, type_id) self._check_body(body) specs = body.get('extra_specs') if not isinstance(specs, dict): expl = _('Malformed extra specs') raise webob.exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, type_id, specs) return body
def create(self, req, vol_type_id, body): context = req.environ['nova.context'] authorize(context) self._check_body(body) specs = body.get('extra_specs') try: db.volume_type_extra_specs_update_or_create(context, vol_type_id, specs) except exception.QuotaError as error: self._handle_quota_error(error) return body
def create(self, req, type_id, body=None): context = req.environ['nova.context'] authorize(context) if not self.is_valid_body(body, 'extra_specs'): raise webob.exc.HTTPUnprocessableEntity() self._check_type(context, type_id) specs = body['extra_specs'] db.volume_type_extra_specs_update_or_create(context, type_id, specs) return body
def update(self, req, vol_type_id, id, body): context = req.environ['nova.context'] authorize(context) self._check_body(body) if not id in body: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, vol_type_id, body) return body
def update(self, req, type_id, id, body=None): context = req.environ["nova.context"] authorize(context) self._check_type(context, type_id) self._check_body(body) if not id in body: expl = _("Request body and URI mismatch") raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _("Request body contains too many items") raise webob.exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, type_id, body) return body
def test_volume_type_extra_specs_create(self): expected_specs = self.vol_type1_specs.copy() expected_specs['vol_extra4'] = 'value4' expected_specs['vol_extra5'] = 'value5' db.volume_type_extra_specs_update_or_create( context.get_admin_context(), self.volume_type1_id, dict(vol_extra4="value4", vol_extra5="value5")) actual_specs = db.volume_type_extra_specs_get( context.get_admin_context(), self.volume_type1_id) self.assertEquals(expected_specs, actual_specs)
def create(self, req, type_id, body=None): context = req.environ['nova.context'] authorize(context) if not self.is_valid_body(body, 'extra_specs'): raise webob.exc.HTTPUnprocessableEntity() self._check_type(context, type_id) specs = body['extra_specs'] db.volume_type_extra_specs_update_or_create(context, type_id, specs) return body
def update(self, req, type_id, id, body=None): context = req.environ['nova.context'] authorize(context) if not body: raise webob.exc.HTTPUnprocessableEntity() self._check_type(context, type_id) if not id in body: expl = _('Request body and URI mismatch') raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise webob.exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, type_id, body) return body
def update(self, req, vol_type_id, id, body): context = req.environ['nova.context'] authorize(context) self._check_body(body) if not id in body: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, vol_type_id, body) return body
def update(self, req, vol_type_id, id, body): self._check_body(body) context = req.environ["nova.context"] if not id in body: expl = _("Request body and URI mismatch") raise exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _("Request body contains too many items") raise exc.HTTPBadRequest(explanation=expl) try: db.volume_type_extra_specs_update_or_create(context, vol_type_id, body) except exception.QuotaError as error: self._handle_quota_error(error) return body
def update(self, req, vol_type_id, id, body): self._check_body(body) context = req.environ['nova.context'] if not id in body: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) try: db.volume_type_extra_specs_update_or_create( context, vol_type_id, body) except exception.QuotaError as error: self._handle_quota_error(error) return body
def update(self, req, type_id, id, body=None): context = req.environ['nova.context'] authorize(context) if not body: raise webob.exc.HTTPUnprocessableEntity() self._check_type(context, type_id) if not id in body: expl = _('Request body and URI mismatch') raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise webob.exc.HTTPBadRequest(explanation=expl) db.volume_type_extra_specs_update_or_create(context, type_id, body) return body