be more flexible in the accepted inputs
[sfa.git] / sfa / util / misc.py
index e1320df..ca8dbba 100644 (file)
@@ -28,8 +28,8 @@ def hostname_to_hrn(auth_hrn, login_base, hostname):
     """
     Convert hrn to plantelab name.
     """
-    genihostname = "_".join(hostname.split("."))
-    return ".".join([auth_hrn, login_base, genihostname])
+    sfa_hostname = ".".join([auth_hrn, login_base, hostname.split(".")[0]])
+    return sfa_hostname
 
 def slicename_to_hrn(auth_hrn, slicename):
     """
@@ -40,3 +40,10 @@ def slicename_to_hrn(auth_hrn, slicename):
 
     return slice_hrn
 
+def email_to_hrn(auth_hrn, email):
+    parts = email.split("@")
+    username = parts[0]
+    username = username.replace(".", "_") 
+    person_hrn = ".".join([auth_hrn, username])
+    
+    return person_hrn