Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPCasCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
hpc-team
HPCasCode
Commits
2ecf42f1
Commit
2ecf42f1
authored
7 years ago
by
Chris Hines
Browse files
Options
Downloads
Plain Diff
Merge branch 'fixProvisionSlurm' into 'master'
Fix provision slurm See merge request
!120
parents
1c47f801
03f9de20
No related branches found
No related tags found
1 merge request
!120
Fix provision slurm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
roles/provision_slurm/templates/provision_slurm.py.j2
+25
-13
25 additions, 13 deletions
roles/provision_slurm/templates/provision_slurm.py.j2
with
25 additions
and
13 deletions
roles/provision_slurm/templates/provision_slurm.py.j2
+
25
−
13
View file @
2ecf42f1
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
import
stat
import
stat
import
subprocess
import
subprocess
class
ldapSearchConfig
:
class
ldapSearchConfig
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
ldapserver
=
""
self
.
ldapserver
=
""
...
@@ -14,12 +15,13 @@ class ldapSearchConfig:
...
@@ -14,12 +15,13 @@ class ldapSearchConfig:
self
.
searchFilter
=
""
self
.
searchFilter
=
""
self
.
cacertfile
=
''
self
.
cacertfile
=
''
class
genericUser
:
class
genericUser
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
dn
=
""
self
.
dn
=
""
self
.
cn
=
""
self
.
cn
=
""
self
.
entry
=
""
self
.
entry
=
""
self
.
uid
=
""
self
.
uid
=
""
def
get_users
(
server
):
def
get_users
(
server
):
...
@@ -52,14 +54,24 @@ def mk_slurmaccount(acct):
...
@@ -52,14 +54,24 @@ def mk_slurmaccount(acct):
else
:
else
:
subprocess
.
call
([
"
{{ slurm_dir }}/bin/sacctmgr
"
,
"
-i
"
,
"
create
"
,
"
account
"
,
acct
])
subprocess
.
call
([
"
{{ slurm_dir }}/bin/sacctmgr
"
,
"
-i
"
,
"
create
"
,
"
account
"
,
acct
])
def
mk_slurmuser
(
user
,
acct
):
p
=
subprocess
.
Popen
([
"
{{ slurm_dir }}/bin/sacctmgr
"
,
"
--noheader
"
,
"
list
"
,
"
Association
"
,
"
user=%s
"
%
user
,
"
format=account
"
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
mk_slurmuser_batch
(
userbatch
,
acct
):
"""
Fetch a list of all accounts associated with users in userbatch, then add
those that aren
'
t a member of acct to acct using sacctmgr.
"""
p
=
subprocess
.
Popen
([
"
/opt/slurm-16.05.4/bin/sacctmgr
"
,
"
--noheader
"
,
"
list
"
,
"
Association
"
,
"
user=%s
"
%
userbatch
,
"
format=user,account
"
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
(
output
,
error
)
=
p
.
communicate
()
(
output
,
error
)
=
p
.
communicate
()
if
acct
in
output
.
splitlines
():
return
userdict
=
defaultdict
(
list
)
else
:
for
line
in
output
.
splitlines
():
subprocess
.
call
([
"
{{ slurm_dir }}/bin/sacctmgr
"
,
"
-i
"
,
"
create
"
,
"
user
"
,
user
,
"
account=%s
"
%
acct
,
"
DefaultAccount=%s
"
%
acct
])
(
u
,
a
)
=
line
.
split
()
userdict
[
u
].
append
(
a
)
newuserbatch
=
"
,
"
.
join
([
x
[
0
]
for
x
in
userdict
.
items
()
if
acct
not
in
x
[
1
]
])
if
newuserbatch
is
not
None
:
subprocess
.
call
([
"
/opt/slurm-16.05.4/bin/sacctmgr
"
,
"
-i
"
,
"
create
"
,
"
user
"
,
newuserbatch
,
"
account=%s
"
%
acct
,
"
DefaultAccount=%s
"
%
acct
])
s
=
ldapSearchConfig
()
s
=
ldapSearchConfig
()
...
@@ -81,11 +93,11 @@ for user in users:
...
@@ -81,11 +93,11 @@ for user in users:
userlist
=
[]
userlist
=
[]
i
=
i
+
1
i
=
i
+
1
userlist
.
append
(
users
[
user
].
entry
[
'
uid
'
][
0
])
userlist
.
append
(
users
[
user
].
entry
[
'
uid
'
][
0
])
usergrouplist
.
append
(
"
,
"
.
join
(
userlist
))
usergrouplist
.
append
(
"
,
"
.
join
(
userlist
))
for
usergroup
in
usergrouplist
:
for
usergroup
in
usergrouplist
:
try
:
try
:
mk_slurmuser_batch
(
usergroup
,
"
default
"
)
mk_slurmuser
(
usergroup
,
"
default
"
)
except
:
except
:
print
traceback
.
format_exc
()
print
traceback
.
format_exc
()
pass
pass
This diff is collapsed.
Click to expand it.
Chris Hines
@chines
mentioned in commit
118133b7
·
4 years ago
mentioned in commit
118133b7
mentioned in commit 118133b756a92a3af950f14b3c9cd233db45f961
Toggle commit list
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