diff --git a/README.md b/README.md index 8aaac097dc08a439f2889361c8ccee2a3a211f69..97bfe2bf48cf7968bcde93ac0179e9b5cceb4be6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flask_producer.py b/flask_producer.py index 0beeaf9a14587391655ce5bae67e695976371f49..dc3c44634745278fa426821d2ea0a2ecc9e61e3f 100755 --- a/flask_producer.py +++ b/flask_producer.py @@ -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])) diff --git a/ohpc_account_create.py b/ohpc_account_create.py index 9c3f6a642a507859ac0aab2917a865c9ccb15afe..ee69364cfc859143ca6a560ba43469851b1f8d9c 100644 --- a/ohpc_account_create.py +++ b/ohpc_account_create.py @@ -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: diff --git a/ood_account_create.py b/ood_account_create.py index fcdac83e5b1caded8965884f8f41b552ba6a61c1..2abaa23429cd41e4565a25e2055ec18920713328 100644 --- a/ood_account_create.py +++ b/ood_account_create.py @@ -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: diff --git a/rabbit_config.py.example b/rabbit_config.py.example index 27c3dd9a3dcf7440766df3c2e20bc67eac289b28..5643bb163e71c667dffdb6890c854b84d3810596 100644 --- a/rabbit_config.py.example +++ b/rabbit_config.py.example @@ -2,5 +2,5 @@ Exchange = 'RegUsr' User = 'reggie' Password = 'CHANGE_IT_TO_YOUR_OWN_PASSWORD' VHost = '/' -Server = 'ood' +Server = 'ohpc' Port = 5672 diff --git a/requirements.txt b/requirements.txt index 721d7c72cc757638f1d85e56d160b2bf10078315..becc2ce1d48131ef086f528906361c6b94cd5487 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,33 +1 @@ -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 diff --git a/slurm_agent.py b/slurm_agent.py index 5ce3727c0cde324020a56ab5e4a929305dd88ef4..fde0949db0c57b42f16c9c04632140fc599aa2dc 100755 --- a/slurm_agent.py +++ b/slurm_agent.py @@ -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')