blob: c5de3cc7b42f83ae3427af2c7e9d6219f939a2da [file] [log] [blame]
peusterme26487b2016-03-08 14:00:21 +01001"""
2This module implements a simple REST API that behaves like SONATA's gatekeeper.
3
4It is only used to support the development of SONATA's SDK tools and to demonstrate
5the year 1 version of the emulator until the integration with WP4's orchestrator is done.
6"""
7
8import logging
9import os
10import uuid
11import hashlib
peusterm786cd542016-03-14 14:12:17 +010012import zipfile
peusterm7ec665d2016-03-14 15:20:44 +010013import yaml
peustermbdfab7e2016-03-14 16:03:30 +010014from docker import Client as DockerClient
peusterme26487b2016-03-08 14:00:21 +010015from flask import Flask, request
16import flask_restful as fr
wtaverni5b23b662016-06-20 12:26:21 +020017from collections import defaultdict
peusterme26487b2016-03-08 14:00:21 +010018
peusterm398cd3b2016-03-21 15:04:54 +010019logging.basicConfig()
peusterm786cd542016-03-14 14:12:17 +010020LOG = logging.getLogger("sonata-dummy-gatekeeper")
21LOG.setLevel(logging.DEBUG)
peusterme26487b2016-03-08 14:00:21 +010022logging.getLogger("werkzeug").setLevel(logging.WARNING)
23
peusterm92237dc2016-03-21 15:45:58 +010024GK_STORAGE = "/tmp/son-dummy-gk/"
25UPLOAD_FOLDER = os.path.join(GK_STORAGE, "uploads/")
26CATALOG_FOLDER = os.path.join(GK_STORAGE, "catalog/")
peusterme26487b2016-03-08 14:00:21 +010027
peusterm82d406e2016-05-02 20:52:06 +020028# Enable Dockerfile build functionality
29BUILD_DOCKERFILE = False
30
peusterm398cd3b2016-03-21 15:04:54 +010031# flag to indicate that we run without the emulator (only the bare API for integration testing)
32GK_STANDALONE_MODE = False
33
peusterm56356cb2016-05-03 10:43:43 +020034# should a new version of an image be pulled even if its available
wtaverni5b23b662016-06-20 12:26:21 +020035FORCE_PULL = False
peusterme26487b2016-03-08 14:00:21 +010036
37class Gatekeeper(object):
38
39 def __init__(self):
peusterm786cd542016-03-14 14:12:17 +010040 self.services = dict()
peusterm082378b2016-03-16 20:14:22 +010041 self.dcs = dict()
peusterm3444ae42016-03-16 20:46:41 +010042 self.vnf_counter = 0 # used to generate short names for VNFs (Mininet limitation)
peusterm786cd542016-03-14 14:12:17 +010043 LOG.info("Create SONATA dummy gatekeeper.")
peusterme26487b2016-03-08 14:00:21 +010044
peusterm786cd542016-03-14 14:12:17 +010045 def register_service_package(self, service_uuid, service):
46 """
47 register new service package
48 :param service_uuid
49 :param service object
50 """
51 self.services[service_uuid] = service
52 # lets perform all steps needed to onboard the service
53 service.onboard()
54
peusterm3444ae42016-03-16 20:46:41 +010055 def get_next_vnf_name(self):
56 self.vnf_counter += 1
peusterm398cd3b2016-03-21 15:04:54 +010057 return "vnf%d" % self.vnf_counter
peusterm3444ae42016-03-16 20:46:41 +010058
peusterm786cd542016-03-14 14:12:17 +010059
60class Service(object):
61 """
62 This class represents a NS uploaded as a *.son package to the
63 dummy gatekeeper.
64 Can have multiple running instances of this service.
65 """
66
67 def __init__(self,
68 service_uuid,
69 package_file_hash,
70 package_file_path):
71 self.uuid = service_uuid
72 self.package_file_hash = package_file_hash
73 self.package_file_path = package_file_path
74 self.package_content_path = os.path.join(CATALOG_FOLDER, "services/%s" % self.uuid)
peusterm7ec665d2016-03-14 15:20:44 +010075 self.manifest = None
76 self.nsd = None
77 self.vnfds = dict()
peustermbdfab7e2016-03-14 16:03:30 +010078 self.local_docker_files = dict()
peusterm82d406e2016-05-02 20:52:06 +020079 self.remote_docker_image_urls = dict()
peusterm786cd542016-03-14 14:12:17 +010080 self.instances = dict()
wtaverni5b23b662016-06-20 12:26:21 +020081 self.vnfname2num = dict()
peusterme26487b2016-03-08 14:00:21 +010082
peusterm786cd542016-03-14 14:12:17 +010083 def onboard(self):
84 """
85 Do all steps to prepare this service to be instantiated
86 :return:
87 """
88 # 1. extract the contents of the package and store them in our catalog
89 self._unpack_service_package()
90 # 2. read in all descriptor files
peusterm7ec665d2016-03-14 15:20:44 +010091 self._load_package_descriptor()
92 self._load_nsd()
93 self._load_vnfd()
peusterm786cd542016-03-14 14:12:17 +010094 # 3. prepare container images (e.g. download or build Dockerfile)
peusterm82d406e2016-05-02 20:52:06 +020095 if BUILD_DOCKERFILE:
96 self._load_docker_files()
97 self._build_images_from_dockerfiles()
98 else:
99 self._load_docker_urls()
100 self._pull_predefined_dockerimages()
peusterm7ec665d2016-03-14 15:20:44 +0100101 LOG.info("On-boarded service: %r" % self.manifest.get("package_name"))
102
peusterm082378b2016-03-16 20:14:22 +0100103 def start_service(self):
peusterm3444ae42016-03-16 20:46:41 +0100104 """
105 This methods creates and starts a new service instance.
106 It computes placements, iterates over all VNFDs, and starts
107 each VNFD as a Docker container in the data center selected
108 by the placement algorithm.
109 :return:
110 """
111 LOG.info("Starting service %r" % self.uuid)
stevenvanrossemd87fe472016-05-11 11:34:34 +0200112
peusterm3444ae42016-03-16 20:46:41 +0100113 # 1. each service instance gets a new uuid to identify it
peusterm082378b2016-03-16 20:14:22 +0100114 instance_uuid = str(uuid.uuid4())
peusterm3444ae42016-03-16 20:46:41 +0100115 # build a instances dict (a bit like a NSR :))
116 self.instances[instance_uuid] = dict()
117 self.instances[instance_uuid]["vnf_instances"] = list()
stevenvanrossemd87fe472016-05-11 11:34:34 +0200118
peusterm3444ae42016-03-16 20:46:41 +0100119 # 2. compute placement of this service instance (adds DC names to VNFDs)
peusterm398cd3b2016-03-21 15:04:54 +0100120 if not GK_STANDALONE_MODE:
121 self._calculate_placement(FirstDcPlacement)
peusterm3444ae42016-03-16 20:46:41 +0100122 # iterate over all vnfds that we have to start
peusterm082378b2016-03-16 20:14:22 +0100123 for vnfd in self.vnfds.itervalues():
peusterm398cd3b2016-03-21 15:04:54 +0100124 vnfi = None
125 if not GK_STANDALONE_MODE:
126 vnfi = self._start_vnfd(vnfd)
127 self.instances[instance_uuid]["vnf_instances"].append(vnfi)
stevenvanrossemd87fe472016-05-11 11:34:34 +0200128
129 # 3. Configure the chaining of the network functions (currently only E-Line links supported)
wtaverni5b23b662016-06-20 12:26:21 +0200130 nfid2name = defaultdict(lambda :"NotExistingNode",
131 reduce(lambda x,y: dict(x, **y),
132 map(lambda d:{d["vnf_id"]:d["vnf_name"]},
133 self.nsd["network_functions"])))
134
stevenvanrossemd87fe472016-05-11 11:34:34 +0200135 vlinks = self.nsd["virtual_links"]
136 fwd_links = self.nsd["forwarding_graphs"][0]["constituent_virtual_links"]
137 eline_fwd_links = [l for l in vlinks if (l["id"] in fwd_links) and (l["connectivity_type"] == "E-Line")]
138
wtaverni5b23b662016-06-20 12:26:21 +0200139 cookie = 1 # not clear why this is needed - to check with Steven
stevenvanrossemd87fe472016-05-11 11:34:34 +0200140 for link in eline_fwd_links:
141 src_node, src_port = link["connection_points_reference"][0].split(":")
142 dst_node, dst_port = link["connection_points_reference"][1].split(":")
143
wtaverni5b23b662016-06-20 12:26:21 +0200144 srcname = nfid2name[src_node]
145 dstname = nfid2name[dst_node]
146 LOG.debug("src name: "+srcname+" dst name: "+dstname)
peusterm9fb74ec2016-06-16 11:30:55 +0200147
wtaverni5b23b662016-06-20 12:26:21 +0200148 if (srcname in self.vnfds) and (dstname in self.vnfds) :
149 network = self.vnfds[srcname].get("dc").net # there should be a cleaner way to find the DCNetwork
150 src_vnf = self.vnfname2num[srcname]
151 dst_vnf = self.vnfname2num[dstname]
152 ret = network.setChain(src_vnf, dst_vnf, vnf_src_interface=src_port, vnf_dst_interface=dst_port, bidirectional = True, cmd="add-flow", cookie = cookie)
153 cookie += 1
stevenvanrossemd87fe472016-05-11 11:34:34 +0200154
peusterm3444ae42016-03-16 20:46:41 +0100155 LOG.info("Service started. Instance id: %r" % instance_uuid)
peusterm082378b2016-03-16 20:14:22 +0100156 return instance_uuid
157
peusterm398cd3b2016-03-21 15:04:54 +0100158 def _start_vnfd(self, vnfd):
159 """
160 Start a single VNFD of this service
161 :param vnfd: vnfd descriptor dict
162 :return:
163 """
164 # iterate over all deployment units within each VNFDs
165 for u in vnfd.get("virtual_deployment_units"):
166 # 1. get the name of the docker image to start and the assigned DC
peusterm56356cb2016-05-03 10:43:43 +0200167 vnf_name = vnfd.get("name")
168 if vnf_name not in self.remote_docker_image_urls:
169 raise Exception("No image name for %r found. Abort." % vnf_name)
170 docker_name = self.remote_docker_image_urls.get(vnf_name)
peusterm398cd3b2016-03-21 15:04:54 +0100171 target_dc = vnfd.get("dc")
172 # 2. perform some checks to ensure we can start the container
173 assert(docker_name is not None)
174 assert(target_dc is not None)
175 if not self._check_docker_image_exists(docker_name):
176 raise Exception("Docker image %r not found. Abort." % docker_name)
177 # 3. do the dc.startCompute(name="foobar") call to run the container
178 # TODO consider flavors, and other annotations
stevenvanrossemd87fe472016-05-11 11:34:34 +0200179 intfs = vnfd.get("connection_points")
wtaverni5b23b662016-06-20 12:26:21 +0200180 self.vnfname2num[vnf_name] = GK.get_next_vnf_name()
181 LOG.info("VNF "+vnf_name+" mapped to "+self.vnfname2num[vnf_name]+" on dc "+str(vnfd.get("dc")))
182 vnfi = target_dc.startCompute(self.vnfname2num[vnf_name], network=intfs, image=docker_name, flavor_name="small")
peusterm398cd3b2016-03-21 15:04:54 +0100183 # 6. store references to the compute objects in self.instances
184 return vnfi
185
peusterm786cd542016-03-14 14:12:17 +0100186 def _unpack_service_package(self):
187 """
188 unzip *.son file and store contents in CATALOG_FOLDER/services/<service_uuid>/
189 """
peusterm82d406e2016-05-02 20:52:06 +0200190 LOG.info("Unzipping: %r" % self.package_file_path)
peusterm786cd542016-03-14 14:12:17 +0100191 with zipfile.ZipFile(self.package_file_path, "r") as z:
192 z.extractall(self.package_content_path)
193
peusterm82d406e2016-05-02 20:52:06 +0200194
peusterm7ec665d2016-03-14 15:20:44 +0100195 def _load_package_descriptor(self):
196 """
197 Load the main package descriptor YAML and keep it as dict.
198 :return:
199 """
200 self.manifest = load_yaml(
201 os.path.join(
202 self.package_content_path, "META-INF/MANIFEST.MF"))
203
204 def _load_nsd(self):
205 """
206 Load the entry NSD YAML and keep it as dict.
207 :return:
208 """
209 if "entry_service_template" in self.manifest:
210 nsd_path = os.path.join(
211 self.package_content_path,
212 make_relative_path(self.manifest.get("entry_service_template")))
213 self.nsd = load_yaml(nsd_path)
peusterm757fe9a2016-04-04 14:11:58 +0200214 LOG.debug("Loaded NSD: %r" % self.nsd.get("name"))
peusterm7ec665d2016-03-14 15:20:44 +0100215
216 def _load_vnfd(self):
217 """
218 Load all VNFD YAML files referenced in MANIFEST.MF and keep them in dict.
219 :return:
220 """
221 if "package_content" in self.manifest:
222 for pc in self.manifest.get("package_content"):
223 if pc.get("content-type") == "application/sonata.function_descriptor":
224 vnfd_path = os.path.join(
225 self.package_content_path,
226 make_relative_path(pc.get("name")))
227 vnfd = load_yaml(vnfd_path)
peusterm757fe9a2016-04-04 14:11:58 +0200228 self.vnfds[vnfd.get("name")] = vnfd
229 LOG.debug("Loaded VNFD: %r" % vnfd.get("name"))
peusterm7ec665d2016-03-14 15:20:44 +0100230
231 def _load_docker_files(self):
232 """
peusterm9d7d4b02016-03-23 19:56:44 +0100233 Get all paths to Dockerfiles from VNFDs and store them in dict.
peusterm7ec665d2016-03-14 15:20:44 +0100234 :return:
235 """
peusterm9d7d4b02016-03-23 19:56:44 +0100236 for k, v in self.vnfds.iteritems():
237 for vu in v.get("virtual_deployment_units"):
238 if vu.get("vm_image_format") == "docker":
239 vm_image = vu.get("vm_image")
peusterm7ec665d2016-03-14 15:20:44 +0100240 docker_path = os.path.join(
241 self.package_content_path,
peusterm9d7d4b02016-03-23 19:56:44 +0100242 make_relative_path(vm_image))
243 self.local_docker_files[k] = docker_path
peusterm56356cb2016-05-03 10:43:43 +0200244 LOG.debug("Found Dockerfile (%r): %r" % (k, docker_path))
peusterm7ec665d2016-03-14 15:20:44 +0100245
peusterm82d406e2016-05-02 20:52:06 +0200246 def _load_docker_urls(self):
247 """
248 Get all URLs to pre-build docker images in some repo.
249 :return:
250 """
251 for k, v in self.vnfds.iteritems():
252 for vu in v.get("virtual_deployment_units"):
253 if vu.get("vm_image_format") == "docker":
peusterm35ba4052016-05-02 21:21:14 +0200254 url = vu.get("vm_image")
255 if url is not None:
256 url = url.replace("http://", "")
257 self.remote_docker_image_urls[k] = url
peusterm56356cb2016-05-03 10:43:43 +0200258 LOG.debug("Found Docker image URL (%r): %r" % (k, self.remote_docker_image_urls[k]))
peusterm82d406e2016-05-02 20:52:06 +0200259
peustermbdfab7e2016-03-14 16:03:30 +0100260 def _build_images_from_dockerfiles(self):
261 """
262 Build Docker images for each local Dockerfile found in the package: self.local_docker_files
263 """
peusterm398cd3b2016-03-21 15:04:54 +0100264 if GK_STANDALONE_MODE:
265 return # do not build anything in standalone mode
peustermbdfab7e2016-03-14 16:03:30 +0100266 dc = DockerClient()
267 LOG.info("Building %d Docker images (this may take several minutes) ..." % len(self.local_docker_files))
268 for k, v in self.local_docker_files.iteritems():
269 for line in dc.build(path=v.replace("Dockerfile", ""), tag=k, rm=False, nocache=False):
270 LOG.debug("DOCKER BUILD: %s" % line)
271 LOG.info("Docker image created: %s" % k)
272
peusterm82d406e2016-05-02 20:52:06 +0200273 def _pull_predefined_dockerimages(self):
peustermbdfab7e2016-03-14 16:03:30 +0100274 """
275 If the package contains URLs to pre-build Docker images, we download them with this method.
276 """
peusterm35ba4052016-05-02 21:21:14 +0200277 dc = DockerClient()
278 for url in self.remote_docker_image_urls.itervalues():
peusterm56356cb2016-05-03 10:43:43 +0200279 if not FORCE_PULL: # only pull if not present (speedup for development)
280 if len(dc.images(name=url)) > 0:
281 LOG.debug("Image %r present. Skipping pull." % url)
282 continue
peusterm35ba4052016-05-02 21:21:14 +0200283 LOG.info("Pulling image: %r" % url)
284 dc.pull(url,
285 insecure_registry=True)
peusterm786cd542016-03-14 14:12:17 +0100286
peusterm3444ae42016-03-16 20:46:41 +0100287 def _check_docker_image_exists(self, image_name):
peusterm3f307142016-03-16 21:02:53 +0100288 """
289 Query the docker service and check if the given image exists
290 :param image_name: name of the docker image
291 :return:
292 """
293 return len(DockerClient().images(image_name)) > 0
peusterm3444ae42016-03-16 20:46:41 +0100294
peusterm082378b2016-03-16 20:14:22 +0100295 def _calculate_placement(self, algorithm):
296 """
297 Do placement by adding the a field "dc" to
298 each VNFD that points to one of our
299 data center objects known to the gatekeeper.
300 """
301 assert(len(self.vnfds) > 0)
302 assert(len(GK.dcs) > 0)
303 # instantiate algorithm an place
304 p = algorithm()
305 p.place(self.nsd, self.vnfds, GK.dcs)
306 LOG.info("Using placement algorithm: %r" % p.__class__.__name__)
307 # lets print the placement result
308 for name, vnfd in self.vnfds.iteritems():
309 LOG.info("Placed VNF %r on DC %r" % (name, str(vnfd.get("dc"))))
310
311
312"""
313Some (simple) placement algorithms
314"""
315
316
317class FirstDcPlacement(object):
318 """
319 Placement: Always use one and the same data center from the GK.dcs dict.
320 """
321 def place(self, nsd, vnfds, dcs):
322 for name, vnfd in vnfds.iteritems():
323 vnfd["dc"] = list(dcs.itervalues())[0]
324
peusterme26487b2016-03-08 14:00:21 +0100325
326"""
327Resource definitions and API endpoints
328"""
329
330
331class Packages(fr.Resource):
332
333 def post(self):
334 """
peusterm26455852016-03-08 14:23:53 +0100335 Upload a *.son service package to the dummy gatekeeper.
336
peusterme26487b2016-03-08 14:00:21 +0100337 We expect request with a *.son file and store it in UPLOAD_FOLDER
peusterm26455852016-03-08 14:23:53 +0100338 :return: UUID
peusterme26487b2016-03-08 14:00:21 +0100339 """
340 try:
341 # get file contents
wtavernib8d9ecb2016-03-25 15:18:31 +0100342 print(request.files)
peusterm593ca582016-03-30 19:55:01 +0200343 # lets search for the package in the request
344 if "package" in request.files:
345 son_file = request.files["package"]
346 # elif "file" in request.files:
347 # son_file = request.files["file"]
348 else:
349 return {"service_uuid": None, "size": 0, "sha1": None, "error": "upload failed. file not found."}, 500
peusterme26487b2016-03-08 14:00:21 +0100350 # generate a uuid to reference this package
351 service_uuid = str(uuid.uuid4())
peusterm786cd542016-03-14 14:12:17 +0100352 file_hash = hashlib.sha1(str(son_file)).hexdigest()
peusterme26487b2016-03-08 14:00:21 +0100353 # ensure that upload folder exists
354 ensure_dir(UPLOAD_FOLDER)
355 upload_path = os.path.join(UPLOAD_FOLDER, "%s.son" % service_uuid)
356 # store *.son file to disk
peusterm786cd542016-03-14 14:12:17 +0100357 son_file.save(upload_path)
peusterme26487b2016-03-08 14:00:21 +0100358 size = os.path.getsize(upload_path)
peusterm786cd542016-03-14 14:12:17 +0100359 # create a service object and register it
360 s = Service(service_uuid, file_hash, upload_path)
361 GK.register_service_package(service_uuid, s)
peusterme26487b2016-03-08 14:00:21 +0100362 # generate the JSON result
peusterm786cd542016-03-14 14:12:17 +0100363 return {"service_uuid": service_uuid, "size": size, "sha1": file_hash, "error": None}
peusterme26487b2016-03-08 14:00:21 +0100364 except Exception as ex:
peusterm786cd542016-03-14 14:12:17 +0100365 LOG.exception("Service package upload failed:")
peusterm593ca582016-03-30 19:55:01 +0200366 return {"service_uuid": None, "size": 0, "sha1": None, "error": "upload failed"}, 500
peusterme26487b2016-03-08 14:00:21 +0100367
368 def get(self):
peusterm26455852016-03-08 14:23:53 +0100369 """
370 Return a list of UUID's of uploaded service packages.
371 :return: dict/list
372 """
peusterm786cd542016-03-14 14:12:17 +0100373 return {"service_uuid_list": list(GK.services.iterkeys())}
peusterme26487b2016-03-08 14:00:21 +0100374
375
376class Instantiations(fr.Resource):
377
378 def post(self):
peusterm26455852016-03-08 14:23:53 +0100379 """
380 Instantiate a service specified by its UUID.
381 Will return a new UUID to identify the running service instance.
382 :return: UUID
383 """
peusterm64b45502016-03-16 21:15:14 +0100384 # try to extract the service uuid from the request
peusterm26455852016-03-08 14:23:53 +0100385 json_data = request.get_json(force=True)
peusterm64b45502016-03-16 21:15:14 +0100386 service_uuid = json_data.get("service_uuid")
387
388 # lets be a bit fuzzy here to make testing easier
389 if service_uuid is None and len(GK.services) > 0:
390 # if we don't get a service uuid, we simple start the first service in the list
391 service_uuid = list(GK.services.iterkeys())[0]
392
peustermbea87372016-03-16 19:37:35 +0100393 if service_uuid in GK.services:
peusterm64b45502016-03-16 21:15:14 +0100394 # ok, we have a service uuid, lets start the service
peustermbea87372016-03-16 19:37:35 +0100395 service_instance_uuid = GK.services.get(service_uuid).start_service()
peusterm26455852016-03-08 14:23:53 +0100396 return {"service_instance_uuid": service_instance_uuid}
peustermbea87372016-03-16 19:37:35 +0100397 return "Service not found", 404
peusterme26487b2016-03-08 14:00:21 +0100398
399 def get(self):
peusterm26455852016-03-08 14:23:53 +0100400 """
401 Returns a list of UUIDs containing all running services.
402 :return: dict / list
403 """
peusterm64b45502016-03-16 21:15:14 +0100404 return {"service_instance_list": [
405 list(s.instances.iterkeys()) for s in GK.services.itervalues()]}
peusterm786cd542016-03-14 14:12:17 +0100406
peusterme26487b2016-03-08 14:00:21 +0100407
408# create a single, global GK object
409GK = Gatekeeper()
410# setup Flask
411app = Flask(__name__)
412app.config['MAX_CONTENT_LENGTH'] = 512 * 1024 * 1024 # 512 MB max upload
413api = fr.Api(app)
414# define endpoints
peusterm593ca582016-03-30 19:55:01 +0200415api.add_resource(Packages, '/packages')
416api.add_resource(Instantiations, '/instantiations')
peusterme26487b2016-03-08 14:00:21 +0100417
418
peusterm082378b2016-03-16 20:14:22 +0100419def start_rest_api(host, port, datacenters=dict()):
peustermbea87372016-03-16 19:37:35 +0100420 GK.dcs = datacenters
peusterme26487b2016-03-08 14:00:21 +0100421 # start the Flask server (not the best performance but ok for our use case)
422 app.run(host=host,
423 port=port,
424 debug=True,
425 use_reloader=False # this is needed to run Flask in a non-main thread
426 )
427
428
429def ensure_dir(name):
430 if not os.path.exists(name):
peusterm7ec665d2016-03-14 15:20:44 +0100431 os.makedirs(name)
432
433
434def load_yaml(path):
435 with open(path, "r") as f:
436 try:
437 r = yaml.load(f)
438 except yaml.YAMLError as exc:
439 LOG.exception("YAML parse error")
440 r = dict()
441 return r
442
443
444def make_relative_path(path):
peusterm9d7d4b02016-03-23 19:56:44 +0100445 if path.startswith("file://"):
446 path = path.replace("file://", "", 1)
peusterm7ec665d2016-03-14 15:20:44 +0100447 if path.startswith("/"):
peusterm9d7d4b02016-03-23 19:56:44 +0100448 path = path.replace("/", "", 1)
peusterm7ec665d2016-03-14 15:20:44 +0100449 return path
450
451
peusterme26487b2016-03-08 14:00:21 +0100452if __name__ == '__main__':
453 """
454 Lets allow to run the API in standalone mode.
455 """
peusterm398cd3b2016-03-21 15:04:54 +0100456 GK_STANDALONE_MODE = True
peusterme26487b2016-03-08 14:00:21 +0100457 logging.getLogger("werkzeug").setLevel(logging.INFO)
458 start_rest_api("0.0.0.0", 8000)
459