pas de URLParameter sur le pika wheezy
This commit is contained in:
parent
e63b25278f
commit
076d667d34
3 changed files with 54 additions and 4 deletions
|
@ -1,4 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import pika
|
||||||
|
|
||||||
# REPLACE password here
|
CREDS = pika.credentials.PlainCredentials('oie', '*******', True)
|
||||||
URL='amqps://oie:****@rabbitmq.crans.org:5671/%2F'
|
|
||||||
|
PARAMS = pika.ConnectionParameters(host='rabbitmq.crans.org',
|
||||||
|
port=5671, credentials=CREDS, ssl=True)
|
||||||
|
|
|
@ -5,8 +5,7 @@ import json
|
||||||
import dump
|
import dump
|
||||||
import config
|
import config
|
||||||
|
|
||||||
params = pika.URLParameters(config.URL)
|
conn = pika.BlockingConnection(config.PARAMS)
|
||||||
conn = pika.BlockingConnection(params)
|
|
||||||
ch = conn.channel()
|
ch = conn.channel()
|
||||||
ch.queue_declare(queue='CransTicket')
|
ch.queue_declare(queue='CransTicket')
|
||||||
def callback(ch, method, properties, body):
|
def callback(ch, method, properties, body):
|
||||||
|
|
48
dump_creds.py
Executable file
48
dump_creds.py
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash /usr/scripts/python.sh
|
||||||
|
|
||||||
|
import pika
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from lc_ldap.shortcuts import lc_ldap_readonly
|
||||||
|
from affich_tools import prompt
|
||||||
|
import lc_ldap.filter2 as filter
|
||||||
|
import config
|
||||||
|
|
||||||
|
rabbit_c = pika.BlockingConnection(config.PARAMS)
|
||||||
|
ch = rabbit_c.channel()
|
||||||
|
ch.queue_declare('CransTicket')
|
||||||
|
|
||||||
|
ldap = lc_ldap_readonly()
|
||||||
|
|
||||||
|
|
||||||
|
f = filter.human_to_ldap(sys.argv[1].decode('utf-8'))
|
||||||
|
adh = ldap.search(f)
|
||||||
|
if len(adh) > 1:
|
||||||
|
print "More than one result"
|
||||||
|
exit()
|
||||||
|
elif not adh:
|
||||||
|
print "Nobody"
|
||||||
|
else:
|
||||||
|
adh = adh[0]
|
||||||
|
adh.display()
|
||||||
|
while True:
|
||||||
|
c = prompt("[O/N]").lower()
|
||||||
|
if c == 'n':
|
||||||
|
exit()
|
||||||
|
elif c == 'o':
|
||||||
|
break
|
||||||
|
|
||||||
|
m = adh.machines()
|
||||||
|
|
||||||
|
to_print = []
|
||||||
|
for machine in m:
|
||||||
|
if u'<automatique>' in machine['macAddress']:
|
||||||
|
continue
|
||||||
|
login = machine['host'][0].split('.', 1)[0]
|
||||||
|
todo = {'login': login, 'macAddress': machine['macAddress'][0].value}
|
||||||
|
if machine.has_key('ipsec'):
|
||||||
|
todo['pass'] = machine['ipsec'][0].value
|
||||||
|
to_print.append(todo)
|
||||||
|
|
||||||
|
ch.basic_publish(exchange='', routing_key='CransTicket', body=json.dumps(to_print))
|
Loading…
Add table
Add a link
Reference in a new issue