def change_humen_password(request, pk): humen = get_object_or_404(Humen, pk=pk) # Step 1: encrypt password passwd = request.POST["my_dear_cleartext"] encrypted_password = get_crypto_base64_rn2014(passwd) # Step 2: send to RabbitMQ following spec on # https://docs.google.com/document/d/1S_mwVnNOIrzbo7gEJlgrmt4w1ZZWSFM0Om5DCTGuJCc/edit# routing_key = "humen.password" data = json.dumps({ "username" : humen.cu, "password" : encrypted_password, }) if settings.RABBITMQ_ENABLE: send_to_rabbitmq(routing_key, data) logger.debug("[RABBIT PASSWD UPDATE %s] %s" % (routing_key, data)) else: logger.debug("[RABBIT DISABLED: PASSWD UPDATE SIMULATION] %s" % data) return HttpResponse("OK")
def my_log_queue(sender, instance, created, **kwargs): data = serializers.serialize("json", [instance], indent=2) # Publish changes to RabbitMQ server routing_key = get_rabbitmq_routing_key(sender, instance, created) if routing_key: send_to_rabbitmq(routing_key, data) logger.debug("[DB WRITE %s] %s" % (routing_key, data)) else: logger.debug("[NO RABBIT DB WRITE] %s" % data)
def update_posix_groups(self, add=[], remove=[]): """ Update or (add or remove) posix groups """ final_add = [] final_remove = [] pgroup_names = [] # map(lambda x: x[0], self.posix_group_set.values('name')) for gadd in add: # update or add groups if gadd not in pgroup_names: final_add.append(gadd) for gdel in remove: # update or remove groups if gdel in pgroup_names: final_remove.append(gdel) #self.posix_group_set.remove(*final_remove) #self.posix_group_set.add(*final_add) routing_key = "humen.groups" data = json.dumps({ "username" : self.cu, "add" : add, #original groups sent -> RABBIT is more up-to-date than me "remove" : remove, #original groups sent -> RABBIT is more up-to-date than me }) # SEND TO RABBITMQ if settings.RABBITMQ_ENABLE: send_to_rabbitmq(routing_key, data) logger.info("[UPDATE %s] %s" % (routing_key, data))