X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Femuvim%2Fapi%2Fsonata%2Fdummygatekeeper.py;h=29ebc0bd7118bbd1aa5019c6c600407c440fd391;hb=0caea49645adff9a83f3ae300c4ac785d8a1f32f;hp=68031e494fa71fa4e0ce636a26423ce48ea6d6fb;hpb=3444ae45d2b2819993cd972ffe6a572b61fce621;p=osm%2Fvim-emu.git diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index 68031e4..29ebc0b 100644 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -195,12 +195,16 @@ class Service(object): """ If the package contains URLs to pre-build Docker images, we download them with this method. """ - # TODO implement + # TODO implement this if we want to be able to download docker images instead of building them pass def _check_docker_image_exists(self, image_name): - # TODO implement - return True + """ + Query the docker service and check if the given image exists + :param image_name: name of the docker image + :return: + """ + return len(DockerClient().images(image_name)) > 0 def _calculate_placement(self, algorithm): """ @@ -284,10 +288,17 @@ class Instantiations(fr.Resource): Will return a new UUID to identify the running service instance. :return: UUID """ - # TODO implement method (start real service) + # try to extract the service uuid from the request json_data = request.get_json(force=True) - service_uuid = list(GK.services.iterkeys())[0] #json_data.get("service_uuid") # TODO only for quick testing + service_uuid = json_data.get("service_uuid") + + # lets be a bit fuzzy here to make testing easier + if service_uuid is None and len(GK.services) > 0: + # if we don't get a service uuid, we simple start the first service in the list + service_uuid = list(GK.services.iterkeys())[0] + if service_uuid in GK.services: + # ok, we have a service uuid, lets start the service service_instance_uuid = GK.services.get(service_uuid).start_service() return {"service_instance_uuid": service_instance_uuid} return "Service not found", 404 @@ -297,8 +308,8 @@ class Instantiations(fr.Resource): Returns a list of UUIDs containing all running services. :return: dict / list """ - # TODO implement method - return {"service_instance_uuid_list": list()} + return {"service_instance_list": [ + list(s.instances.iterkeys()) for s in GK.services.itervalues()]} # create a single, global GK object @@ -347,7 +358,7 @@ def helper_map_docker_name(name): """ Quick hack to fix missing dependency in example package. """ - # TODO remove this when package description is fixed + # FIXME remove this when package description is fixed mapping = { "/docker_files/iperf/Dockerfile": "iperf_docker", "/docker_files/firewall/Dockerfile": "fw_docker",