diff options
author | Ruan HE <ruan.he@orange.com> | 2018-01-02 08:30:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-01-02 08:30:34 +0000 |
commit | 0b785d7a9c075e45245edbbdc1415680c0818c5d (patch) | |
tree | 047e07d2e70e17af2b137622f3418763b0b51a42 | |
parent | 176674ec7b91ffccf99844a836fd928d92cc09b3 (diff) | |
parent | e1f5bd9e603ce0768937cc018256f2837c723502 (diff) |
Merge "Add comment and fix on functions that contains bugs in pdp module"
-rw-r--r-- | python_moondb/python_moondb/api/pdp.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/python_moondb/python_moondb/api/pdp.py b/python_moondb/python_moondb/api/pdp.py index c75040ae..d39418b8 100644 --- a/python_moondb/python_moondb/api/pdp.py +++ b/python_moondb/python_moondb/api/pdp.py @@ -7,7 +7,7 @@ from uuid import uuid4 import logging from python_moonutilities.security_functions import enforce from python_moondb.api.managers import Managers - +from python_moonutilities import exceptions logger = logging.getLogger("moon.db.api.pdp") @@ -24,10 +24,14 @@ class PDPManager(Managers): @enforce(("read", "write"), "pdp") def delete_pdp(self, user_id, pdp_id): + if pdp_id not in self.driver.get_pdp(pdp_id=pdp_id): + raise exceptions.PdpUnknown return self.driver.delete_pdp(pdp_id=pdp_id) @enforce(("read", "write"), "pdp") def add_pdp(self, user_id, pdp_id=None, value=None): + if pdp_id in self.driver.get_pdp(pdp_id=pdp_id): + raise exceptions.PdpExisting if not pdp_id: pdp_id = uuid4().hex return self.driver.add_pdp(pdp_id=pdp_id, value=value) @@ -35,4 +39,3 @@ class PDPManager(Managers): @enforce("read", "pdp") def get_pdp(self, user_id, pdp_id=None): return self.driver.get_pdp(pdp_id=pdp_id) - |