from flask_restful import Resource
from flask import Response, request
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
import logging
import json
like the image was just created to make orchestrators, like OSM, happy.
"""
LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
- body_data = json.loads(request.data)
+ try:
+ body_data = json.loads(request.data)
+ except:
+ body_data = dict()
# lets see what we should create
img_name = request.headers.get("X-Image-Meta-Name")
img_size = request.headers.get("X-Image-Meta-Size")
resp['image'] = f
# build actual response with headers and everything
r = Response(json.dumps(resp), status=201, mimetype="application/json")
- r.headers.add("Location", "http://%s:%d/v1/images/%s" % (self.api.ip,
+ r.headers.add("Location", "http://%s:%d/v1/images/%s" % (get_host(request),
self.api.port,
img_id))
return r