diff options
Diffstat (limited to 'moonv4/moon_manager')
-rw-r--r-- | moonv4/moon_manager/Dockerfile | 2 | ||||
-rw-r--r-- | moonv4/moon_manager/moon_manager/api/pdp.py | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/moonv4/moon_manager/Dockerfile b/moonv4/moon_manager/Dockerfile index 17bee16a..873e3aa2 100644 --- a/moonv4/moon_manager/Dockerfile +++ b/moonv4/moon_manager/Dockerfile @@ -6,7 +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 /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 ffc91fba..465f4dba 100644 --- a/moonv4/moon_manager/moon_manager/api/pdp.py +++ b/moonv4/moon_manager/moon_manager/api/pdp.py @@ -14,6 +14,8 @@ import requests import time from moon_utilities.security_functions import check_auth from moon_db.core import PDPManager +from moon_db.core import PolicyManager +from moon_db.core import ModelManager from moon_utilities import configuration __version__ = "0.1.0" @@ -26,15 +28,23 @@ def delete_pod(uuid): def add_pod(uuid, data): + if not data.get("keystone_project_id"): + return LOG.info("Add a new pod {}".format(data)) + if "pdp_id" not in data: + data["pdp_id"] = uuid + data['policies'] = PolicyManager.get_policies(user_id="admin") + data['models'] = ModelManager.get_models(user_id="admin") 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") while True: try: - req = requests.post("{}://{}:{}/pods".format(proto, hostname, port), - data=data) + req = requests.post( + "{}://{}:{}/pods".format(proto, hostname, port), + json=data, + headers={"content-type": "application/json"}) except requests.exceptions.ConnectionError: LOG.warning("Orchestrator is not ready, standby...") time.sleep(1) |