use sfa.client.client_helper to generate users list in CreateSliver
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 10 Oct 2011 19:46:46 +0000 (15:46 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 10 Oct 2011 19:46:46 +0000 (15:46 -0400)
Makefile
sfa/client/sfi.py
sfa/managers/aggregate_manager_pl.py
sfa/managers/slice_manager_pl.py
sfa/plc/aggregate.py

index 5bb1bba..f162f5f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ uninstall: python-uninstall tests-uninstall
 
 .PHONY: all install clean uninstall
 
-VERSIONTAG=should-be-redefined-by-specfile
+VERSIONTAG=0.0-0-should.be-redefined-by-specfile
 SCMURL=should-be-redefined-by-specfile
 
 ##########
index 838b291..384d6f1 100755 (executable)
@@ -16,7 +16,7 @@ from lxml import etree
 from StringIO import StringIO
 from types import StringTypes, ListType
 from optparse import OptionParser
-
+from sfa.client.client_helper import pg_users_arg, sfa_users_arg, sfa_to_pg_users_arg 
 from sfa.util.sfalogging import sfi_logger
 from sfa.trust.certificate import Keypair, Certificate
 from sfa.trust.gid import GID
@@ -980,37 +980,17 @@ class Sfi:
         #    keys: [<ssh key A>, <ssh key B>] 
         #  }]
         users = []
-        all_keys = []
-        all_key_ids = []
         slice_records = self.registry.Resolve(slice_urn, [user_cred.save_to_string(save_parents=True)])
         if slice_records and 'researcher' in slice_records[0] and slice_records[0]['researcher']!=[]:
             slice_record = slice_records[0]
             user_hrns = slice_record['researcher']
             user_urns = [hrn_to_urn(hrn, 'user') for hrn in user_hrns]
             user_records = self.registry.Resolve(user_urns, [user_cred.save_to_string(save_parents=True)])
-            for user_record in user_records:
-                if user_record['type'] != 'user':
-                    continue
-                #user = {'urn': user_cred.get_gid_caller().get_urn(),'keys': []}
-                user = {'urn': user_cred.get_gid_caller().get_urn(), #
-                        'keys': user_record['keys'],
-                        'email': user_record['email'], #  needed for MyPLC
-                        'person_id': user_record['person_id'], # needed for MyPLC
-                        'first_name': user_record['first_name'], # needed for MyPLC
-                        'last_name': user_record['last_name'], # needed for MyPLC
-                        'slice_record': slice_record, # needed for legacy refresh peer
-                        'key_ids': user_record['key_ids'] # needed for legacy refresh peer
-                } 
-                users.append(user)
-                all_keys.extend(user_record['keys'])
-                all_key_ids.extend(user_record['key_ids'])
-            # ProtoGeni Aggregates will only install the keys of the user that is issuing the
-            # request. So we will add all to the current caller's list of keys
+            
             if 'sfa' not in server_version:
-                for user in users:
-                    if user['urn'] == user_cred.get_gid_caller().get_urn():
-                        user['keys'] = all_keys  
-
+                users = pg_users_arg(user_records)
+            else:
+                users = sfa_users_arg(user_records, slice_record)
         call_args = [slice_urn, creds, rspec, users]
         if self.server_supports_call_id_arg(server):
             call_args.append(unique_call_id())
index 3b82cb6..a870f8f 100644 (file)
@@ -1,5 +1,3 @@
-
-
 import datetime
 import time
 import traceback
@@ -298,7 +296,7 @@ def ListSlices(api, creds, call_id):
 
     return slice_urns
     
-def ListResources(api, creds, options,call_id):
+def ListResources(api, creds, options, call_id):
     if Callids().already_handled(call_id): return ""
     # get slice's hrn from options
     xrn = options.get('geni_slice_urn', None)
index 0f7774f..f41f8de 100644 (file)
@@ -122,7 +122,7 @@ def ListResources(api, creds, options, call_id):
             rspec = server.ListResources(*args)
             return {"aggregate": aggregate, "rspec": rspec, "elapsed": time.time()-tStart, "status": "success"}
         except Exception, e:
-            api.logger.log_exc("ListResources failed at %s: %s" %(server.url))
+            api.logger.log_exc("ListResources failed at %s" %(server.url))
             return {"aggregate": aggregate, "elapsed": time.time()-tStart, "status": "exception"}
 
     if Callids().already_handled(call_id): return ""
index a45cd2e..f39fd61 100644 (file)
@@ -99,7 +99,7 @@ class Aggregate:
         # filter out nodes with a whitelist:
         valid_nodes = [] 
         for node in self.nodes.values():
-            # only doing this becuase protogeni rspec needs
+            # only doing this because protogeni rspec needs
             # to advertise available initscripts 
             node['pl_initscripts'] = self.pl_initscripts