diff options
author | Thomas Duval <thomas.duval@orange.com> | 2018-01-05 11:42:39 +0100 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2018-01-05 11:42:39 +0100 |
commit | 6ec3992503b049d26e05b7ec40f22f8bce78643b (patch) | |
tree | c684a1b7ab1f78ec2221101c19839345889ed5d4 /moon_manager/moon_manager/api/pdp.py | |
parent | 3a3072d2e1c4a17375405a6e7e8fd9adeab0c434 (diff) |
Clean the code of Manager
Change-Id: I636631929cfdf197a28debbfdf1df863b30445b3
Diffstat (limited to 'moon_manager/moon_manager/api/pdp.py')
-rw-r--r-- | moon_manager/moon_manager/api/pdp.py | 28 |
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} |