4 # This file here is the connection to the SFA code
5 # at some point in time we had duplicated this from sfa
6 # but of course both versions have entirely diverged since then
7 # in addition we really only need 2 hepler functions here, that allow to maintain
8 # hrn for nodes and persons and that is all
10 # So in order to avoid such situations in the future,
11 # we try to import and re-use the SFA code
12 # assumption being that if these hrn's are of importance then it makes sense to
13 # require people to have sfa-plc installed as well
14 # however we do not want this requirement to break myplc in case it is not fulfilled
17 #################### try to import from sfa
19 from sfa.planetlab.plxrn import hostname_to_hrn
24 from sfa.planetlab.plxrn import email_to_hrn
28 #################### if not found, bring our own local version
30 def escape(token): return re.sub(r'([^\\])\.', r'\1\.', token)
32 if hostname_to_hrn is None:
33 def hostname_to_hrn (auth_hrn, login_base, hostname):
34 return ".".join( [ auth_hrn, login_base, escape(hostname) ] )
36 if email_to_hrn is None:
37 def email_to_hrn (auth_hrn, email):
38 return '.'.join([auth_hrn,email.split('@')[0].replace(".", "_").replace("+", "_")])