Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
16
Issue boards
Milestones
Wiki
Code
Merge requests
10
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
5dcf31a9
Commit
5dcf31a9
authored
3 years ago
by
Eesaan Atluri
Browse files
Options
Downloads
Patches
Plain Diff
Task manager for controlling flow of acctmgr agents
parent
a4d483da
No related branches found
No related tags found
2 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!119
Feat account management
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
prod_rmq_agents/acct_mgmt_workflow.py
+92
-0
92 additions, 0 deletions
prod_rmq_agents/acct_mgmt_workflow.py
with
92 additions
and
0 deletions
prod_rmq_agents/acct_mgmt_workflow.py
0 → 100755
+
92
−
0
View file @
5dcf31a9
#!/usr/bin/env python3
import
json
import
rc_util
import
argparse
import
signal
import
uuid
import
pika
import
rc_util
from
rc_rmq
import
RCRMQ
import
rabbit_config
as
rcfg
import
time
task
=
"
acctmgr
"
# Instantiate rabbitmq object
rc_rmq
=
RCRMQ
({
"
exchange
"
:
rcfg
.
Exchange
,
"
exchange_type
"
:
"
topic
"
})
tracking
=
{}
def
manage_acct
(
ch
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
op
=
method
.
routing_key
.
split
(
"
.
"
)[
1
]
username
=
msg
[
"
username
"
]
state
=
msg
[
"
state
"
]
service
=
msg
[
"
service
"
]
queuename
=
msg
[
"
queuename
"
]
if
username
in
tracking
:
current
=
tracking
[
username
]
else
:
current
=
tracking
[
username
]
=
{}
if
op
==
'
request
'
:
if
state
==
'
blocked
'
or
state
==
'
certification
'
:
msg
[
"
action
"
]
=
"
lock
"
elif
state
==
'
ok
'
:
msg
[
"
action
"
]
=
"
unlock
"
else
:
print
(
"
Invalid state provided. Check the help menu.
"
)
if
service
==
'
all
'
:
current
[
"
new_jobs
"
]
=
None
current
[
"
expire_account
"
]
=
None
# send a broadcast message to all agents
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
"
{
msg
[
'
action
'
]
}
.
{
queuename
}
"
,
"
msg
"
:
msg
,
}
)
else
:
for
each_service
in
service
:
current
[
each_service
]
=
None
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
"
{
each_service
}
.
{
queuename
}
"
,
"
msg
"
:
msg
}
)
elif
op
==
'
done
'
:
# Check if each task/agent returned success
current
[
msg
[
"
task
"
]]
=
msg
[
"
success
"
]
done
=
True
for
task
in
current
.
keys
():
if
current
[
task
]
is
None
:
done
=
False
if
done
:
rc_util
.
update_state
(
username
,
state
)
# Send done msg to account_manager.py
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
'
certified.
{
queuename
}
'
,
"
msg
"
:
msg
,
}
)
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
rc_rmq
.
bind_queue
(
queue
=
task
,
routing_key
=
'
acctmgr.request.*
'
,
durable
=
True
)
rc_rmq
.
bind_queue
(
queue
=
task
,
routing_key
=
'
acctmgr.done.*
'
,
durable
=
True
)
print
(
"
Waiting for completion...
"
)
rc_rmq
.
start_consume
(
{
"
queue
"
:
task
,
"
cb
"
:
manage_acct
}
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment