for record in records:
if record['type'] != 'user':
continue
- user = {'urn': record['geni_urn'],
+ user = {'urn': record['urn'],
'keys': record['keys']}
users.append(user)
return users
-def sfa_users_arg(records, slice_record):
+def sfa_users_arg (records, slice_record):
users = []
for record in records:
if record['type'] != 'user':
continue
try:
- user = {'urn': record['geni_urn'], #
- 'keys': record['keys'],
- 'email': record['email'], # needed for MyPLC
- 'person_id': record['person_id'], # needed for MyPLC
- 'first_name': record['first_name'], # needed for MyPLC
- 'last_name': record['last_name'], # needed for MyPLC
- 'slice_record': slice_record, # needed for legacy refresh peer
- 'key_ids': record['key_ids'] # needed for legacy refresh peer
- }
+ user = {'urn': record['urn'], #
+# all right, so this is sooo totally wrong
+# 'keys': record['keys'],
+# 'email': record['email'], # needed for MyPLC
+# 'person_id': record['person_id'], # needed for MyPLC
+# 'first_name': record['first_name'], # needed for MyPLC
+# 'last_name': record['last_name'], # needed for MyPLC
+# 'slice_record': slice_record, # needed for legacy refresh peer
+# 'key_ids': record['key_ids'] # needed for legacy refresh peer
+ }
except:
# handle NITOS user args
- user = {'urn': record['geni_urn'],
- 'keys': record['keys'],
- 'email': record['email'],
- 'user_id': record['user_id'],
- 'slice_record': slice_record,
- }
-
+ user = {'urn': record['urn'],
+ 'keys': record['keys'],
+ 'email': record['email'],
+ 'user_id': record['user_id'],
+ 'slice_record': slice_record,
+ }
+
users.append(user)
- return users
+ return users
def sfa_to_pg_users_arg(users):
def terminal_render_slice (record, options):
print "%s (Slice)"%record['hrn'],
if record.get('reg-researchers',None): print " [USERS %s]"%(" and ".join(record['reg-researchers'])),
- print record.keys()
+# print record.keys()
print ""
def terminal_render_authority (record, options):
print "%s (Authority)"%record['hrn'],
# Main: parse arguments and dispatch to command
#
def dispatch(self, command, command_options, command_args):
- return getattr(self, command)(command_options, command_args)
+ method=getattr(self, command,None)
+ if not method:
+ print "Unknown command %s"%command
+ return
+ return method(command_options, command_args)
def main(self):
self.sfi_parser = self.create_parser()
try:
self.dispatch(command, command_options, command_args)
- except KeyError:
- self.logger.critical ("Unknown command %s"%command)
+ except:
+ self.logger.log_exc ("sfi command %s failed"%command)
sys.exit(1)
return
self.print_help()
sys.exit(1)
hrn = args[0]
- # xxx should set details=True here but that's not in the xmlrpc interface ...
- # record_dicts = self.registry().Resolve(hrn, self.my_credential_string, details=True)
- record_dicts = self.registry().Resolve(hrn, self.my_credential_string)
+ # explicitly require Resolve to run in details mode
+ record_dicts = self.registry().Resolve(hrn, self.my_credential_string, {'details':True})
record_dicts = filter_records(options.type, record_dicts)
if not record_dicts:
self.logger.error("No record of type %s"% options.type)
# to the actual method calls anyway
self.manager = manager(config)
else:
+ # that's what happens when there's something wrong with the db
+ # or any bad stuff of that kind at startup time
+ logger.log_exc("Failed to create a manager, startup sequence is broken")
raise SfaAPIError,"Argument to ManagerWrapper must be a module or class"
self.interface = interface
from sfa.trust.gid import create_uuid
from sfa.storage.model import make_record, RegRecord, RegAuthority, RegUser, RegSlice, RegKey, \
- augment_with_related_hrns
+ augment_with_urn_and_related_hrns
from sfa.storage.alchemy import dbsession
class RegistryManager:
local_records=local_records.all()
for local_record in local_records:
- augment_with_related_hrns (local_record)
+ augment_with_urn_and_related_hrns (local_record)
logger.info("Resolve, (details=%s,type=%s) local_records=%s "%(details,type,local_records))
local_dicts = [ record.__dict__ for record in local_records ]
records = dbsession.query(RegRecord).filter(RegRecord.hrn.startswith(hrn))
else:
records = dbsession.query(RegRecord).filter_by(authority=hrn)
- for record in records: augment_with_related_hrns (record)
+ for record in records: augment_with_urn_and_related_hrns (record)
record_dicts=[ record.todict(exclude_type=RegRecord) for record in records ]
return record_dicts
Mixed(Parameter(str, "Human readable name (hrn or urn)"),
Parameter(list, "List of Human readable names ([hrn])")),
Mixed(Parameter(str, "Credential string"),
- Parameter(list, "List of credentials)"))
+ Parameter(list, "List of credentials)")),
+ Parameter(dict, "options"),
]
# xxx used to be [SfaRecord]
returns = [Parameter(dict, "registry record")]
- def call(self, xrns, creds):
- # xxx should be ar arg
- details=False
+ def call(self, xrns, creds, options={}):
+ # use details=False by default, only when explicitly specified do we want
+ # to mess with the testbed details
+ if 'details' in options: details=options['details']
+ else: details=False
type = None
if not isinstance(xrns, types.ListType):
type = Xrn(xrns).get_type()
'reg-slices':'reg_slices_as_researcher',},
}
-def augment_with_related_hrns (local_record):
+def augment_with_urn_and_related_hrns (local_record):
+ # don't ruin the import of that file in a client world
+ from sfa.util.xrn import Xrn
+ local_record.urn=Xrn(xrn=local_record.hrn,type=local_record.type).urn
# search in map according to record type
type_map=augment_map.get(local_record.type,{})
# use type-dep. map to do the job