From f4b4574d5bac5303405650b8fffaaad5eba9cf6e Mon Sep 17 00:00:00 2001 From: rtripath89 <ravi89@uab.edu> Date: Thu, 20 Feb 2020 14:07:05 -0600 Subject: [PATCH] Correct callback and remove home dir (#13) * Renaming callback functions * Remove home creation with useradd command --- ohpc_account_create.py | 6 +++--- ood_account_create.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ohpc_account_create.py b/ohpc_account_create.py index 4778450..ee69364 100644 --- a/ohpc_account_create.py +++ b/ohpc_account_create.py @@ -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 326e541..2abaa23 100644 --- a/ood_account_create.py +++ b/ood_account_create.py @@ -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: -- GitLab