Skip to content
Snippets Groups Projects
Commit 68126bdd authored by Eesaan Atluri's avatar Eesaan Atluri
Browse files

Add task success state to msg dict being returned to callback queue.

parent 576ebf1b
No related branches found
No related tags found
2 merge requests!147Merge previous default branch feat-cod-rmq into main,!119Feat account management
...@@ -21,7 +21,8 @@ def new_jobs(ch, method, properties, body): ...@@ -21,7 +21,8 @@ def new_jobs(ch, method, properties, body):
msg = json.loads(body) msg = json.loads(body)
username = msg["username"] username = msg["username"]
action = msg["action"] action = msg["action"]
msg["success"] = False msg["success"] = {}
msg["success"][task] = False
corr_id = properties.correlation_id corr_id = properties.correlation_id
reply_to = properties.reply_to reply_to = properties.reply_to
...@@ -35,10 +36,11 @@ def new_jobs(ch, method, properties, body): ...@@ -35,10 +36,11 @@ def new_jobs(ch, method, properties, body):
elif action == 'unlock': elif action == 'unlock':
unblock_new_jobs = popen(unblock_new_jobs_cmd).read().rstrip() unblock_new_jobs = popen(unblock_new_jobs_cmd).read().rstrip()
msg["success"] = True msg["success"][task] = True
logger.info(f"Succeeded in blocking {username}'s jobs getting to run state")
except Exception: except Exception:
msg["success"] = False msg["success"][task] = False
msg["errmsg"] = "Exception raised while setting maxjobs that can enter run state, check the logs for stack trace" msg["errmsg"] = "Exception raised while setting maxjobs that can enter run state, check the logs for stack trace"
logger.error("", exc_info=True) logger.error("", exc_info=True)
......
...@@ -21,7 +21,8 @@ def ssh_access(ch, method, properties, body): ...@@ -21,7 +21,8 @@ def ssh_access(ch, method, properties, body):
msg = json.loads(body) msg = json.loads(body)
username = msg["username"] username = msg["username"]
action = msg["action"] action = msg["action"]
msg["success"] = False msg["success"] = {}
msg["success"][task] = False
corr_id = properties.correlation_id corr_id = properties.correlation_id
reply_to = properties.reply_to reply_to = properties.reply_to
...@@ -35,10 +36,11 @@ def ssh_access(ch, method, properties, body): ...@@ -35,10 +36,11 @@ def ssh_access(ch, method, properties, body):
elif action == 'unlock': elif action == 'unlock':
unblock_ssh = popen(unblock_ssh_cmd).read().rstrip() unblock_ssh = popen(unblock_ssh_cmd).read().rstrip()
msg["success"] = True msg["success"][task] = True
logger.info(f"User {username} is added to nossh group")
except Exception: except Exception:
msg["success"] = False msg["success"][task] = False
msg["errmsg"] = "Exception raised, while blocking user's ssh access, check the logs for stack trace" msg["errmsg"] = "Exception raised, while blocking user's ssh access, check the logs for stack trace"
logger.error("", exc_info=True) logger.error("", exc_info=True)
......
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