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
Boxiang Sun
slapos.core
Commits
574a1f79
Commit
574a1f79
authored
Jun 23, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SlapObject: extracted method _additional_buildout_parameters
parent
c66a7312
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
36 deletions
+39
-36
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+39
-36
No files found.
slapos/grid/SlapObject.py
View file @
574a1f79
...
...
@@ -154,6 +154,27 @@ class Software(object):
root_stat
.
st_gid
!=
path_stat
.
st_gid
):
os
.
chown
(
path
,
root_stat
.
st_uid
,
root_stat
.
st_gid
)
def
_additional_buildout_parameters
(
self
,
extends_cache
):
yield
'buildout:extends-cache=%s'
%
extends_cache
yield
'buildout:directory=%s'
%
self
.
software_path
if
(
self
.
signature_private_key_file
or
self
.
upload_cache_url
or
self
.
upload_dir_url
):
yield
'buildout:networkcache-section=networkcache'
for
networkcache_option
,
value
in
[
(
'signature-private-key-file'
,
self
.
signature_private_key_file
),
(
'upload-cache-url'
,
self
.
upload_cache_url
),
(
'upload-dir-url'
,
self
.
upload_dir_url
),
(
'shacache-cert-file'
,
self
.
shacache_cert_file
),
(
'shacache-key-file'
,
self
.
shacache_key_file
),
(
'shadir-cert-file'
,
self
.
shadir_cert_file
),
(
'shadir-key-file'
,
self
.
shadir_key_file
)
]:
if
value
:
yield
'networkcache:%s=%s'
%
(
networkcache_option
,
value
)
def
_install_from_buildout
(
self
):
""" Fetches buildout configuration from the server, run buildout with
it. If it fails, we notify the server.
...
...
@@ -169,53 +190,35 @@ class Software(object):
self
.
_set_ownership
(
extends_cache
)
try
:
buildout_parameter_list
=
[
'buildout:extends-cache=%s'
%
extends_cache
,
'buildout:directory=%s'
%
self
.
software_path
]
if
(
self
.
signature_private_key_file
or
self
.
upload_cache_url
or
self
.
upload_dir_url
):
buildout_parameter_list
.
append
(
'buildout:networkcache-section=networkcache'
)
for
buildout_option
,
value
in
[
(
'%ssignature-private-key-file=%s'
,
self
.
signature_private_key_file
),
(
'%supload-cache-url=%s'
,
self
.
upload_cache_url
),
(
'%supload-dir-url=%s'
,
self
.
upload_dir_url
),
(
'%sshacache-cert-file=%s'
,
self
.
shacache_cert_file
),
(
'%sshacache-key-file=%s'
,
self
.
shacache_key_file
),
(
'%sshadir-cert-file=%s'
,
self
.
shadir_cert_file
),
(
'%sshadir-key-file=%s'
,
self
.
shadir_key_file
)
]:
if
value
:
buildout_parameter_list
.
append
(
buildout_option
%
(
'networkcache:'
,
value
))
buildout_cfg
=
os
.
path
.
join
(
self
.
software_path
,
'buildout.cfg'
)
self
.
createProfileIfMissing
(
buildout_cfg
,
self
.
url
)
if
not
os
.
path
.
exists
(
buildout_cfg
):
self
.
_create_buildout_profile
(
buildout_cfg
,
self
.
url
)
additional_parameters
=
list
(
self
.
_additional_buildout_parameters
(
extends_cache
))
additional_parameters
.
extend
([
'-c'
,
buildout_cfg
])
buildout_parameter_list
.
extend
([
'-c'
,
buildout_cfg
])
utils
.
bootstrapBuildout
(
path
=
self
.
software_path
,
buildout
=
self
.
buildout
,
logger
=
self
.
logger
,
additional_buildout_parameter_list
=
buildout_parameter_list
)
additional_buildout_parameter_list
=
additional_parameters
)
utils
.
launchBuildout
(
path
=
self
.
software_path
,
buildout_binary
=
os
.
path
.
join
(
self
.
software_path
,
'bin'
,
'buildout'
),
logger
=
self
.
logger
,
additional_buildout_parameter_list
=
buildout_parameter_list
)
additional_buildout_parameter_list
=
additional_parameters
)
finally
:
shutil
.
rmtree
(
extends_cache
)
def
createProfileIfMissing
(
self
,
buildout_cfg
,
url
):
if
not
os
.
path
.
exists
(
buildout_cfg
):
with
open
(
buildout_cfg
,
'wb'
)
as
fout
:
fout
.
write
(
textwrap
.
dedent
(
"""
\
# Created by slapgrid. extends {url}
# but you can change it for development purposes.
[buildout]
extends = {url}
"""
.
format
(
url
=
url
)))
self
.
_set_ownership
(
buildout_cfg
)
def
_create_buildout_profile
(
self
,
buildout_cfg
,
url
):
with
open
(
buildout_cfg
,
'wb'
)
as
fout
:
fout
.
write
(
textwrap
.
dedent
(
"""
\
# Created by slapgrid. extends {url}
# but you can change it for development purposes.
[buildout]
extends = {url}
"""
.
format
(
url
=
url
)))
self
.
_set_ownership
(
buildout_cfg
)
def
uploadSoftwareRelease
(
self
,
tarpath
):
"""
...
...
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