Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Bo-Chun Chen
rabbitmq_agents
Commits
5779c40d
Commit
5779c40d
authored
5 years ago
by
Cloud User
Browse files
Options
Downloads
Patches
Plain Diff
Adding json import, and changing the slurm call to add sacctmgr account
parent
9be2f281
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slurm_agent.py
+6
-2
6 additions, 2 deletions
slurm_agent.py
with
6 additions
and
2 deletions
slurm_agent.py
100644 → 100755
+
6
−
2
View file @
5779c40d
...
...
@@ -5,6 +5,7 @@ import rabbit_config as rcfg
import
socket
import
subprocess
import
time
import
json
hostname
=
socket
.
gethostname
().
split
(
"
.
"
,
1
)[
0
]
connect_host
=
rcfg
.
Server
if
hostname
!=
rcfg
.
Server
else
"
localhost
"
...
...
@@ -22,6 +23,8 @@ parameters = pika.ConnectionParameters(connect_host,
connection
=
pika
.
BlockingConnection
(
parameters
)
channel
=
connection
.
channel
()
print
"
connection established. Listening for messages:
"
# create exchange to pass messages
channel
.
exchange_declare
(
exchange
=
rcfg
.
Exchange
,
exchange_type
=
'
direct
'
)
...
...
@@ -32,15 +35,16 @@ channel.queue_bind(exchange=rcfg.Exchange, queue=queue_name, routing_key=queue_n
def
slurm_account_create
(
ch
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
print
(
"
Message received {}
"
.
format
(
msg
))
username
=
msg
[
'
username
'
]
try
:
subprocess
.
call
([
"
sacctmgr
"
,
"
add
"
,
"
account
"
,
username
,
"
Descripition: Add user
"
])
subprocess
.
call
([
"
sudo
"
,
"
sacctmgr
"
,
"
add
"
,
"
account
"
,
username
,
"
-i
"
,
"
Descripition: Add user
"
])
except
:
print
(
"
Failed to create user
"
)
channel
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
channel
.
basic_publish
(
exchange
=
rcfg
.
Exchange
,
routing_key
=
'
warewulf_file_sync
'
,
body
=
json
.
dumps
(
msg
))
channel
.
basic_publish
(
exchange
=
rcfg
.
Exchange
,
routing_key
=
username
,
body
=
json
.
dumps
(
msg
))
# ingest messages
...
...
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