+ # Make requested associations
+ for k,v in related.iteritems():
+ person.associate (auth, k, v)
+
+ person.update(native)
+ person.update_last_updated(False)
+ person.sync(commit=True)
+
+ # send a mail
+ if 'enabled' in person_fields:
+ To = [("%s %s" % (person['first_name'], person['last_name']), person['email'])]
+ Cc = []
+ if person['enabled']:
+ Subject = "%s account enabled" % (self.api.config.PLC_NAME)
+ Body = "Your %s account has been enabled. Please visit %s to access your account." % (self.api.config.PLC_NAME, self.api.config.PLC_WWW_HOST)
+ else:
+ Subject = "%s account disabled" % (self.api.config.PLC_NAME)
+ Body = "Your %s account has been disabled. Please contact your PI or PlanetLab support for more information" % (self.api.config.PLC_NAME)
+ sendmail(self.api, To = To, Cc = Cc, Subject = Subject, Body = Body)
+
+
+ for (tagname,value) in tags.iteritems():
+ # the tagtype instance is assumed to exist, just check that
+ tag_types = TagTypes(self.api,{'tagname':tagname})
+ if not tag_types:
+ raise PLCInvalidArgument,"No such TagType %s"%tagname
+ tag_type = tag_types[0]
+ person_tags=PersonTags(self.api,{'tagname':tagname,'person_id':person['person_id']})
+ if not person_tags:
+ person_tag = PersonTag(self.api)
+ person_tag['person_id'] = person['person_id']
+ person_tag['tag_type_id'] = tag_type['tag_type_id']
+ person_tag['tagname'] = tagname
+ person_tag['value'] = value
+ person_tag.sync()
+ else:
+ person_tag = person_tags[0]
+ person_tag['value'] = value
+ person_tag.sync()
+
+ # Logging variables
+ self.event_objects = {'Person': [person['person_id']]}
+
+ # Redact password
+ if 'password' in person_fields:
+ person_fields['password'] = "Removed by API"
+ self.message = 'Person %d updated: %s.' % \
+ (person['person_id'], person_fields.keys())
+ if 'enabled' in person_fields:
+ self.message += ' Person enabled'