Skip to content
Snippets Groups Projects
Commit ba5dabf8 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Update rc_util with new topic exchange

parent 7ec758f5
No related branches found
No related tags found
2 merge requests!23Feat resolve uid gid,!18Redesign RabbitMQ
from rc_rmq import RCRMQ from rc_rmq import RCRMQ
import json import json
rc_rmq = RCRMQ({'exchange': 'Register'}) rc_rmq = RCRMQ({'exchange': 'RegUsr', 'exchange_type': 'topic'})
confirm_rmq = RCRMQ({'exchange': 'Confirm'}) tasks = {'ohpc_account': None, 'ood_account': None, 'slurm_account': None}
tasks = {'ohpc_account': False, 'ohpc_homedir': False, 'ood_account': False, 'slurm_account': False}
def add_account(username, full='', reason=''): def add_account(username, full='', reason=''):
rc_rmq.publish_msg({ rc_rmq.publish_msg({
'routing_key': 'ohpc_account', 'routing_key': 'request.' + username,
'msg': { 'msg': {
"username": username, "username": username,
"fullname": full, "fullname": full,
...@@ -18,8 +17,8 @@ def add_account(username, full='', reason=''): ...@@ -18,8 +17,8 @@ def add_account(username, full='', reason=''):
def worker(ch, method, properties, body): def worker(ch, method, properties, body):
msg = json.loads(body) msg = json.loads(body)
task = msg['task'] task = msg['task']
print("get msg: {}".format(task))
tasks[task] = msg['success'] tasks[task] = msg['success']
print("Got msg: {}({})".format(msg['task'], msg['success']))
# Check if all tasks are done # Check if all tasks are done
done = True done = True
...@@ -37,6 +36,7 @@ def consume(username, callback, debug=False): ...@@ -37,6 +36,7 @@ def consume(username, callback, debug=False):
else: else:
confirm_rmq.start_consume({ confirm_rmq.start_consume({
'queue': username, 'queue': username,
'routing_key': 'confirm.' + username,
'cb': callback 'cb': callback
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment