#log the call
self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), None, self.name))
record = GeniRecord(dict = record_dict)
- table = GeniTable()
+ record['authority'] = get_authority(record['hrn'])
type = record['type']
hrn = record['hrn']
- auth_name = get_authority(hrn)
self.api.auth.verify_object_permission(hrn)
- auth_info = self.api.auth.get_auth_info(auth_name)
+ auth_info = self.api.auth.get_auth_info(record['authority'])
pub_key = None
# make sure record has a gid
if 'gid' not in record:
record.set_gid(gid)
# check if record already exists
+ table = GeniTable()
existing_records = table.find({'type': type, 'hrn': hrn})
if existing_records:
raise ExistingRecord(hrn)
if hrn.startswith(self.api.hrn) and type in ['user', 'slice', 'authority']:
for registry in registries:
if registry not in [self.api.hrn]:
- result=registries[registry].remove_peer_object(credential, record)
+ try:
+ result=registries[registry].remove_peer_object(credential, record)
+ except:
+ pass
if type == "user":
persons = self.api.plshell.GetPersons(self.api.plauth, record['pointer'])
# only delete this person if he has site ids. if he doesnt, it probably means
if caller_cred==None:
caller_cred=cred
#log the call
- self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
+ self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), record['hrn'], self.name))
self.api.auth.check(cred, "remove")
except: self.api.auth.verify_cred_is_me(cred)
table = GeniTable()
- hrn, type, peer_auth = record['hrn'], record['type']
+ hrn, type = record['hrn'], record['type']
records = table.find({'hrn': hrn, 'type': type })
for record in records:
self.remove_plc_record(record)
elif type == "slice":
slices=self.api.plshell.GetSlices(self.api.plauth, {'slice_id' : record['pointer']})
- if not slices:
+ if not slices:
return 1
- slice=slices[0]
+ slice=slices[0]
if slice['peer_id']:
peer = self.get_peer_name(slice['peer_id'])
- self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
+ self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
elif type == "authority":
sites=self.api.plshell.GetSites(self.api.plauth, {'site_id' : record['pointer']})
# @param type
# @param hrn
- def remove_peer_object(self, cred, type, hrn, peer_auth, caller_cred=None):
- result = self.server.remove_peer_object(cred.save_to_string(save_parents=True), type, hrn, peer_auth, caller_cred)
+ def remove_peer_object(self, cred, record, caller_cred=None):
+ result = self.server.remove_peer_object(cred.save_to_string(save_parents=True), record, caller_cred)
return result
##
db_fields = self.db_fields(record)
keys = db_fields.keys()
values = [self.db.param(key, value) for (key, value) in db_fields.items()]
- pairs = []
- for (key, value) in db_fields.items():
- pairs.append(key + " = " + value)
- update = ", ".join(pairs)
-
+ columns = ["%s = %s" % (key, value) for (key, value) in zip(keys, values)]
query_str = "UPDATE %s SET %s WHERE record_id = %s" % \
- (self.tablename, update, record['record_id'])
+ (self.tablename, ", ".join(columns), record['record_id'])
self.db.do(query_str, db_fields)
self.db.commit()
self.gid = None
self.type = None
self.pointer = None
+ self.set_peer_auth(peer_authority)
if hrn:
self.set_name(hrn)
if gid:
self.set_type(type)
if pointer:
self.set_pointer(pointer)
- if peer_authority:
- self.set_peer_auth(peer_authority)
if dict:
self.load_from_dict(dict)
if string: