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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.core
Commits
24508b1a
Commit
24508b1a
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dict-kw cleanup
parent
65e35e46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
48 deletions
+47
-48
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+25
-24
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+16
-19
slapos/grid/utils.py
slapos/grid/utils.py
+6
-5
No files found.
slapos/grid/SlapObject.py
View file @
24508b1a
...
...
@@ -314,18 +314,18 @@ class Partition(object):
'templates/program_partition_supervisord.conf.in'
).
read
()
for
runner
in
runner_list
:
self
.
partition_supervisor_configuration
+=
'
\
n
'
+
\
program_partition_template
%
dict
(
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_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
,
}
def
updateSymlink
(
self
,
sr_symlink
,
software_path
):
if
os
.
path
.
lexists
(
sr_symlink
):
...
...
@@ -376,14 +376,14 @@ class Partition(object):
# fill generated buildout with additional information
buildout_text
=
open
(
config_location
).
read
()
buildout_text
+=
'
\
n
\
n
'
+
pkg_resources
.
resource_string
(
__name__
,
'templates/buildout-tail.cfg.in'
)
%
dict
(
computer_id
=
self
.
computer_id
,
partition_id
=
self
.
partition_id
,
server_url
=
self
.
server_url
,
software_release_url
=
self
.
software_release_url
,
key_file
=
self
.
key_file
,
cert_file
=
self
.
cert_file
)
'templates/buildout-tail.cfg.in'
)
%
{
'computer_id'
:
self
.
computer_id
,
'partition_id'
:
self
.
partition_id
,
'server_url'
:
self
.
server_url
,
'software_release_url'
:
self
.
software_release_url
,
'key_file'
:
self
.
key_file
,
'cert_file'
:
self
.
cert_file
,
}
open
(
config_location
,
'w'
).
write
(
buildout_text
)
os
.
chmod
(
config_location
,
0o640
)
# Try to find the best possible buildout:
...
...
@@ -460,10 +460,11 @@ class Partition(object):
partition_id
=
self
.
computer_partition
.
getId
()
group_partition_template
=
pkg_resources
.
resource_stream
(
__name__
,
'templates/group_partition_supervisord.conf.in'
).
read
()
self
.
partition_supervisor_configuration
=
group_partition_template
%
dict
(
instance_id
=
partition_id
,
program_list
=
','
.
join
([
'_'
.
join
([
partition_id
,
runner
])
for
runner
in
runner_list
+
service_list
]))
self
.
partition_supervisor_configuration
=
group_partition_template
%
{
'instance_id'
:
partition_id
,
'program_list'
:
','
.
join
([
'_'
.
join
([
partition_id
,
runner
])
for
runner
in
runner_list
+
service_list
])
}
# Same method to add to service and run
self
.
addServiceToGroup
(
partition_id
,
runner_list
,
self
.
run_path
)
self
.
addServiceToGroup
(
partition_id
,
service_list
,
self
.
service_path
,
...
...
slapos/grid/slapgrid.py
View file @
24508b1a
...
...
@@ -516,20 +516,17 @@ class Slapgrid(object):
# Creates supervisord configuration
updateFile
(
self
.
supervisord_configuration_path
,
pkg_resources
.
resource_stream
(
__name__
,
'templates/supervisord.conf.in'
).
read
()
%
dict
(
supervisord_configuration_directory
=
\
self
.
supervisord_configuration_directory
,
supervisord_socket
=
os
.
path
.
abspath
(
self
.
supervisord_socket
),
supervisord_loglevel
=
'info'
,
supervisord_logfile
=
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'log'
,
'supervisord.log'
)),
supervisord_logfile_maxbytes
=
'50MB'
,
supervisord_nodaemon
=
'false'
,
supervisord_pidfile
=
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)),
supervisord_logfile_backups
=
'10'
,
watchdog_command
=
self
.
getWatchdogLine
(),
))
'templates/supervisord.conf.in'
).
read
()
%
{
'supervisord_configuration_directory'
:
self
.
supervisord_configuration_directory
,
'supervisord_socket'
:
os
.
path
.
abspath
(
self
.
supervisord_socket
),
'supervisord_loglevel'
:
'info'
,
'supervisord_logfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'log'
,
'supervisord.log'
)),
'supervisord_logfile_maxbytes'
:
'50MB'
,
'supervisord_nodaemon'
:
'false'
,
'supervisord_pidfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)),
'supervisord_logfile_backups'
:
'10'
,
'watchdog_command'
:
self
.
getWatchdogLine
(),
})
except
(
WrongPermissionError
,
PathDoesNotExistError
)
as
error
:
raise
error
...
...
@@ -668,14 +665,14 @@ class Slapgrid(object):
promise
=
os
.
path
.
basename
(
command
[
0
])
self
.
logger
.
info
(
"Checking promise %r."
,
promise
)
kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
)
process_handler
=
subprocess
.
Popen
(
command
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
cwd
,
env
=
None
if
sys
.
platform
==
'cygwin'
else
{},
**
kw
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
)
process_handler
.
stdin
.
flush
()
process_handler
.
stdin
.
close
()
process_handler
.
stdin
=
None
...
...
@@ -1129,12 +1126,12 @@ class Slapgrid(object):
#stat sys call to get statistics informations
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
),
env
=
None
,
**
kw
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
if
process_handler
.
returncode
is
None
:
process_handler
.
kill
()
if
process_handler
.
returncode
!=
0
:
...
...
slapos/grid/utils.py
View file @
24508b1a
...
...
@@ -278,9 +278,8 @@ def bootstrapBuildout(path, buildout=None,
path
))
kw
.
update
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
**
kw
)
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
logger
.
error
(
message
)
...
...
@@ -321,8 +320,10 @@ def launchBuildout(path, buildout_binary,
path
))
kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
logger
.
error
(
message
)
...
...
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