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
Jérome Perrin
slapos.core
Commits
9b599b47
Commit
9b599b47
authored
Oct 20, 2021
by
Jérome Perrin
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testcase: use partition's python for getPromisePluginParameterDict
parent
151be649
Pipeline
#17931
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+4
-15
slapos/grid/utils.py
slapos/grid/utils.py
+14
-0
slapos/testing/utils.py
slapos/testing/utils.py
+7
-1
No files found.
slapos/grid/SlapObject.py
View file @
9b599b47
...
@@ -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,7 +473,7 @@ class Partition(object):
...
@@ -472,7 +473,7 @@ class Partition(object):
self
.
instance_min_free_space
=
instance_min_free_space
self
.
instance_min_free_space
=
instance_min_free_space
self
.
instance_python
=
self
.
getInstalledPythonExecutable
(
)
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
def
check_free_space
(
self
):
def
check_free_space
(
self
):
...
@@ -707,7 +708,7 @@ class Partition(object):
...
@@ -707,7 +708,7 @@ class Partition(object):
debug
=
self
.
buildout_debug
)
debug
=
self
.
buildout_debug
)
self
.
generateSupervisorConfigurationFile
()
self
.
generateSupervisorConfigurationFile
()
self
.
createRetentionLockDelay
()
self
.
createRetentionLockDelay
()
self
.
instance_python
=
self
.
getInstalledPythonExecutable
(
)
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
def
generateSupervisorConfiguration
(
self
):
def
generateSupervisorConfiguration
(
self
):
"""
"""
...
@@ -1046,15 +1047,3 @@ class Partition(object):
...
@@ -1046,15 +1047,3 @@ class Partition(object):
return
float
(
date_file_path
.
read
())
return
float
(
date_file_path
.
read
())
else
:
else
:
return
None
return
None
def
getInstalledPythonExecutable
(
self
):
"""
Return the path of the python executable installed for the SR of this instance.
"""
try
:
with
open
(
os
.
path
.
join
(
self
.
software_path
,
'bin'
,
'buildout'
))
as
f
:
shebang
=
f
.
readline
()
except
OSError
:
return
if
shebang
.
startswith
(
'#!'
):
return
shebang
[
2
:].
split
(
None
,
1
)[
0
]
slapos/grid/utils.py
View file @
9b599b47
...
@@ -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
=
[]
...
...
slapos/testing/utils.py
View file @
9b599b47
...
@@ -41,6 +41,8 @@ from contextlib import closing
...
@@ -41,6 +41,8 @@ from contextlib import closing
from
six.moves
import
BaseHTTPServer
from
six.moves
import
BaseHTTPServer
from
six.moves
import
urllib_parse
from
six.moves
import
urllib_parse
from
..grid.utils
import
getPythonExecutableFromSoftwarePath
try
:
try
:
import
typing
import
typing
if
typing
.
TYPE_CHECKING
:
if
typing
.
TYPE_CHECKING
:
...
@@ -77,8 +79,12 @@ def getPromisePluginParameterDict(filepath):
...
@@ -77,8 +79,12 @@ def getPromisePluginParameterDict(filepath):
This allow to check that monitoring plugin are using a proper config.
This allow to check that monitoring plugin are using a proper config.
"""
"""
executable
=
getPythonExecutableFromSoftwarePath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
filepath
))),
'software_release'
))
extra_config_dict_json
=
subprocess
.
check_output
([
extra_config_dict_json
=
subprocess
.
check_output
([
sys
.
executable
,
executable
,
"-c"
,
"-c"
,
"""
"""
import json, sys
import json, sys
...
...
Jérome Perrin
@jerome
mentioned in merge request
nexedi/slapos.core!329 (merged)
·
Oct 20, 2021
mentioned in merge request
nexedi/slapos.core!329 (merged)
mentioned in merge request nexedi/slapos.core!329
Toggle commit list
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