Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
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
ef395bb9
Commit
ef395bb9
authored
3 years ago
by
Eesaan Atluri
Browse files
Options
Downloads
Patches
Plain Diff
Modify to accept state as arg and send msg based on state.
parent
377a8315
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
account_manager.py
+19
-23
19 additions, 23 deletions
account_manager.py
with
19 additions
and
23 deletions
account_manager.py
+
19
−
23
View file @
ef395bb9
...
@@ -4,11 +4,11 @@ import rc_util
...
@@ -4,11 +4,11 @@ import rc_util
import
argparse
import
argparse
import
signal
import
signal
import
uuid
import
uuid
import
import
rc_util
parser
=
argparse
.
ArgumentParser
(
description
=
"
Account management driver script
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Account management driver script
"
)
parser
.
add_argument
(
"
username
"
,
help
=
"
Username that should be locked/unlocked
"
)
parser
.
add_argument
(
"
username
"
,
help
=
"
Username that should be locked/unlocked
"
)
parser
.
add_argument
(
"
action
"
,
help
=
"
Choose
lock or unlock action to be take
n
"
)
parser
.
add_argument
(
"
state
"
,
help
=
"
Choose
from states (ok,block,certify) to put the user i
n
"
)
parser
.
add_argument
(
"
service
"
,
nargs
=
'
*
'
,
help
=
"
List one or more services to be blocked
"
)
parser
.
add_argument
(
"
service
"
,
nargs
=
'
*
'
,
help
=
"
List one or more services to be blocked
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"
-a
"
,
"
--all
"
,
help
=
"
Block all services
"
)
"
-a
"
,
"
--all
"
,
help
=
"
Block all services
"
)
...
@@ -22,7 +22,7 @@ args = parser.parse_args()
...
@@ -22,7 +22,7 @@ args = parser.parse_args()
timeout
=
60
timeout
=
60
username
=
args
.
username
username
=
args
.
username
action
=
args
.
action
state
=
args
.
state
service
=
args
.
service
service
=
args
.
service
corr_id
=
str
(
uuid
.
uuid4
())
corr_id
=
str
(
uuid
.
uuid4
())
...
@@ -30,6 +30,13 @@ callback_queue = rc_rmq.bind_queue(exclusive=True)
...
@@ -30,6 +30,13 @@ callback_queue = rc_rmq.bind_queue(exclusive=True)
msg
=
{}
msg
=
{}
if
state
==
'
block
'
or
state
==
'
certify
'
:
action
=
lock
elif
state
==
'
ok
'
:
action
=
unlock
else
:
print
(
"
Invalid state provided. Check the help menu.
"
)
if
args
.
all
is
not
None
:
if
args
.
all
is
not
None
:
# send a broadcast message to all agents
# send a broadcast message to all agents
rc_rmq
.
publish_msg
(
rc_rmq
.
publish_msg
(
...
@@ -40,26 +47,15 @@ if args.all is not None:
...
@@ -40,26 +47,15 @@ if args.all is not None:
)
)
else
:
else
:
for
each_service
in
service
:
for
each_service
in
service
:
if
action
==
'
lock
'
:
rc_rmq
.
publish_msg
(
rc_rmq
.
publish_msg
(
{
{
"
routing_key
"
:
f
"
{
service
}
.
{
username
}
"
,
"
routing_key
"
:
f
"
{
service
}
.
{
username
}
"
,
"
props
"
:
pika
.
BasicProperties
(
"
props
"
:
pika
.
BasicProperties
(
correlation_id
=
corr_id
,
reply_to
=
callback_queue
correlation_id
=
corr_id
,
reply_to
=
callback_queue
),
),
"
msg
"
:
{
"
username
"
:
username
,
"
action
"
:
action
,
"
service
"
:
service
},
"
msg
"
:
{
"
username
"
:
username
,
"
action
"
:
action
,
"
service
"
:
service
},
}
}
)
)
elif
action
==
'
unlock
'
:
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
"
{
service
}
.
{
username
}
"
,
"
props
"
:
pika
.
BasicProperties
(
correlation_id
=
corr_id
,
reply_to
=
callback_queue
),
"
msg
"
:
{
"
username
"
:
username
,
"
action
"
:
action
,
"
service
"
:
service
},
}
)
def
timeout_handler
(
signum
,
frame
):
def
timeout_handler
(
signum
,
frame
):
print
(
"
Process timeout, there
'
s some issue with agents
"
)
print
(
"
Process timeout, there
'
s some issue with agents
"
)
...
...
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