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

Merge branch 'develop' into feat-connection-module

Conflicts:
	README.md
parents 8e8dd901 1dbcac12
No related branches found
No related tags found
2 merge requests!23Feat resolve uid gid,!9Feat connection module
......@@ -2,7 +2,7 @@
This repo keeps different rabbitmq agents that help in account creation on OHPC system.
It has 2 branches ```develop``` and ```production``` , that house agents based on where they are launched
It has 2 branches ```develop``` and ```production``` , that houses agents based on where they are launched
## Using RCRMQ class
......
......@@ -3,7 +3,7 @@ import pika
import sys
import socket
import json
import rabbitmq_config as rcfg
import rabbit_config as rcfg
if len(sys.argv) < 3:
sys.stderr.write("Usage: {} TAG USERNAME ".format(sys.argv[0]))
......
......@@ -24,7 +24,7 @@ parameters = pika.ConnectionParameters(connect_host,
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
print "connection established. Listening for messages:"
print("connection established. Listening for messages:")
# create exchange to pass messages
channel.exchange_declare(exchange=rcfg.Exchange, exchange_type='direct')
......@@ -34,12 +34,12 @@ result = channel.queue_declare(queue=queue_name, exclusive=False)
channel.queue_bind(exchange=rcfg.Exchange, queue=queue_name, routing_key=queue_name)
def slurm_account_create(ch, method, properties, body):
def ohpc_account_create(ch, method, properties, body):
msg = json.loads(body)
print("Message received {}".format(msg))
username = msg['username']
try:
subprocess.call(["sudo", "useradd", "-m", username])
subprocess.call(["sudo", "useradd", username])
print("User {} has been added to {}".format(username, hostname))
except:
print("Failed to create user")
......@@ -51,7 +51,7 @@ def slurm_account_create(ch, method, properties, body):
# ingest messages
channel.basic_consume(queue=queue_name, on_message_callback=slurm_account_create)
channel.basic_consume(queue=queue_name, on_message_callback=ohpc_account_create)
# initiate message ingestion
try:
......
......@@ -23,7 +23,7 @@ parameters = pika.ConnectionParameters(connect_host,
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
print "connection established. Listening for messages:"
print("connection established. Listening for messages:")
# create exchange to pass messages
channel.exchange_declare(exchange=rcfg.Exchange, exchange_type='direct')
......@@ -33,7 +33,7 @@ result = channel.queue_declare(queue=queue_name, exclusive=False)
channel.queue_bind(exchange=rcfg.Exchange, queue=queue_name, routing_key=queue_name)
def slurm_account_create(ch, method, properties, body):
def ood_account_create(ch, method, properties, body):
msg = json.loads(body)
print("Message received {}".format(msg))
username = msg['username']
......@@ -41,7 +41,7 @@ def slurm_account_create(ch, method, properties, body):
user_gid = str(msg['gid'])
try:
subprocess.call(["sudo", "groupadd", "-r", "-g", user_gid, username])
subprocess.call(["sudo", "useradd", "-u", user_uid, "-g", user_gid, "-m", username])
subprocess.call(["sudo", "useradd", "-u", user_uid, "-g", user_gid, username])
print("User {} has been added to {}".format(username, hostname))
except:
print("Failed to create user")
......@@ -52,7 +52,7 @@ def slurm_account_create(ch, method, properties, body):
# ingest messages
channel.basic_consume(queue=queue_name, on_message_callback=slurm_account_create)
channel.basic_consume(queue=queue_name, on_message_callback=ood_account_create)
# initiate message ingestion
try:
......
......@@ -2,5 +2,5 @@ Exchange = 'RegUsr'
User = 'reggie'
Password = 'CHANGE_IT_TO_YOUR_OWN_PASSWORD'
VHost = '/'
Server = 'ood'
Server = 'ohpc'
Port = 5672
argh==0.26.2
Click==7.0
dominate==2.3.5
eventlet==0.17.4
Flask==1.0.2
Flask-Bootstrap==3.3.7.1
Flask-Login==0.4.1
Flask-SocketIO==4.2.1
Flask-Testing==0.7.1
Flask-WTF==0.14.2
greenlet==0.4.15
gunicorn==18.0
itsdangerous==1.1.0
Jinja2==2.10.1
Mako==1.0.7
MarkupSafe==1.1.1
pathtools==0.1.2
pbr==5.1.3
pika==1.1.0
python-dateutil==1.5
python-editor==1.0.4
python-engineio==3.10.0
python-socketio==4.3.1
pytz==2013.7
PyYAML==5.1.2
six==1.12.0
stevedore==1.30.1
virtualenv==16.4.3
virtualenv-clone==0.5.1
virtualenvwrapper==4.8.4
visitor==0.1.3
Werkzeug==0.14.1
WTForms==2.2.1
......@@ -23,7 +23,7 @@ parameters = pika.ConnectionParameters(connect_host,
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
print "connection established. Listening for messages:"
print("connection established. Listening for messages:")
# create exchange to pass messages
channel.exchange_declare(exchange=rcfg.Exchange, exchange_type='direct')
......
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