if existing_records:
raise ExistingRecord(name)
- if (type == "sa") or (type=="ma"):
+ if type in ["authority", "sa", "ma"]:
# update the tree
if not self.api.auth.hierarchy.auth_exists(name):
self.api.auth.hierarchy.create_auth(name)
# if registering a sa, see if a ma already exists
# if registering a ma, see if a sa already exists
- if (type == "sa"):
- other_rec = table.resolve("ma", record.get_name())
- elif (type == "ma"):
- other_rec = table.resolve("sa", record.get_name())
+ if type in ["authority", "sa", "ma"]:
+ other_rec = table.resolve("authority", record.get_name())
if other_rec:
print >> log, "linking ma and sa to the same plc site"
record.set_pointer(pointer)
# Add the user's key
- if record['keys']:
- self.api.plshell.AddPersonKey(self.api.plauth, pointer, {'key_type' : 'ssh', 'key' : record['keys'][0]})
+ if record['key']:
+ self.api.plshell.AddPersonKey(self.api.plauth, pointer, {'key_type' : 'ssh', 'key' : record['key']})
elif (type == "node"):
pl_record = self.api.geni_fields_to_pl_fields(type, name, record)
else:
raise UnknownGeniType(type)
- table.insert(record)
+ # SFA upcalls may exist in PLCAPI and they could have already added the
+ # record for us. Lets check if the record already exists
+ existing_records = table.resolve(type, name)
+ if not existing_records:
+ table.insert(record)
# update membership for researchers, pis, owners, operators
self.api.update_membership(None, record)