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
ecc4069e
Unverified
Commit
ecc4069e
authored
4 years ago
by
Ravi Tripathi
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #22 from diedpigs/feat-verify-agent
Feat dir verify agent
parents
05246993
5ae8a9ad
No related branches found
Branches containing commit
No related tags found
5 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!85
kill nginx process running under user from login node
,
!51
Fix acct create wait
,
!39
WIP:Feat cod rmq
,
!38
WIP: Feat cod rmq
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dir_verify.py
+65
-0
65 additions, 0 deletions
dir_verify.py
with
65 additions
and
0 deletions
dir_verify.py
0 → 100644
+
65
−
0
View file @
ecc4069e
#!/usr/bin/env python
import
sys
import
json
import
shutil
import
rc_util
from
pathlib
import
Path
from
rc_rmq
import
RCRMQ
task
=
'
dir_verify
'
dirs
=
[
'
/home
'
,
'
/data/user
'
,
'
/data/scratch
'
]
args
=
rc_util
.
get_args
()
logger
=
rc_util
.
get_logger
(
args
)
# Instantiate rabbitmq object
rc_rmq
=
RCRMQ
({
'
exchange
'
:
'
RegUsr
'
,
'
exchange_type
'
:
'
topic
'
})
def
dir_verify
(
ch
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
username
=
msg
[
'
username
'
]
msg
[
'
task
'
]
=
task
msg
[
'
success
'
]
=
False
try
:
for
d
in
dirs
:
path
=
Path
(
d
)
/
msg
[
'
username
'
]
if
args
.
dry_run
:
logger
.
info
(
f
'
Checking dirs:
{
path
}
'
)
else
:
if
not
path
.
exists
():
# Make sure folder exists and with right permission
path
.
mkdir
(
mode
=
0o700
)
# Make sure ownership is correct
shutil
.
chown
(
path
,
int
(
msg
[
'
uid
'
]),
int
(
msg
[
'
gid
'
]))
logger
.
debug
(
f
'
{
path
}
created
'
)
msg
[
'
success
'
]
=
True
except
Exception
as
exception
:
logger
.
error
(
''
,
exc_info
=
True
)
# send confirm message
rc_rmq
.
publish_msg
({
'
routing_key
'
:
'
confirm.
'
+
username
,
'
msg
'
:
msg
})
logger
.
debug
(
f
'
User
{
username
}
confirmation sent
'
)
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
logger
.
info
(
f
'
Start listening to queue:
{
task
}
'
)
rc_rmq
.
start_consume
({
'
queue
'
:
task
,
'
routing_key
'
:
"
verify.*
"
,
'
cb
'
:
dir_verify
})
logger
.
info
(
'
Disconnected
'
)
rc_rmq
.
disconnect
()
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