Skip to content
Snippets Groups Projects
Commit 42b8c4df authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Split updated_by in agents and scripts

parent ffdf3308
No related branches found
No related tags found
2 merge requests!147Merge previous default branch feat-cod-rmq into main,!127Add updated_by field to user_state table
......@@ -40,7 +40,7 @@ msg["username"] = username
msg["state"] = state
msg["service"] = service
msg["queuename"] = queuename
msg["updated_by"] = rc_util.get_caller_info()
msg["updated_by"], msg["host"] = rc_util.get_caller_info()
# publish msg with acctmgr.{uname} routing key.
rc_rmq.publish_msg(
......
......@@ -25,7 +25,7 @@ args = parser.parse_args()
timeout = 60
queuename = rc_util.encode_name(args.username)
updated_by = rc_util.get_caller_info()
updated_by, host = rc_util.get_caller_info()
if args.email == "":
args.email = args.username
......@@ -60,6 +60,7 @@ rc_util.add_account(
full=args.full_name,
reason=args.reason,
updated_by=updated_by,
host=host,
)
print(f"Account for {args.username} requested.")
......
......@@ -16,7 +16,7 @@ args = parser.parse_args()
default_state = "ok"
today = datetime.now()
updated_by = rc_util.get_caller_info()
updated_by, host = rc_util.get_caller_info()
# Chunk size for insert into db
size = 1000
......@@ -45,6 +45,7 @@ if len(users) > 50:
state=default_state,
date=today,
updated_by=updated_by,
host=host,
)
for user in users[start:end]
]
......@@ -66,5 +67,6 @@ else:
"state": default_state,
"date": today,
"updated_by": updated_by,
"host": host,
}
)
......@@ -70,7 +70,9 @@ def manage_acct(ch, method, properties, body):
done = False
if done:
rc_util.update_state(username, state, msg.get("updated_by"))
rc_util.update_state(
username, state, msg.get("updated_by"), msg.get("host")
)
# Send done msg to account_manager.py
rc_rmq.publish_msg(
......
......@@ -277,7 +277,9 @@ def task_manager(ch, method, properties, body):
update_db(username, {"reported": True})
rc_util.update_state(username, "ok", msg.get("updated_by"))
rc_util.update_state(
username, "ok", msg.get("updated_by"), msg.get("host")
)
tracking.pop(username)
......
......@@ -23,6 +23,7 @@ def user_state(ch, method, properties, body):
msg = json.loads(body)
username = msg["username"]
updated_by = msg.get("updated_by")
host = msg.get("host")
op = msg["op"]
msg["success"] = False
errmsg = ""
......@@ -53,6 +54,7 @@ def user_state(ch, method, properties, body):
"state": state,
"date": datetime.now(),
"updated_by": updated_by,
"host": host,
}
)
logger.debug(f"User {username} state updates to {state}")
......
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