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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Klaus Wölfel
slapos.toolbox
Commits
079c8333
Commit
079c8333
authored
Jul 31, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement stopping/destroy of partitions
parent
ad426dc5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
slapos/container/prepare.py
slapos/container/prepare.py
+24
-6
No files found.
slapos/container/prepare.py
View file @
079c8333
...
@@ -17,6 +17,7 @@ class SlapContainerError(Exception):
...
@@ -17,6 +17,7 @@ class SlapContainerError(Exception):
def
main
(
sr_directory
,
partition_list
,
bridge_name
):
def
main
(
sr_directory
,
partition_list
,
bridge_name
):
started_containers
=
set
()
for
partition_path
in
partition_list
:
for
partition_path
in
partition_list
:
slapcontainer_filename
=
os
.
path
.
join
(
partition_path
,
slapcontainer_filename
=
os
.
path
.
join
(
partition_path
,
'.slapcontainer'
)
'.slapcontainer'
)
...
@@ -37,6 +38,9 @@ def main(sr_directory, partition_list, bridge_name):
...
@@ -37,6 +38,9 @@ def main(sr_directory, partition_list, bridge_name):
slapcontainer_conf
)
==
'stopped'
:
slapcontainer_conf
)
==
'stopped'
:
start
(
sr_directory
,
partition_path
,
start
(
sr_directory
,
partition_path
,
slapcontainer_conf
)
slapcontainer_conf
)
started_containers
.
add
(
slapcontainer_conf
.
get
(
'requested'
,
'name'
)
)
else
:
else
:
if
status
(
sr_directory
,
partition_path
,
if
status
(
sr_directory
,
partition_path
,
slapcontainer_conf
)
==
'started'
:
slapcontainer_conf
)
==
'started'
:
...
@@ -47,6 +51,26 @@ def main(sr_directory, partition_list, bridge_name):
...
@@ -47,6 +51,26 @@ def main(sr_directory, partition_list, bridge_name):
finally
:
finally
:
lock
.
release
()
lock
.
release
()
try
:
active_containers
=
set
(
call
(
[
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-ls'
),
'--active'
]
).
split
(
'
\
n
'
))
except
SlapContainerError
:
active_containers
=
set
()
to_stop
=
active_containers
-
started_containers
for
container
in
to_stop
:
try
:
call
(
[
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-stop'
),
'-n'
,
container
]
)
except
SlapContainerError
:
pass
# TODO : put some log
def
start
(
sr_directory
,
partition_path
,
conf
):
def
start
(
sr_directory
,
partition_path
,
conf
):
...
@@ -107,12 +131,6 @@ def create(sr_directory, partition_path, conf, bridge_name):
...
@@ -107,12 +131,6 @@ def create(sr_directory, partition_path, conf, bridge_name):
def
destroy
(
partition_path
):
# TODO: Destroy container
pass
def
status
(
sr_directory
,
partition_path
,
conf
):
def
status
(
sr_directory
,
partition_path
,
conf
):
lxc_info
=
call
([
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-info'
),
lxc_info
=
call
([
os
.
path
.
join
(
sr_directory
,
'parts/lxc/bin/lxc-info'
),
'-n'
,
conf
.
get
(
'requested'
,
'name'
)])
'-n'
,
conf
.
get
(
'requested'
,
'name'
)])
...
...
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