Merge branch 'master' into senslab2
[sfa.git] / sfa / plc / pldriver.py
index 9a7db2d..b9db9b2 100644 (file)
@@ -12,7 +12,7 @@ from sfa.util.cache import Cache
 
 # one would think the driver should not need to mess with the SFA db, but..
 from sfa.storage.alchemy import dbsession
-from sfa.storage.persistentobjs import RegRecord
+from sfa.storage.model import RegRecord
 
 # used to be used in get_ticket
 #from sfa.trust.sfaticket import SfaTicket
@@ -110,7 +110,15 @@ class PlDriver (Driver):
                 self.shell.AddPersonToSite(pointer, login_base)
     
             # What roles should this user have?
-            self.shell.AddRoleToPerson('user', pointer)
+            roles=[]
+            if 'roles' in sfa_record: 
+                # if specified in xml, but only low-level roles
+                roles = [ role for role in sfa_record['roles'] if role in ['user','tech'] ]
+            # at least user if no other cluse could be found
+            if not roles:
+                roles=['user']
+            for role in roles:
+                self.shell.AddRoleToPerson(role, pointer)
             # Add the user's key
             if pub_key:
                 self.shell.AddPersonKey(pointer, {'key_type' : 'ssh', 'key' : pub_key})
@@ -225,10 +233,10 @@ class PlDriver (Driver):
                pl_record["url"] = sfa_record["url"]
            if "description" in sfa_record:
                pl_record["description"] = sfa_record["description"]
-        if "expires" in sfa_record:
-            date = utcparse(sfa_record['expires'])
-            expires = datetime_to_epoch(date)
-            pl_record["expires"] = expires
+            if "expires" in sfa_record:
+                date = utcparse(sfa_record['expires'])
+                expires = datetime_to_epoch(date)
+                pl_record["expires"] = expires
 
         elif type == "node":
             if not "hostname" in pl_record:
@@ -469,6 +477,7 @@ class PlDriver (Driver):
             #    continue 
             sfa_info = {}
             type = record['type']
+            logger.info("fill_record_sfa_info - incoming record typed %s"%type)
             if (type == "slice"):
                 # all slice users are researchers
                 record['geni_urn'] = hrn_to_urn(record['hrn'], 'slice')
@@ -489,6 +498,7 @@ class PlDriver (Driver):
                 
             elif (type.startswith("authority")):
                 record['url'] = None
+                logger.info("fill_record_sfa_info - authority xherex")
                 if record['pointer'] != -1:
                     record['PI'] = []
                     record['operator'] = []
@@ -511,6 +521,7 @@ class PlDriver (Driver):
                 # xxx TODO: URI, LatLong, IP, DNS
     
             elif (type == "user"):
+                logger.info('setting user.email')
                 sfa_info['email'] = record.get("email", "")
                 sfa_info['geni_urn'] = hrn_to_urn(record['hrn'], 'user')
                 sfa_info['geni_certificate'] = record['gid']