Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos.toolbox
Commits
87c12a30
Commit
87c12a30
authored
Jul 31, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some logs
parent
20a04993
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
slapos/container/prepare.py
slapos/container/prepare.py
+14
-5
No files found.
slapos/container/prepare.py
View file @
87c12a30
...
...
@@ -3,6 +3,7 @@
import
ConfigParser
import
os
import
subprocess
import
logging
import
lockfile
...
...
@@ -17,6 +18,8 @@ class SlapContainerError(Exception):
def
main
(
sr_directory
,
partition_list
,
bridge_name
):
logger
=
logging
.
getLogger
()
to_start
=
set
()
for
partition_path
in
partition_list
:
slapcontainer_filename
=
os
.
path
.
join
(
partition_path
,
...
...
@@ -51,25 +54,30 @@ def main(sr_directory, partition_list, bridge_name):
finally
:
lock
.
release
()
logger
.
debug
(
'Container to start %s.'
,
', '
.
join
(
to_start
))
try
:
active_containers
=
set
(
call
(
[
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-ls'
),
'--active'
]
).
split
(
'
\
n
'
))
logger
.
debug
(
'Active containers are %s.'
,
', '
.
join
(
active_containers
))
except
SlapContainerError
:
active_containers
=
set
()
to_stop
=
active_containers
-
to_start
if
to_stop
:
logger
.
debug
(
'Stopping containers %s.'
,
', '
.
join
(
to_stop
))
for
container
in
to_stop
:
try
:
logger
.
info
(
'Stopping container %s.'
,
container
)
call
(
[
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-stop'
),
'-n'
,
container
]
)
except
SlapContainerError
:
pass
# TODO : put some log
logger
.
fatal
(
'Impossible to stop %s.'
,
container
)
...
...
@@ -142,8 +150,9 @@ def status(sr_directory, partition_path, conf):
def
call
(
command_line
,
override_environ
=
{}):
# for debug :
# print ' '.join(command_line)
logger
=
logging
.
getLogger
()
logger
.
debug
(
'Call %s'
,
' '
.
join
(
command_line
))
environ
=
dict
(
os
.
environ
)
environ
.
update
(
override_environ
)
process
=
subprocess
.
Popen
(
command_line
,
stdin
=
subprocess
.
PIPE
,
...
...
@@ -152,9 +161,9 @@ def call(command_line, override_environ={}):
process
.
stdin
.
close
()
if
process
.
wait
()
!=
0
:
logger
.
debug
(
'Failed'
)
raise
SlapContainerError
(
"Subprocess call failed"
)
out
=
process
.
stdout
.
read
()
# for debug :
# print out
logger
.
debug
(
'Output : %s.'
,
out
)
return
out
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