From: Mohamed Larabi Date: Thu, 10 Oct 2013 14:23:38 +0000 (+0200) Subject: Add slicename_to_hrn in order to check slice HRN as well as persons and nodes X-Git-Tag: plcapi-5.2-10~1 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=ba1ae7e83e7e30049b8d5c8f403a0d96d72afc00 Add slicename_to_hrn in order to check slice HRN as well as persons and nodes --- diff --git a/PLC/Namespace.py b/PLC/Namespace.py index 6c3565b..e61ff2c 100644 --- a/PLC/Namespace.py +++ b/PLC/Namespace.py @@ -25,6 +25,10 @@ try: except: email_to_hrn=None +try: + from sfa.planetlab.plxrn import slicename_to_hrn +except: + slicename_to_hrn=None #################### if not found, bring our own local version import re def escape(token): return re.sub(r'([^\\])\.', r'\1\.', token) @@ -36,3 +40,7 @@ if hostname_to_hrn is None: if email_to_hrn is None: def email_to_hrn (auth_hrn, email): return '.'.join([auth_hrn,email.split('@')[0].replace(".", "_").replace("+", "_")]) + +if slicename_to_hrn is None: + def slicename_to_hrn (auth_hrn, slicename): + return ".".join([auth_hrn] + slicename.split("_",1))