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
Merge requests
!22
Feat dir verify agent
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feat dir verify agent
github/fork/diedpigs/feat-verify-agent
into
feat-cod-rmq
Overview
3
Commits
5
Pipelines
0
Changes
1
Merged
Bo-Chun Chen
requested to merge
github/fork/diedpigs/feat-verify-agent
into
feat-cod-rmq
5 years ago
Overview
3
Commits
5
Pipelines
0
Changes
1
Expand
👍
0
👎
0
Merge request reports
Compare
feat-cod-rmq
feat-cod-rmq (base)
and
latest version
latest version
5ae8a9ad
5 commits,
1 year ago
1 file
+
65
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
dir_verify.py
0 → 100644
+
65
−
0
Options
#!/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
()
Loading