Пример #1
0
 def delete(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     return self.send(vimid,
                      request.get_full_path(),
                      request.body,
                      "DELETE",
                      headers=originHeaders(request))
Пример #2
0
 def post(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     content_type = request.META.get('CONTENT_TYPE', 'application/json')
     if content_type.startswith("multipart"):
         return self.__process_multipart(request, vimid)
     return self.send(vimid,
                      request.get_full_path(),
                      request.body,
                      "POST",
                      headers=originHeaders(request))
Пример #3
0
    def post(self, request):
        try:
            body = json.loads(request.body)
        except ValueError as e:
            return Response(data={'error': 'Invalidate request body %s.' % e},
                            status=status.HTTP_400_BAD_REQUEST)

        ret = {"VIMs": []}
        newbody = {
            "vCPU": body.get("vCPU", 0),
            "Memory": body.get("Memory", 0),
            "Storage": body.get("Storage", 0)
        }
        for vim in body.get("VIMs", []):
            cloud_owner = vim["cloud-owner"]
            cloud_region_id = vim["cloud-region-id"]
            url = request.get_full_path().replace(
                "check_vim_capacity",
                "%s/%s/capacity_check" % (cloud_owner, cloud_region_id))
            vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
            resp = self.send(vimid,
                             url,
                             json.dumps(newbody),
                             "POST",
                             headers=originHeaders(request))

            if int(resp.status_code) != status.HTTP_200_OK:
                continue

            try:
                resp_body = json.loads(resp.content)
            except ValueError:
                continue
            if not resp_body.get("result", False):
                continue
            azCapInfo = resp_body.get("AZs", [])
            vim["AZs"] = azCapInfo
            ret['VIMs'].append(vim)
        return Response(data=ret, status=status.HTTP_200_OK)
Пример #4
0
 def put(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     return super(APIv1Forward, self).put(request, vimid)
Пример #5
0
 def get(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     return super(APIv1Extension, self).get(request, vimid)
Пример #6
0
 def delete(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     return super(APIv1UnRegistry, self).delete(request, vimid)
Пример #7
0
 def post(self, request, cloud_owner, cloud_region_id):
     vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
     return super(APIv1Registry, self).post(request, vimid)