diff --git a/prod_rmq_agents/git_commit.py b/prod_rmq_agents/git_commit.py index 697bdabcb0451f6f7794d014aa2c3a435370ecac..19740f43f345becaa153825019212c3ccbe3b2fe 100644 --- a/prod_rmq_agents/git_commit.py +++ b/prod_rmq_agents/git_commit.py @@ -6,6 +6,7 @@ import json import rc_util from rc_rmq import RCRMQ import rabbit_config as rmq_cfg +import time task = "git_commit" @@ -37,7 +38,8 @@ def git_commit(ch, method, properties, body): username = msg["username"] msg["task"] = task msg["success"] = False - branch_name = "issue-add-users-" + username.lower() + branch_name = "issue-add-users-" + \ + username.lower() + "-" + time.strftime("%Y%m%d_%H%M%S") user_ldif = users_dir + f"/{username}.ldif" group_ldif = groups_dir + f"/{username}.ldif" diff --git a/prod_rmq_agents/notify_user.py b/prod_rmq_agents/notify_user.py index 92b442458a4c04d7695b32da897432f6225181f5..4f1dd3e47db9c07703eb1261d4ce464e35c5b1d8 100644 --- a/prod_rmq_agents/notify_user.py +++ b/prod_rmq_agents/notify_user.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import sys import json import rc_util import smtplib @@ -15,12 +14,13 @@ task = "notify_user" args = rc_util.get_args() logger = rc_util.get_logger(args) -db = dataset.connect(f"sqlite:///.agent_db/user_reg.db") +db = dataset.connect(f"sqlite:///{rcfg.db_path}/user_reg.db") table = db["users"] # Instantiate rabbitmq object rc_rmq = RCRMQ({"exchange": "RegUsr", "exchange_type": "topic"}) + # Email instruction to user def notify_user(ch, method, properties, body): msg = json.loads(body) diff --git a/prod_rmq_agents/task_manager.py b/prod_rmq_agents/task_manager.py index 036540ac65c837881e74601eea4ab4d366be590c..9ad0b78bcdccfc679790fc983f67d65cb517a851 100644 --- a/prod_rmq_agents/task_manager.py +++ b/prod_rmq_agents/task_manager.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import sys import copy import json import signal @@ -18,7 +17,7 @@ timeout = 30 args = rc_util.get_args() logger = rc_util.get_logger(args) -db = dataset.connect(f"sqlite:///.agent_db/user_reg.db") +db = dataset.connect(f"sqlite:///{rcfg.db_path}/user_reg.db") table = db["users"] record = { @@ -159,9 +158,7 @@ def task_manager(ch, method, properties, body): if user_db: # Restore task status - current["request"]["create_account"] = user_db[ - "create_account" - ] + current["request"]["create_account"] = user_db["create_account"] current["verify"]["git_commit"] = user_db["git_commit"] current["verify"]["dir_verify"] = user_db["dir_verify"] current["verify"]["subscribe_mail_list"] = user_db[ diff --git a/prod_rmq_agents/user_reg_logger.py b/prod_rmq_agents/user_reg_logger.py index 19997096e1ab82650146d09fadacf0c62328e5f3..ea8f9eed894c93c304f7c755c3f74f69b72f7029 100755 --- a/prod_rmq_agents/user_reg_logger.py +++ b/prod_rmq_agents/user_reg_logger.py @@ -1,10 +1,10 @@ #!/usr/bin/env python import json -import sys import dataset import rc_util from rc_rmq import RCRMQ from datetime import datetime +import rabbit_config as rcfg # Define queue name task = "reg_logger" @@ -19,9 +19,10 @@ args = rc_util.get_args() logger = rc_util.get_logger() # Open registry table in DB -db = dataset.connect("sqlite:///.agent_db/reg_logger.db") +db = dataset.connect(f"sqlite:///{rcfg.db_path}/reg_logger.db") account_req_table = db["registry"] + # Define registration logger callback def log_registration(ch, method, properties, body): diff --git a/rabbit_config.py.example b/rabbit_config.py.example index 21386da2c7dfadaec5804114ee27f12c18dc4608..bffaaab2a8f1b815c5ca6886264d5c3e79236822 100644 --- a/rabbit_config.py.example +++ b/rabbit_config.py.example @@ -14,6 +14,7 @@ User_dirs = ['/home', '/data/user', '/data/scratch'] # git_commit agent config rc_users_ldap_repo_loc = "~/git/rc-users" +db_path = ".agent_db" # Config related to email Mail_server = 'localhost'