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
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
!8
Add account create script
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Add account create script
github/fork/diedpigs/feat-add-create-script
into
develop
Overview
0
Commits
1
Pipelines
0
Changes
1
Closed
Bo-Chun Chen
requested to merge
github/fork/diedpigs/feat-add-create-script
into
develop
5 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
username is must. optional arguments: Full name and Reason
👍
0
👎
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
a18f9154
1 commit,
1 year ago
1 file
+
41
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
create_account.py
0 → 100755
+
41
−
0
Options
#!/usr/bin/env python
import
sys
import
json
import
pika
import
socket
import
rabbitmq_config
as
rcfg
if
len
(
sys
.
argv
)
<
2
:
sys
.
stderr
.
write
(
"
Usage: {} USERNAME [FULL_NAME] [REASON]
"
.
format
(
sys
.
argv
[
0
]))
exit
(
1
)
node
=
'
ohpc
'
user_name
=
sys
.
argv
[
1
]
full_name
=
sys
.
argv
[
2
]
if
len
(
sys
.
argv
)
>=
3
else
''
reason
=
sys
.
argv
[
3
]
if
len
(
sys
.
argv
)
>=
4
else
''
message
=
{
"
username
"
:
user_name
,
"
fullname
"
:
full_name
,
"
reason
"
:
reason
}
hostname
=
socket
.
gethostname
().
split
(
"
.
"
,
1
)[
0
]
connect_host
=
rcfg
.
Server
if
hostname
!=
rcfg
.
Server
else
"
localhost
"
# Set up credentials to connect to RabbitMQ server
credentials
=
pika
.
PlainCredentials
(
rcfg
.
User
,
rcfg
.
Password
)
parameters
=
pika
.
ConnectionParameters
(
connect_host
,
rcfg
.
Port
,
rcfg
.
VHost
,
credentials
)
# Establish connection to RabbitMQ server
connection
=
pika
.
BlockingConnection
(
parameters
)
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
rcfg
.
Exchange
,
exchange_type
=
'
direct
'
)
channel
.
basic_publish
(
exchange
=
rcfg
.
Exchange
,
routing_key
=
node
,
body
=
json
.
dumps
(
message
))
print
(
"
Account for user: {}, requested.
"
.
format
(
user_name
))
connection
.
close
()
Loading