Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
a220d056
Commit
a220d056
authored
Jun 14, 2018
by
Guillaume Hervier
Committed by
Rafael Monnerat
Jul 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapgrid: Add methods to SlapObject.Partition for more control
on generated supervisord config
parent
2fe8f2c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
22 deletions
+40
-22
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+40
-22
No files found.
slapos/grid/SlapObject.py
View file @
a220d056
...
...
@@ -438,34 +438,52 @@ class Partition(object):
gid
=
stat_info
.
st_gid
return
(
uid
,
gid
)
def
addProgramToGroup
(
self
,
partition_id
,
program_id
,
name
,
command
,
as_user
=
True
):
if
as_user
:
uid
,
gid
=
self
.
getUserGroupId
()
else
:
uid
,
gid
=
0
,
0
self
.
partition_supervisor_configuration
+=
'
\
n
'
+
\
PROGRAM_PARTITION_TEMPLATE
%
{
'program_id'
:
'{}_{}'
.
format
(
partition_id
,
program_id
),
'program_directory'
:
self
.
instance_path
,
'program_command'
:
command
,
'program_name'
:
name
,
'instance_path'
:
self
.
instance_path
,
'user_id'
:
uid
,
'group_id'
:
gid
,
# As supervisord has no environment to inherit, setup a minimalistic one
'HOME'
:
pwd
.
getpwuid
(
uid
).
pw_dir
,
'USER'
:
pwd
.
getpwuid
(
uid
).
pw_name
,
}
def
addCustomGroup
(
self
,
group_suffix
,
partition_id
,
program_list
):
group_partition_template
=
pkg_resources
.
resource_stream
(
__name__
,
'templates/group_partition_supervisord.conf.in'
).
read
()
group_id
=
'{}-{}'
.
format
(
partition_id
,
group_suffix
)
self
.
supervisor_configuration_group
+=
group_partition_template
%
{
'instance_id'
:
group_id
,
'program_list'
:
','
.
join
([
'{}_{}'
.
format
(
group_id
,
program_id
)
for
program_id
in
program_list
]),
}
return
group_id
def
addServiceToGroup
(
self
,
partition_id
,
runner_list
,
path
,
extension
=
''
):
uid
,
gid
=
self
.
getUserGroupId
()
for
runner
in
runner_list
:
self
.
partition_supervisor_configuration
+=
'
\
n
'
+
\
PROGRAM_PARTITION_TEMPLATE
%
{
'program_id'
:
'_'
.
join
([
partition_id
,
runner
]),
'program_directory'
:
self
.
instance_path
,
'program_command'
:
os
.
path
.
join
(
path
,
runner
),
'program_name'
:
runner
+
extension
,
'instance_path'
:
self
.
instance_path
,
'user_id'
:
uid
,
'group_id'
:
gid
,
# As supervisord has no environment to inherit, setup a minimalistic one
'HOME'
:
pwd
.
getpwuid
(
uid
).
pw_dir
,
'USER'
:
pwd
.
getpwuid
(
uid
).
pw_name
,
}
program_id
=
runner
program_name
=
runner
+
extension
program_command
=
os
.
path
.
join
(
path
,
runner
)
self
.
addProgramToGroup
(
partition_id
,
program_id
,
program_name
,
program_command
)
def
addServiceToCustomGroup
(
self
,
group_suffix
,
partition_id
,
runner_list
,
path
,
extension
=
''
):
"""Add new services to supervisord that belong to specific group"""
group_partition_template
=
pkg_resources
.
resource_stream
(
__name__
,
'templates/group_partition_supervisord.conf.in'
).
read
()
group_id
=
'-'
.
join
([
partition_id
,
group_suffix
])
self
.
supervisor_configuration_group
+=
group_partition_template
%
{
'instance_id'
:
group_id
,
'program_list'
:
','
.
join
([
'_'
.
join
([
group_id
,
runner
])
for
runner
in
runner_list
])
}
group_id
=
self
.
addCustomGroup
(
group_suffix
,
partition_id
,
runner_list
)
return
self
.
addServiceToGroup
(
group_id
,
runner_list
,
path
,
extension
)
def
updateSymlink
(
self
,
sr_symlink
,
software_path
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment