aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--moonv4/moon_manager/Dockerfile1
-rw-r--r--moonv4/moon_manager/moon_manager/api/pdp.py25
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,