Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
15
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
28c18109
Commit
28c18109
authored
2 years ago
by
Eesaan Atluri
Browse files
Options
Downloads
Patches
Plain Diff
Change var names appropriately and w.r.t group_vars/all
parent
cfb17105
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!137
Refactor ssh access agent
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
prod_rmq_agents/ssh_access.py
+11
-11
11 additions, 11 deletions
prod_rmq_agents/ssh_access.py
with
11 additions
and
11 deletions
prod_rmq_agents/ssh_access.py
+
11
−
11
View file @
28c18109
...
...
@@ -51,33 +51,33 @@ def ssh_access(ch, method, properties, body):
proc
=
Popen
([
'
/usr/bin/groups
'
,
username
],
stdout
=
PIPE
,
stderr
=
PIPE
)
out
,
err
=
proc
.
communicate
()
user_group
_list
=
out
.
decode
().
strip
().
split
(
"
:
"
)[
1
].
split
()
lock
_groups
=
rcfg
.
lock
_groups
user_group
s
=
out
.
decode
().
strip
().
split
(
"
:
"
)[
1
].
split
()
state
_groups
=
rcfg
.
state
_groups
"""
Filter the lock group a user is in and assign to spl
lambda function returns common elements between two lists. For all
the true values by returned lambda function for common elements
corresponding values are included as a list by filter function.
"""
spl
_groups
=
list
(
filter
(
lambda
x
:
x
in
list
(
lock
_groups
.
values
()),
user_group
_list
))
user_state
_groups
=
list
(
filter
(
lambda
x
:
x
in
list
(
rcfg
.
state
_groups
.
values
()),
user_group
s
))
# Depending on state add user to the group corresponding to state.
# Remove user from
lock
_groups they are already part of.
# Remove user from
user_state
_groups they are already part of.
# eg: {"groups": { "add":[a,b,c], "remove":[d,e,f] }
if
state
==
'
certification
'
:
msg
[
"
groups
"
][
"
add
"
]
=
[
lock
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
spl
_groups
msg
[
"
groups
"
][
"
add
"
]
=
[
state
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
user_state
_groups
elif
state
==
'
hold
'
:
msg
[
"
groups
"
][
"
add
"
]
=
[
lock
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
spl
_groups
msg
[
"
groups
"
][
"
add
"
]
=
[
state
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
user_state
_groups
elif
state
==
'
pre_certification
'
:
msg
[
"
groups
"
][
"
add
"
]
=
[
lock
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
spl
_groups
msg
[
"
groups
"
][
"
add
"
]
=
[
state
_groups
[
state
]]
msg
[
"
groups
"
][
"
remove
"
]
=
user_state
_groups
elif
state
==
'
ok
'
:
msg
[
"
groups
"
][
"
remove
"
]
=
spl
_groups
msg
[
"
groups
"
][
"
remove
"
]
=
user_state
_groups
# send a message to group_member.py agent
logger
.
debug
(
f
"
sending msg to group agent:
{
msg
}
"
)
...
...
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