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
Tristan Cavelier
slapos.toolbox
Commits
d2df81f3
Commit
d2df81f3
authored
Jul 30, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to image use
parent
ce197340
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
48 deletions
+11
-48
slapos/container/prepare.py
slapos/container/prepare.py
+11
-48
No files found.
slapos/container/prepare.py
View file @
d2df81f3
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
import
ConfigParser
import
ConfigParser
import
os
import
os
import
subprocess
import
subprocess
import
shutil
import
lockfile
import
lockfile
...
@@ -32,9 +31,8 @@ def main(sr_directory, partition_list, bridge_name):
...
@@ -32,9 +31,8 @@ def main(sr_directory, partition_list, bridge_name):
'status'
)
'status'
)
if
requested_status
==
'started'
:
if
requested_status
==
'started'
:
if
not
created
(
partition_path
,
slapcontainer_conf
):
create
(
sr_directory
,
partition_path
,
create
(
sr_directory
,
partition_path
,
slapcontainer_conf
,
bridge_name
)
slapcontainer_conf
,
bridge_name
)
if
status
(
sr_directory
,
partition_path
)
==
'stopped'
:
if
status
(
sr_directory
,
partition_path
)
==
'stopped'
:
start
(
sr_directory
,
partition_path
)
start
(
sr_directory
,
partition_path
)
else
:
else
:
...
@@ -67,47 +65,10 @@ def stop(sr_directory, partition_path):
...
@@ -67,47 +65,10 @@ def stop(sr_directory, partition_path):
def
created
(
partition_path
,
conf
):
return
os
.
path
.
exists
(
conf
.
get
(
'rootfs'
,
'directory'
))
and
\
os
.
path
.
exists
(
conf
.
get
(
'config'
,
'file'
))
def
extract_rootfs
(
partition_path
,
conf
):
tmp_dir
=
conf
.
get
(
'rootfs'
,
'tmp'
)
if
os
.
path
.
exists
(
tmp_dir
):
shutil
.
rmtree
(
tmp_dir
)
os
.
mkdir
(
tmp_dir
)
call
([
conf
.
get
(
'tar'
,
'binary'
),
'-xf'
,
conf
.
get
(
'tar'
,
'archive'
),
'-C'
,
tmp_dir
],
{
'PATH'
:
'%s:%s'
%
(
os
.
environ
,
conf
.
get
(
'tar'
,
'path'
))})
lst_tmp_dir
=
os
.
listdir
(
tmp_dir
)
if
len
(
lst_tmp_dir
)
>
1
:
rootfs
=
tmp_dir
else
:
rootfs
=
os
.
path
.
join
(
tmp_dir
,
lst_tmp_dir
[
0
])
shutil
.
move
(
rootfs
,
conf
.
get
(
'rootfs'
,
'directory'
))
if
os
.
path
.
exists
(
tmp_dir
):
shutil
.
rmtree
(
tmp_dir
)
def
create
(
sr_directory
,
partition_path
,
conf
,
bridge_name
):
def
create
(
sr_directory
,
partition_path
,
conf
,
bridge_name
):
tmp_dir
=
conf
.
get
(
'rootfs'
,
'tmp'
)
lxc_filename
=
conf
.
get
(
'config'
,
'file'
)
rootfs_dir
=
conf
.
get
(
'rootfs'
,
'directory'
)
if
os
.
path
.
exists
(
tmp_dir
):
shutil
.
rmtree
(
tmp_dir
)
if
os
.
path
.
exists
(
rootfs_dir
):
shutil
.
rmtree
(
rootfs_dir
)
extract_rootfs
(
partition_path
,
conf
)
lxc_filename
=
os
.
path
.
join
(
partition_path
,
'config'
)
lxc
=
LXCConfig
()
lxc
=
LXCConfig
()
lxc
.
utsname
=
os
.
path
.
basename
(
partition_path
)
lxc
.
utsname
=
conf
.
get
(
'requested'
,
'name'
)
lxc
.
network
.
type
=
'veth'
lxc
.
network
.
type
=
'veth'
lxc
.
network
.
link
=
bridge_name
lxc
.
network
.
link
=
bridge_name
lxc
.
network
.
veth
.
pair
=
'lxc%s'
%
conf
.
get
(
'network'
,
'interface'
)
lxc
.
network
.
veth
.
pair
=
'lxc%s'
%
conf
.
get
(
'network'
,
'interface'
)
...
@@ -130,11 +91,13 @@ def create(sr_directory, partition_path, conf, bridge_name):
...
@@ -130,11 +91,13 @@ def create(sr_directory, partition_path, conf, bridge_name):
'c 5:2 rwm'
,
'c 5:2 rwm'
,
'c 254:0 rwm'
,
'c 254:0 rwm'
,
]
]
lxc
.
mount
.
entry
=
[
# XXX : This is a relic of previous code, even if it is versionned
'proc %s proc nodev,noexec,nosuid 0 0'
%
os
.
path
.
join
(
rootfs_dir
,
'proc'
),
# this could be usefull in future
'sysfs %s sysfs defaults 0 0'
%
os
.
path
.
join
(
rootfs_dir
,
'sys'
),
# lxc.mount.entry = [
]
# 'proc %s proc nodev,noexec,nosuid 0 0' % os.path.join(rootfs_dir, 'proc'),
lxc
.
rootfs
=
rootfs_dir
# 'sysfs %s sysfs defaults 0 0' % os.path.join(rootfs_dir, 'sys'),
# ]
lxc
.
rootfs
=
conf
.
get
(
'rootfs'
,
'image'
)
with
open
(
lxc_filename
,
'w'
)
as
lxc_file
:
with
open
(
lxc_filename
,
'w'
)
as
lxc_file
:
lxc_file
.
write
(
str
(
lxc
))
lxc_file
.
write
(
str
(
lxc
))
...
...
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