Skip to content
Snippets Groups Projects
Unverified Commit f4b4574d authored by Ravi Tripathi's avatar Ravi Tripathi Committed by GitHub
Browse files

Correct callback and remove home dir (#13)

* Renaming callback functions

* Remove home creation with useradd command
parent e4a2df57
No related branches found
No related tags found
1 merge request!23Feat resolve uid gid
...@@ -34,12 +34,12 @@ result = channel.queue_declare(queue=queue_name, exclusive=False) ...@@ -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) 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) msg = json.loads(body)
print("Message received {}".format(msg)) print("Message received {}".format(msg))
username = msg['username'] username = msg['username']
try: try:
subprocess.call(["sudo", "useradd", "-m", username]) subprocess.call(["sudo", "useradd", username])
print("User {} has been added to {}".format(username, hostname)) print("User {} has been added to {}".format(username, hostname))
except: except:
print("Failed to create user") print("Failed to create user")
...@@ -51,7 +51,7 @@ def slurm_account_create(ch, method, properties, body): ...@@ -51,7 +51,7 @@ def slurm_account_create(ch, method, properties, body):
# ingest messages # 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 # initiate message ingestion
try: try:
......
...@@ -33,7 +33,7 @@ result = channel.queue_declare(queue=queue_name, exclusive=False) ...@@ -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) 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) msg = json.loads(body)
print("Message received {}".format(msg)) print("Message received {}".format(msg))
username = msg['username'] username = msg['username']
...@@ -41,7 +41,7 @@ def slurm_account_create(ch, method, properties, body): ...@@ -41,7 +41,7 @@ def slurm_account_create(ch, method, properties, body):
user_gid = str(msg['gid']) user_gid = str(msg['gid'])
try: try:
subprocess.call(["sudo", "groupadd", "-r", "-g", user_gid, username]) 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)) print("User {} has been added to {}".format(username, hostname))
except: except:
print("Failed to create user") print("Failed to create user")
...@@ -52,7 +52,7 @@ def slurm_account_create(ch, method, properties, body): ...@@ -52,7 +52,7 @@ def slurm_account_create(ch, method, properties, body):
# ingest messages # 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 # initiate message ingestion
try: try:
......
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