Merge branch 'geni-v3' into dbsession
[sfa.git] / sfa / planetlab / plslices.py
index 4d23ff2..9231d7a 100644 (file)
@@ -10,7 +10,6 @@ from sfa.planetlab.vlink import VLink
 from sfa.planetlab.topology import Topology
 from sfa.planetlab.plxrn import PlXrn, hrn_to_pl_slicename, xrn_to_hostname, top_auth, hash_loginbase
 from sfa.storage.model import SliverAllocation
-from sfa.storage.alchemy import dbsession
 
 MAXINT =  2L**31-1
 
@@ -272,7 +271,7 @@ class PlSlices:
                                       component_id=component_id,
                                       slice_urn = slice_urn, 
                                       allocation_state='geni_allocated')      
-            record.sync()
+            record.sync(self.driver.api.dbsession())
         return resulting_nodes
 
     def free_egre_key(self):
@@ -452,7 +451,7 @@ class PlSlices:
         else:
             slice = slice_exists[0]
             #Update expiration if necessary
-            if slice['expires'] != expires:
+            if slice.get('expires', None) != expires:
                 self.driver.shell.UpdateSlice( int(slice['slice_id']), {'expires' : expires})
 
         return self.driver.shell.GetSlices(int(slice['slice_id']))[0]
@@ -510,11 +509,12 @@ class PlSlices:
                            'first_name': person_hrn,
                            'last_name': person_hrn,
                            'email': users_by_hrn[person_hrn].get('email', "%s@geni.net"%person_hrn.split('.')[-1]),
-                           'enabled': True
                           }
 
                  person_id = self.driver.shell.AddPerson(person)
                  self.driver.shell.AddRoleToPerson('user', int(person_id))
+                 # enable the account 
+                 self.driver.shell.UpdatePerson(int(person_id), {'enabled': True})
                  self.driver.shell.SetPersonHrn(int(person_id), person_hrn)
                  self.driver.shell.SetPersonSfaCreated(int(person_id), 'True')
                  self.driver.shell.AddPersonToSite(int(person_id), site['site_id'])