Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
16
Issue boards
Milestones
Wiki
Code
Merge requests
10
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
!97
Feat pre commit hook
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feat pre commit hook
github/fork/diedpigs/feat-pre-commit
into
feat-cod-rmq
Overview
1
Commits
6
Pipelines
0
Changes
10
Merged
Bo-Chun Chen
requested to merge
github/fork/diedpigs/feat-pre-commit
into
feat-cod-rmq
4 years ago
Overview
1
Commits
6
Pipelines
0
Changes
10
Expand
Setup to check coding style before every
git commit
👍
0
👎
0
Merge request reports
Compare
feat-cod-rmq
feat-cod-rmq (base)
and
latest version
latest version
f2b52e48
6 commits,
1 year ago
10 files
+
193
−
110
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
Search (e.g. *.vue) (Ctrl+P)
dev_rmq_agents/ohpc_account_create.py
+
17
−
19
Options
@@ -8,12 +8,13 @@ from rc_rmq import RCRMQ
task
=
"
ohpc_account
"
# Instantiate rabbitmq object
rc_rmq
=
RCRMQ
({
'
exchange
'
:
'
RegUsr
'
,
'
exchange_type
'
:
'
topic
'
})
rc_rmq
=
RCRMQ
({
"
exchange
"
:
"
RegUsr
"
,
"
exchange_type
"
:
"
topic
"
})
def
ohpc_account_create
(
ch
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
print
(
"
Message received {}
"
.
format
(
msg
))
username
=
msg
[
'
username
'
]
username
=
msg
[
"
username
"
]
success
=
False
try
:
subprocess
.
call
([
"
sudo
"
,
"
useradd
"
,
username
])
@@ -24,28 +25,25 @@ def ohpc_account_create(ch, method, properties, body):
print
(
"
[{}]: Error: {}
"
.
format
(
task
,
e
))
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
msg
[
'
uid
'
]
=
getpwnam
(
username
).
pw_uid
msg
[
'
gid
'
]
=
getpwnam
(
username
).
pw_gid
msg
[
"
uid
"
]
=
getpwnam
(
username
).
pw_uid
msg
[
"
gid
"
]
=
getpwnam
(
username
).
pw_gid
# send confirm message
rc_rmq
.
publish_msg
({
'
routing_key
'
:
'
confirm.
'
+
username
,
'
msg
'
:
{
'
task
'
:
task
,
'
success
'
:
success
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
"
confirm.
"
+
username
,
"
msg
"
:
{
"
task
"
:
task
,
"
success
"
:
success
},
}
}
)
)
if
success
:
# send create message to other agent
rc_rmq
.
publish_msg
(
{
'
routing_key
'
:
'
create.
'
+
username
,
'
msg
'
:
msg
})
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
"
create.
"
+
username
,
"
msg
"
:
msg
}
)
print
(
"
Start Listening to queue: {}
"
.
format
(
task
))
rc_rmq
.
start_consume
({
'
queue
'
:
task
,
'
routing_key
'
:
'
request.*
'
,
'
cb
'
:
ohpc_account_create
})
rc_rmq
.
start_consume
(
{
"
queue
"
:
task
,
"
routing_key
"
:
"
request.*
"
,
"
cb
"
:
ohpc_account_create
}
)
Loading