-
- if (type == "authority"):
- self.driver.UpdateSite(pointer, new_record)
-
- elif type == "slice":
- pl_record=self.driver.sfa_fields_to_pl_fields(type, hrn, new_record)
- if 'name' in pl_record:
- pl_record.pop('name')
- self.driver.UpdateSlice(pointer, pl_record)
-
- elif type == "user":
- # SMBAKER: UpdatePerson only allows a limited set of fields to be
- # updated. Ideally we should have a more generic way of doing
- # this. I copied the field names from UpdatePerson.py...
- update_fields = {}
- all_fields = new_record
- for key in all_fields.keys():
- if key in ['first_name', 'last_name', 'title', 'email',
- 'password', 'phone', 'url', 'bio', 'accepted_aup',
- 'enabled']:
- update_fields[key] = all_fields[key]
- self.driver.UpdatePerson(pointer, update_fields)
-
- if 'key' in new_record and new_record['key']:
- # must check this key against the previous one if it exists
- persons = self.driver.GetPersons([pointer], ['key_ids'])
- person = persons[0]
- keys = person['key_ids']
- keys = self.driver.GetKeys(person['key_ids'])
- key_exists = False
- if isinstance(new_record['key'], types.ListType):
- new_key = new_record['key'][0]
- else:
- new_key = new_record['key']
-
- # Delete all stale keys
- for key in keys:
- if new_record['key'] != key['key']:
- self.driver.DeleteKey(key['key_id'])
- else:
- key_exists = True
- if not key_exists:
- self.driver.AddPersonKey(pointer, {'key_type': 'ssh', 'key': new_key})
-
- # update the openssl key and gid
- pkey = convert_public_key(new_key)
- uuid = create_uuid()
- gid_object = api.auth.hierarchy.create_gid(urn, uuid, pkey)
- gid = gid_object.save_to_string(save_parents=True)
- record['gid'] = gid
- record = SfaRecord(dict=record)
- table.update(record)
-
- elif type == "node":
- self.driver.UpdateNode(pointer, new_record)
-
- else:
- raise UnknownSfaType(type)
+ # xxx oddly enough, without this useless statement,
+ # record.__dict__ as received by the driver seems to be off
+ # anyway the driver should receive an object
+ # (and then extract __dict__ itself if needed)
+ print "DO NOT REMOVE ME before driver.update, record=%s"%record
+ if not self.driver.update (record.__dict__, new_record.__dict__, hrn, new_key):
+ logger.warning("driver.update failed")