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
66d7dbf2
Commit
66d7dbf2
authored
5 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Utilize rc_util
parent
ff962a25
No related branches found
No related tags found
6 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
,
!22
Feat dir verify agent
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dir_verify.py
+23
-9
23 additions, 9 deletions
dir_verify.py
with
23 additions
and
9 deletions
dir_verify.py
+
23
−
9
View file @
66d7dbf2
...
@@ -2,12 +2,16 @@
...
@@ -2,12 +2,16 @@
import
sys
import
sys
import
json
import
json
import
shutil
import
shutil
import
rc_util
from
pathlib
import
Path
from
pathlib
import
Path
from
rc_rmq
import
RCRMQ
from
rc_rmq
import
RCRMQ
task
=
'
dir_verify
'
task
=
'
dir_verify
'
dirs
=
[
'
/home
'
,
'
/data/user
'
,
'
/data/scratch
'
]
dirs
=
[
'
/home
'
,
'
/data/user
'
,
'
/data/scratch
'
]
args
=
rc_util
.
get_args
()
logger
=
rc_util
.
get_logger
(
args
)
# Instantiate rabbitmq object
# Instantiate rabbitmq object
rc_rmq
=
RCRMQ
({
'
exchange
'
:
'
RegUsr
'
,
'
exchange_type
'
:
'
topic
'
})
rc_rmq
=
RCRMQ
({
'
exchange
'
:
'
RegUsr
'
,
'
exchange_type
'
:
'
topic
'
})
...
@@ -20,16 +24,23 @@ def dir_verify(ch, method, properties, body):
...
@@ -20,16 +24,23 @@ def dir_verify(ch, method, properties, body):
for
d
in
dirs
:
for
d
in
dirs
:
path
=
Path
(
d
)
/
msg
[
'
username
'
]
path
=
Path
(
d
)
/
msg
[
'
username
'
]
if
not
path
.
exists
():
if
args
.
dry_run
:
# Make sure folder exists and with right permission
logger
.
info
(
f
'
Checking dirs:
{
path
}
'
)
path
.
mkdir
(
mode
=
0o700
)
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
,
msg
[
'
uid
'
],
msg
[
'
gid
'
])
logger
.
debug
(
f
'
{
path
}
created
'
)
# Make sure ownership is correct
shutil
.
chown
(
path
,
msg
[
'
uid
'
],
msg
[
'
gid
'
])
success
=
True
success
=
True
except
:
e
=
sys
.
exc_info
()[
0
]
except
Exception
as
exception
:
print
(
"
[{}]: Error: {}
"
.
format
(
task
,
e
)
)
logger
.
error
(
''
,
exc_info
=
Tru
e
)
# send confirm message
# send confirm message
rc_rmq
.
publish_msg
({
rc_rmq
.
publish_msg
({
...
@@ -40,12 +51,15 @@ def dir_verify(ch, method, properties, body):
...
@@ -40,12 +51,15 @@ def dir_verify(ch, method, properties, body):
}
}
})
})
logger
.
debug
(
f
'
User
{
username
}
confirmation sent
'
)
print
(
"
Start listening to queue: {
}
"
.
format
(
task
)
)
logger
.
info
(
f
'
Start listening to queue:
{
task
}
'
)
rc_rmq
.
start_consume
({
rc_rmq
.
start_consume
({
'
queue
'
:
task
,
'
queue
'
:
task
,
'
routing_key
'
:
"
verify.*
"
,
'
routing_key
'
:
"
verify.*
"
,
'
cb
'
:
dir_verify
'
cb
'
:
dir_verify
})
})
logger
.
info
(
'
Disconnected
'
)
rc_rmq
.
disconnect
()
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