diff options
author | Thomas Duval <thomas.duval@orange.com> | 2017-10-29 21:05:42 +0100 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2017-10-29 21:05:42 +0100 |
commit | 068c08a37302b05ee3efac87f14106ca25768f03 (patch) | |
tree | 11b377cd31afd128920ed322def1924bf35ff9c7 /moonv4 | |
parent | 0e46fc8f2c6a42c144f05c4e2a416fd2fb8339e1 (diff) |
Update Manager to use Kubernetes
Change-Id: I46a755a218a49e6bb91e328ff35b3f8f19d78e2d
Diffstat (limited to 'moonv4')
-rw-r--r-- | moonv4/moon_manager/Dockerfile | 1 | ||||
-rw-r--r-- | moonv4/moon_manager/moon_manager/api/pdp.py | 25 |
2 files changed, 19 insertions, 7 deletions
diff --git a/moonv4/moon_manager/Dockerfile b/moonv4/moon_manager/Dockerfile index 3e1a65af..17bee16a 100644 --- a/moonv4/moon_manager/Dockerfile +++ b/moonv4/moon_manager/Dockerfile @@ -6,6 +6,7 @@ RUN pip3 install pip --upgrade ADD . /root WORKDIR /root/ RUN pip3 install -r requirements.txt +RUN pip3 install /root/dist/* --upgrade RUN pip3 install . CMD ["python3", "-m", "moon_manager"]
\ No newline at end of file diff --git a/moonv4/moon_manager/moon_manager/api/pdp.py b/moonv4/moon_manager/moon_manager/api/pdp.py index ff996e4a..823055a2 100644 --- a/moonv4/moon_manager/moon_manager/api/pdp.py +++ b/moonv4/moon_manager/moon_manager/api/pdp.py @@ -9,20 +9,29 @@ PDP are Policy Decision Point. from flask import request from flask_restful import Resource -from oslo_log import log as logging +import logging +import requests from moon_utilities.security_functions import check_auth from moon_db.core import PDPManager +from moon_utilities import configuration __version__ = "0.1.0" LOG = logging.getLogger("moon.manager.api." + __name__) -def add_container(uuid, pipeline): - # TODO: to implement - LOG.warning("Add container not implemented!") - LOG.info(uuid) - LOG.info(pipeline) +def delete_pod(uuid): + raise NotImplementedError + + +def add_pod(uuid, data): + conf = configuration.get_configuration("components/orchestrator") + hostname = conf["components/orchestrator"].get("hostname", "orchestrator") + port = conf["components/orchestrator"].get("port", 80) + proto = conf["components/orchestrator"].get("protocol", "http") + req = requests.post("{}://{}:{}/pods".format(proto, hostname, port), + data=data) + LOG.info(req.text) class PDP(Resource): @@ -86,6 +95,7 @@ class PDP(Resource): try: data = PDPManager.add_pdp( user_id=user_id, pdp_id=None, value=request.json) + add_pod(uuid=uuid, data=data[uuid]) except Exception as e: LOG.error(e, exc_info=True) return {"result": False, @@ -106,6 +116,7 @@ class PDP(Resource): """ try: data = PDPManager.delete_pdp(user_id=user_id, pdp_id=uuid) + delete_pod(uuid) except Exception as e: LOG.error(e, exc_info=True) return {"result": False, @@ -131,7 +142,7 @@ class PDP(Resource): try: data = PDPManager.update_pdp( user_id=user_id, pdp_id=uuid, value=request.json) - add_container(uuid=uuid, pipeline=data[uuid]['security_pipeline']) + add_pod(uuid=uuid, data=data[uuid]) except Exception as e: LOG.error(e, exc_info=True) return {"result": False, |