X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Fregistry_manager_pl.py;h=619e48153f7fee6d89b3174272a87c0f4896af0b;hb=9167ba6e1a70f1ff29619247f2d6f1509ae1652d;hp=985cd3190d541abd5b75b993b114bad5d33eaa44;hpb=11d02cbfd5e91784119bb9377fceb4fa6adae621;p=sfa.git diff --git a/sfa/managers/registry_manager_pl.py b/sfa/managers/registry_manager_pl.py index 985cd319..619e4815 100644 --- a/sfa/managers/registry_manager_pl.py +++ b/sfa/managers/registry_manager_pl.py @@ -67,9 +67,9 @@ def resolve(api, xrns, type=None, origin_hrn=None): # load all know registry names into a prefix tree and attempt to find # the longest matching prefix - if not isinstance(hrns, types.ListType): + if not isinstance(xrns, types.ListType): xrns = [xrns] - + hrns = [urn_to_hrn(xrn)[0] for xrn in xrns] # create a dict whre key is an registry hrn and its value is a # hrns at that registry (determined by the known prefix tree). xrn_dict = {} @@ -79,7 +79,7 @@ def resolve(api, xrns, type=None, origin_hrn=None): tree.load(registry_hrns) for xrn in xrns: registry_hrn = tree.best_match(urn_to_hrn(xrn)[0]) - if registry_hrn not in hrn_dict: + if registry_hrn not in xrn_dict: xrn_dict[registry_hrn] = [] xrn_dict[registry_hrn].append(xrn) @@ -100,6 +100,7 @@ def resolve(api, xrns, type=None, origin_hrn=None): # try resolving the remaining unfound records at the local registry remaining_hrns = set(hrns).difference([record['hrn'] for record in records]) + # convert set to list remaining_hrns = [hrn for hrn in remaining_hrns] table = SfaTable() local_records = table.findObjects({'hrn': remaining_hrns}) @@ -121,8 +122,8 @@ def resolve(api, xrns, type=None, origin_hrn=None): return records -def list(api, xrn): - hrn, type = hrn_to_urn(xrn) +def list(api, xrn, origin_hrn=None): + hrn, type = urn_to_hrn(xrn) # load all know registry names into a prefix tree and attempt to find # the longest matching prefix records = [] @@ -216,13 +217,13 @@ def register(api, record): for key in pl_record.keys(): if key not in acceptable_fields: pl_record.pop(key) - slices = api.plshell.GetSlices(api.plauth, [pl_record['name']]) - if not slices: - pointer = api.plshell.AddSlice(api.plauth, pl_record) - else: - pointer = slices[0]['slice_id'] - record.set_pointer(pointer) - record['pointer'] = pointer + slices = api.plshell.GetSlices(api.plauth, [pl_record['name']]) + if not slices: + pointer = api.plshell.AddSlice(api.plauth, pl_record) + else: + pointer = slices[0]['slice_id'] + record.set_pointer(pointer) + record['pointer'] = pointer elif (type == "user"): persons = api.plshell.GetPersons(api.plauth, [record['email']])