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
Titouan Soulard
slapos.core
Commits
a84d4b79
Commit
a84d4b79
authored
Jun 27, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SlapObject: cleaner buildout_cfg creation
parent
be2b2ac7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+20
-17
No files found.
slapos/grid/SlapObject.py
View file @
a84d4b79
...
...
@@ -408,23 +408,25 @@ class Partition(object):
'Cannot deploy instance.'
%
self
.
software_release_url
)
# Generate buildout instance profile from template in Software Release
template_location
=
os
.
path
.
join
(
self
.
software_path
,
'instance.cfg'
)
if
not
os
.
path
.
exists
(
template_location
):
instance_cfg
=
os
.
path
.
join
(
self
.
software_path
,
'instance.cfg'
)
if
not
os
.
path
.
exists
(
instance_cfg
):
# Backward compatibility: "instance.cfg" file was named "template.cfg".
if
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
software_path
,
'template.cfg'
)):
template_location
=
os
.
path
.
join
(
self
.
software_path
,
'template.cfg'
)
instance_cfg
=
os
.
path
.
join
(
self
.
software_path
,
'template.cfg'
)
else
:
# No template: Software Release is either inconsistent or not correctly installed.
# XXX What should it raise?
raise
IOError
(
'Software Release %s is not correctly installed.
\
n
Missing file: %s'
%
(
self
.
software_release_url
,
template_location
))
config_location
=
os
.
path
.
join
(
self
.
instance_path
,
'buildout.cfg'
)
self
.
logger
.
debug
(
"Copying %r to %r"
%
(
template_location
,
config_location
))
shutil
.
copy
(
template_location
,
config_location
)
self
.
software_release_url
,
instance_cfg
))
buildout_cfg
=
os
.
path
.
join
(
self
.
instance_path
,
'buildout.cfg'
)
self
.
logger
.
debug
(
"Copying %r to %r"
%
(
instance_cfg
,
buildout_cfg
))
with
open
(
buildout_cfg
,
'w'
)
as
fout
:
fout
.
write
(
open
(
instance_cfg
).
read
())
fout
.
write
(
'
\
n
\
n
'
)
# fill generated buildout with additional information
buildout_text
=
open
(
config_location
).
read
()
buildout_text
+=
'
\
n
\
n
'
+
pkg_resources
.
resource_string
(
__name__
,
fout
.
write
(
pkg_resources
.
resource_string
(
__name__
,
'templates/buildout-tail.cfg.in'
)
%
{
'computer_id'
:
self
.
computer_id
,
'partition_id'
:
self
.
partition_id
,
...
...
@@ -432,9 +434,9 @@ class Partition(object):
'software_release_url'
:
self
.
software_release_url
,
'key_file'
:
self
.
key_file
,
'cert_file'
:
self
.
cert_file
,
}
o
pen
(
config_location
,
'w'
).
write
(
buildout_text
)
os
.
chmod
(
config_location
,
0o640
)
})
o
s
.
chmod
(
buildout_cfg
,
0o640
)
# Try to find the best possible buildout:
# *) if software_root/bin/bootstrap exists use this one to bootstrap
# locally
...
...
@@ -447,7 +449,7 @@ class Partition(object):
else
:
bootstrap_candidate_list
=
[]
uid
,
gid
=
self
.
getUserGroupId
()
os
.
chown
(
config_location
,
-
1
,
int
(
gid
))
os
.
chown
(
buildout_cfg
,
-
1
,
int
(
gid
))
if
len
(
bootstrap_candidate_list
)
==
0
:
buildout_binary
=
os
.
path
.
join
(
self
.
software_path
,
'bin'
,
'buildout'
)
self
.
logger
.
warning
(
"Falling back to default buildout %r"
%
...
...
@@ -490,7 +492,7 @@ class Partition(object):
[
'buildout:bin-directory=%s'
%
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
)])
buildout_binary
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'buildout'
)
# Launches buildout
utils
.
launchBuildout
(
path
=
self
.
instance_path
,
buildout_binary
=
buildout_binary
,
logger
=
self
.
logger
)
...
...
@@ -588,6 +590,7 @@ class Partition(object):
destroy_binary
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'destroy'
)
if
os
.
path
.
exists
(
destroy_binary
):
self
.
_pre_destroy
(
destroy_binary
)
# Manually cleans what remains
try
:
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
...
...
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