working on adding user information to createsliver
authorJosh Karlin <jkarlin@bbn.com>
Fri, 14 May 2010 17:10:15 +0000 (17:10 +0000)
committerJosh Karlin <jkarlin@bbn.com>
Fri, 14 May 2010 17:10:15 +0000 (17:10 +0000)
sfa/managers/geni_am_pl.py
sfa/methods/CreateSliver.py
sfa/plc/slices.py

index 87d8a95..cd60989 100644 (file)
@@ -8,7 +8,6 @@ from sfa.util.record import *
 from sfa.plc.slices import *
 from sfa.util.sfalogging import *
 from sfa.util.record import SfaRecord
-from lxml import etree
 from StringIO import StringIO
 from time import mktime
 
@@ -54,7 +53,7 @@ def ListResources(api, creds, options):
     return rspec
 
 
-def CreateSliver(api, slice_xrn, creds, rspec):
+def CreateSliver(api, slice_xrn, creds, rspec, users):
     hrn, type = urn_to_hrn(slice_xrn)
     
     hrn_auth = get_authority(hrn)
@@ -86,6 +85,22 @@ def CreateSliver(api, slice_xrn, creds, rspec):
     slice['pointer'] = 0
     reg_objects['slice_record'] = slice
     
+    
+    # Note:
+    # Left off here, need to properly fill out the slice record and 
+    # stuff the user information in to get through slices.verify_persons
+    # Need to hear back from Tony Mack to find out how accurate the user
+    # information needs to be.
+    for user in users:
+        slice['researcher'].append(user.getdefault('name', 'geni_default_user'))
+        
+        
+    keys = []
+    for user in users:
+        keys += user['keys']
+        
+    reg_objects['keys'] = keys
+    
     manager_base = 'sfa.managers'
     mgr_type = 'pl'
     manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
index 269ec27..651a77d 100644 (file)
@@ -23,7 +23,8 @@ class CreateSliver(Method):
     accepts = [
         Parameter(str, "Slice URN"),
         Parameter(type([str]), "List of credentials"),
-        Parameter(str, "RSpec")
+        Parameter(str, "RSpec"),
+        Parameter(type([]), "List of user information")
         ]
     returns = Parameter(str, "Allocated RSpec")
 
@@ -38,7 +39,7 @@ class CreateSliver(Method):
         return newrspec
 
 
-    def call(self, slice_xrn, creds, rspec):
+    def call(self, slice_xrn, creds, rspec, users):
         hrn, type = urn_to_hrn(slice_xrn)
 
         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
@@ -56,6 +57,6 @@ class CreateSliver(Method):
             rspec = self.__run_sfatables(manager, SFATablesRules('INCOMING'),
                                          hrn, origin_hrn, rspec)
 
-            return manager.CreateSliver(self.api, slice_xrn, ValidCreds, rspec)            
+            return manager.CreateSliver(self.api, slice_xrn, ValidCreds, rspec, users)            
         return ''
     
index bc1e0a5..66766cf 100644 (file)
@@ -257,18 +257,21 @@ class Slices:
            self.sync_slice(slice, slice_record, peer)
 
         slice['peer_slice_id'] = slice_record['pointer']
-        self.verify_persons(registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer)
+        self.verify_persons(registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer, reg_objects)
     
         return slice        
 
-    def verify_persons(self, registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer):
+    def verify_persons(self, registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer, reg_objects=None):
         # get the list of valid slice users from the registry and make 
         # sure they are added to the slice 
         slicename = hrn_to_pl_slicename(slice_record['hrn'])
         researchers = slice_record.get('researcher', [])
         for researcher in researchers:
             person_record = {}
-            person_records = registry.resolve(credential, researcher)
+            if reg_objects:
+                person_records = reg_objects['users']['researcher']
+            else:
+                person_records = registry.resolve(credential, researcher)
             for record in person_records:
                 if record['type'] in ['user'] and record['enabled']:
                     person_record = record