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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
fad6938c
Commit
fad6938c
authored
Sep 02, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapgrid: Map instances to their installed python
parent
0cfa831d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+5
-1
slapos/grid/utils.py
slapos/grid/utils.py
+14
-0
No files found.
slapos/grid/SlapObject.py
View file @
fad6938c
...
@@ -45,7 +45,8 @@ from six.moves.configparser import ConfigParser
...
@@ -45,7 +45,8 @@ from six.moves.configparser import ConfigParser
from
supervisor
import
xmlrpc
from
supervisor
import
xmlrpc
from
slapos.grid.utils
import
(
md5digest
,
getCleanEnvironment
,
from
slapos.grid.utils
import
(
md5digest
,
getCleanEnvironment
,
SlapPopen
,
dropPrivileges
,
updateFile
)
SlapPopen
,
dropPrivileges
,
updateFile
,
getPythonExecutableFromSoftwarePath
)
from
slapos.grid
import
utils
# for methods that could be mocked, access them through the module
from
slapos.grid
import
utils
# for methods that could be mocked, access them through the module
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
NotFoundError
from
slapos.grid.svcbackend
import
getSupervisorRPC
from
slapos.grid.svcbackend
import
getSupervisorRPC
...
@@ -472,6 +473,8 @@ class Partition(object):
...
@@ -472,6 +473,8 @@ class Partition(object):
self
.
instance_min_free_space
=
instance_min_free_space
self
.
instance_min_free_space
=
instance_min_free_space
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
def
check_free_space
(
self
):
def
check_free_space
(
self
):
required
=
self
.
instance_min_free_space
or
0
required
=
self
.
instance_min_free_space
or
0
...
@@ -705,6 +708,7 @@ class Partition(object):
...
@@ -705,6 +708,7 @@ class Partition(object):
debug
=
self
.
buildout_debug
)
debug
=
self
.
buildout_debug
)
self
.
generateSupervisorConfigurationFile
()
self
.
generateSupervisorConfigurationFile
()
self
.
createRetentionLockDelay
()
self
.
createRetentionLockDelay
()
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
def
generateSupervisorConfiguration
(
self
):
def
generateSupervisorConfiguration
(
self
):
"""
"""
...
...
slapos/grid/utils.py
View file @
fad6938c
...
@@ -164,6 +164,20 @@ def md5digest(url):
...
@@ -164,6 +164,20 @@ def md5digest(url):
return
hashlib
.
md5
(
url
.
encode
(
'utf-8'
)).
hexdigest
()
return
hashlib
.
md5
(
url
.
encode
(
'utf-8'
)).
hexdigest
()
def
getPythonExecutableFromSoftwarePath
(
software_path
):
"""
Return the path of the python executable installed for the software release
installed as `software_path`.
"""
try
:
with
open
(
os
.
path
.
join
(
software_path
,
'bin'
,
'buildout'
))
as
f
:
shebang
=
f
.
readline
()
except
OSError
:
return
if
shebang
.
startswith
(
'#!'
):
return
shebang
[
2
:].
split
(
None
,
1
)[
0
]
def
getCleanEnvironment
(
logger
,
home_path
=
'/tmp'
):
def
getCleanEnvironment
(
logger
,
home_path
=
'/tmp'
):
changed_env
=
{}
changed_env
=
{}
removed_env
=
[]
removed_env
=
[]
...
...
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