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 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)
Example #3
0
 def create(self, req, vol_type_id, body):
     self._check_body(body)
     context = req.environ['engine.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):
     self._check_body(body)
     context = req.environ['engine.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 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)
Example #7
0
    def update(self, req, vol_type_id, id, body):
        self._check_body(body)
        context = req.environ['engine.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['engine.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