pl: wider mgt of new slice url and description
[sfa.git] / sfa / planetlab / plaggregate.py
index 2d26f0f..cae6495 100644 (file)
@@ -21,7 +21,6 @@ from sfa.rspecs.version_manager import VersionManager
 from sfa.planetlab.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename, slicename_to_hrn, top_auth, hash_loginbase
 from sfa.planetlab.vlink import get_tc_rate
 from sfa.planetlab.topology import Topology
-from sfa.storage.alchemy import dbsession
 from sfa.storage.model import SliverAllocation
 
 
@@ -116,6 +115,7 @@ class PlAggregate:
         names = set()
         slice_ids = set()
         node_ids = []
+        slice_hrn = None
         for urn in urns:
             xrn = PlXrn(xrn=urn)
             if xrn.type == 'sliver':
@@ -130,24 +130,18 @@ class PlAggregate:
                     pass 
             else:  
                 slice_hrn = xrn.get_hrn()
-                top_auth_hrn = top_auth(slice_hrn)
-                site_hrn = '.'.join(slice_hrn.split('.')[:-1])
-                slice_part = slice_hrn.split('.')[-1]
-                if top_auth_hrn == self.driver.hrn:
-                    login_base = slice_hrn.split('.')[-2][:12]
-                else:
-                    login_base = hash_loginbase(site_hrn)
-
-                slice_name = '_'.join([login_base, slice_part])
-                names.add(slice_name)
 
         filter = {}
-        if names:
-            filter['name'] = list(names)
+        filter['peer_id'] = None
         if slice_ids:
             filter['slice_id'] = list(slice_ids)
-        # get slices
-        slices = self.driver.shell.GetSlices(filter)
+        # get all slices
+        all_slices = self.driver.shell.GetSlices(filter, ['slice_id', 'name', 'hrn', 'person_ids', 'node_ids', 'slice_tag_ids', 'expires'])
+        if slice_hrn:
+            slices = [slice for slice in all_slices if slice['hrn'] == slice_hrn]
+        else:
+            slices = all_slices
+      
         if not slices:
             return []
         slice = slices[0]     
@@ -435,7 +429,7 @@ class PlAggregate:
         geni_urn = urns[0]
         sliver_ids = [sliver['sliver_id'] for sliver in slivers]
         constraint = SliverAllocation.sliver_id.in_(sliver_ids)
-        sliver_allocations = dbsession.query(SliverAllocation).filter(constraint)
+        sliver_allocations = self.driver.api.dbsession().query(SliverAllocation).filter(constraint)
         sliver_allocation_dict = {}
         for sliver_allocation in sliver_allocations:
             geni_urn = sliver_allocation.slice_urn