1 ### $Id: misc.py 16477 2010-01-05 16:31:37Z thierry $
2 ### $URL: http://svn.planet-lab.org/svn/sfa/trunk/sfa/util/misc.py $
4 from sfa.util.faults import *
8 return ".".join(parts[-1:])
10 def get_authority(hrn):
11 parts = hrn.split(".")
12 return ".".join(parts[:-1])
14 def hrn_to_pl_slicename(hrn):
15 parts = hrn.split(".")
16 return parts[-2] + "_" + parts[-1]
18 # assuming hrn is the hrn of an authority, return the plc authority name
19 def hrn_to_pl_authname(hrn):
20 parts = hrn.split(".")
23 # assuming hrn is the hrn of an authority, return the plc login_base
24 def hrn_to_pl_login_base(hrn):
25 return hrn_to_pl_authname(hrn)
27 def hostname_to_hrn(auth_hrn, login_base, hostname):
29 Convert hrn to plantelab name.
31 sfa_hostname = ".".join([auth_hrn, login_base, hostname.split(".")[0]])
34 def slicename_to_hrn(auth_hrn, slicename):
36 Convert hrn to planetlab name.
38 parts = slicename.split("_")
39 slice_hrn = ".".join([auth_hrn, parts[0]]) + "." + "_".join(parts[1:])
43 def email_to_hrn(auth_hrn, email):
44 parts = email.split("@")
46 username = username.replace(".", "_")
47 person_hrn = ".".join([auth_hrn, username])