コード例 #1
0
 def create(self, req, flavor_id, body):
     self._check_body(body)
     context = req.environ['engine.context']
     specs = body.get('extra_specs')
     try:
         db.instance_type_extra_specs_update_or_create(
             context, flavor_id, specs)
     except exception.QuotaError as error:
         self._handle_quota_error(error)
     return body
コード例 #2
0
 def create(self, req, flavor_id, body):
     self._check_body(body)
     context = req.environ['engine.context']
     specs = body.get('extra_specs')
     try:
         db.instance_type_extra_specs_update_or_create(context,
                                                           flavor_id,
                                                           specs)
     except exception.QuotaError as error:
         self._handle_quota_error(error)
     return body
コード例 #3
0
 def test_instance_type_extra_specs_update(self):
     expected_specs = dict(cpu_arch="x86_64",
                              cpu_model="Sandy Bridge",
                              xpu_arch="fermi",
                              xpus="2",
                              xpu_model="Tesla 2050")
     db.instance_type_extra_specs_update_or_create(
                           self.context,
                           self.instance_type_id,
                           dict(cpu_model="Sandy Bridge"))
     actual_specs = db.instance_type_extra_specs_get(
                           self.context,
                           self.instance_type_id)
     self.assertEquals(expected_specs, actual_specs)
コード例 #4
0
    def update(self, req, flavor_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.instance_type_extra_specs_update_or_create(
                context, flavor_id, body)
        except exception.QuotaError as error:
            self._handle_quota_error(error)

        return body
コード例 #5
0
 def test_instance_type_extra_specs_create(self):
     expected_specs = dict(cpu_arch="x86_64",
                              cpu_model="Nehalem",
                              xpu_arch="fermi",
                              xpus="2",
                              xpu_model="Tesla 2050",
                              net_arch="ethernet",
                              net_mbps="10000")
     db.instance_type_extra_specs_update_or_create(
                           self.context,
                           self.instance_type_id,
                           dict(net_arch="ethernet",
                                net_mbps=10000))
     actual_specs = db.instance_type_extra_specs_get(
                           self.context,
                           self.instance_type_id)
     self.assertEquals(expected_specs, actual_specs)
コード例 #6
0
    def update(self, req, flavor_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.instance_type_extra_specs_update_or_create(context,
                                                               flavor_id,
                                                               body)
        except exception.QuotaError as error:
            self._handle_quota_error(error)

        return body