X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=blobdiff_plain;f=src%2Femuvim%2Fapi%2Fsonata%2F__init__.py;h=200337ae0ee7d5ef4b87c5fc088d7e20567bca4c;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=e26487ba6b33c22a1e3f5f843364df9f0efc07eb;hpb=ea8db83259fd1f87774ffb3b80c8ab455481da28 diff --git a/src/emuvim/api/sonata/__init__.py b/src/emuvim/api/sonata/__init__.py index e69de29..200337a 100644 --- a/src/emuvim/api/sonata/__init__.py +++ b/src/emuvim/api/sonata/__init__.py @@ -0,0 +1,36 @@ +""" +This module implements a simple REST API that behaves like SONATA's gatekeeper. + +It is only used to support the development of SONATA's SDK tools and to demonstrate +the year 1 version of the emulator until the integration with WP4's orchestrator is done. +""" + +import logging +import threading +import dummygatekeeper as dgk + + +class SonataDummyGatekeeperEndpoint(object): + + def __init__(self, listenip, port): + self.dcs = {} + self.ip = listenip + self.port = port + logging.debug("Created API endpoint %s" % self) + + def __repr__(self): + return "%s(%s:%d)" % (self.__class__.__name__, self.ip, self.port) + + def connectDatacenter(self, dc): + self.dcs[dc.label] = dc + logging.info("Connected DC(%s) to API endpoint %s" % ( + dc, self)) + + def start(self): + thread = threading.Thread(target=self._api_server_thread, args=()) + thread.daemon = True + thread.start() + logging.debug("Started API endpoint %s" % self) + + def _api_server_thread(self): + dgk.start_rest_api(self.ip, self.port)