aboutsummaryrefslogtreecommitdiffstats
path: root/moon_manager/moon_manager/api/pdp.py
diff options
context:
space:
mode:
Diffstat (limited to 'moon_manager/moon_manager/api/pdp.py')
-rw-r--r--moon_manager/moon_manager/api/pdp.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/moon_manager/moon_manager/api/pdp.py b/moon_manager/moon_manager/api/pdp.py
index 9183c25d..4dc2c310 100644
--- a/moon_manager/moon_manager/api/pdp.py
+++ b/moon_manager/moon_manager/api/pdp.py
@@ -18,9 +18,9 @@ from python_moondb.core import PolicyManager
from python_moondb.core import ModelManager
from python_moonutilities import configuration
-__version__ = "0.1.0"
+__version__ = "4.3.2"
-LOG = logging.getLogger("moon.manager.api." + __name__)
+logger = logging.getLogger("moon.manager.api." + __name__)
def delete_pod(uuid):
@@ -30,11 +30,9 @@ 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))
+ logger.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)
@@ -46,11 +44,11 @@ def add_pod(uuid, data):
json=data,
headers={"content-type": "application/json"})
except requests.exceptions.ConnectionError:
- LOG.warning("Orchestrator is not ready, standby...")
+ logger.warning("Orchestrator is not ready, standby...")
time.sleep(1)
else:
break
- LOG.info(req.text)
+ logger.info(req.text)
class PDP(Resource):
@@ -84,7 +82,7 @@ class PDP(Resource):
try:
data = PDPManager.get_pdp(user_id=user_id, pdp_id=uuid)
except Exception as e:
- LOG.error(e, exc_info=True)
+ logger.error(e, exc_info=True)
return {"result": False,
"error": str(e)}, 500
return {"pdps": data}
@@ -118,11 +116,11 @@ class PDP(Resource):
data = PDPManager.add_pdp(
user_id=user_id, pdp_id=None, value=request.json)
uuid = list(data.keys())[0]
- LOG.info("data={}".format(data))
- LOG.info("uuid={}".format(uuid))
+ logger.debug("data={}".format(data))
+ logger.debug("uuid={}".format(uuid))
add_pod(uuid=uuid, data=data[uuid])
except Exception as e:
- LOG.error(e, exc_info=True)
+ logger.error(e, exc_info=True)
return {"result": False,
"error": str(e)}, 500
return {"pdps": data}
@@ -143,7 +141,7 @@ class PDP(Resource):
data = PDPManager.delete_pdp(user_id=user_id, pdp_id=uuid)
delete_pod(uuid)
except Exception as e:
- LOG.error(e, exc_info=True)
+ logger.error(e, exc_info=True)
return {"result": False,
"error": str(e)}, 500
return {"result": True}
@@ -170,11 +168,11 @@ class PDP(Resource):
_data["keystone_project_id"] = None
data = PDPManager.update_pdp(
user_id=user_id, pdp_id=uuid, value=_data)
- LOG.info("data={}".format(data))
- LOG.info("uuid={}".format(uuid))
+ logger.debug("data={}".format(data))
+ logger.debug("uuid={}".format(uuid))
add_pod(uuid=uuid, data=data[uuid])
except Exception as e:
- LOG.error(e, exc_info=True)
+ logger.error(e, exc_info=True)
return {"result": False,
"error": str(e)}, 500
return {"pdps": data}