From aa4d27cf6ecf9dd7037b1c8292268467efca1805 Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 19 Jun 2019 10:21:25 +0200 Subject: [PATCH] Fix: Allow CORS to fetch emulator state Change-Id: I26e0cc5a570bdc35ec27b9eeb2c4ec528bdf8bf3 Signed-off-by: peusterm --- src/emuvim/api/tango/llcm.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/emuvim/api/tango/llcm.py b/src/emuvim/api/tango/llcm.py index 8b4a350..75c71bf 100755 --- a/src/emuvim/api/tango/llcm.py +++ b/src/emuvim/api/tango/llcm.py @@ -52,6 +52,10 @@ LOG = logging.getLogger("5gtango.llcm") LOG.setLevel(logging.INFO) +CORS_HEADER = {'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET,OPTIONS'} + + GK_STORAGE = "/tmp/vim-emu-tango-llcm/" UPLOAD_FOLDER = os.path.join(GK_STORAGE, "uploads/") CATALOG_FOLDER = os.path.join(GK_STORAGE, "catalog/") @@ -1038,7 +1042,7 @@ class Packages(fr.Resource): pkg["pd"]["version"] = sobj.manifest.get("version") pkg["created_at"] = sobj.created_at result.append(pkg) - return result, 200 + return result, 200, CORS_HEADER class Services(fr.Resource): @@ -1060,7 +1064,7 @@ class Services(fr.Resource): service["nsd"]["version"] = sobj.nsd.get("version") service["created_at"] = sobj.created_at result.append(service) - return result, 200 + return result, 200, CORS_HEADER class Instantiations(fr.Resource): @@ -1107,7 +1111,7 @@ class Instantiations(fr.Resource): Returns a list of UUIDs containing all running services. :return: dict / list """ - LOG.info("GET /instantiations or /api/v3/records/services") + LOG.debug("GET /instantiations or /api/v3/records/services") # return {"service_instantiations_list": [ # list(s.instances.iterkeys()) for s in GK.services.itervalues()]} result = list() @@ -1120,7 +1124,7 @@ class Instantiations(fr.Resource): inst["status"] = "running" inst["created_at"] = iobj.get("created_at") result.append(inst) - return result, 200 + return result, 200, CORS_HEADER def delete(self): """ -- 2.25.1