Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
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
Lisa Casino
slapos.package
Commits
2ed1c39e
Commit
2ed1c39e
authored
Mar 28, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ask if bridge is needed, disable create_tap if bridge is not needed
parent
c19d4b77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
slapprepare/setup.py
slapprepare/setup.py
+4
-1
slapprepare/slapprepare/slapprepare.py
slapprepare/slapprepare/slapprepare.py
+19
-11
No files found.
slapprepare/setup.py
View file @
2ed1c39e
...
...
@@ -20,7 +20,10 @@ setup(name=name,
author
=
'VIFIB'
,
packages
=
[
'slapprepare'
],
include_package_data
=
True
,
install_requires
=
[
'slapos.libnetworkcache'
,],
install_requires
=
[
'slapos.libnetworkcache'
,
'iniparse'
,
],
zip_safe
=
False
,
entry_points
=
{
'console_scripts'
:
[
...
...
slapprepare/slapprepare/slapprepare.py
View file @
2ed1c39e
...
...
@@ -29,13 +29,14 @@
from
optparse
import
OptionParser
,
Option
import
ConfigParser
,
os
import
pkg_resources
import
re
import
socket
from
subprocess
import
call
as
subprocessCall
import
sys
import
urllib2
from
pwd
import
getpwnam
import
iniparse
SLAPOS_MARK
=
'# Added by SlapOS
\
n
'
...
...
@@ -162,16 +163,16 @@ def get_computer_name(slapos_configuration):
return
socket
.
gethostname
()
def
enable_bridge
(
slapos_configuration
):
# we don't use ConfigParser here, as it would remove comments
def
setup_bridge
(
slapos_configuration
,
create_tap
):
slapos_cfg_path
=
os
.
path
.
join
(
slapos_configuration
,
'slapos.cfg'
)
lines
=
[]
for
line
in
open
(
slapos_cfg_path
):
if
re
.
match
(
'^create_tap *='
,
line
):
line
=
'create_tap = true
\
n
'
lines
.
append
(
line
)
# using iniparse instead of ConfigParser, will retain the comments
slapos_cfg
=
iniparse
.
RawConfigParser
()
slapos_cfg
.
read
(
slapos_cfg_path
)
slapos_cfg
.
set
(
'slapformat'
,
'create_tap'
,
'true'
if
create_tap
else
'false'
)
with
open
(
slapos_cfg_path
,
'w'
)
as
fout
:
fout
.
writelines
(
lines
)
slapos_cfg
.
write
(
fout
)
# Function to get ssh key
...
...
@@ -448,11 +449,15 @@ class Config:
self
.
partition_amount
=
raw_input
(
"""Number of SlapOS partitions for this computer? Default is 20 :"""
)
if
self
.
partition_amount
==
''
:
self
.
partition_amount
=
'20'
self
.
virtual
=
get_yes_no
(
"Is this a virtual Machine?"
,
False
)
if
not
self
.
virtual
:
self
.
one_disk
=
not
get_yes_no
(
"Do you want to use SlapOS with a second disk?"
,
True
)
else
:
self
.
one_disk
=
True
self
.
need_bridge
=
get_yes_no
(
"Do you to setup the network to allow virtual machines inside this node?"
,
False
)
self
.
force_vpn
=
get_yes_no
(
"Do you want to use vpn to provide ipv6?"
,
True
)
self
.
force_slapcontainer
=
get_yes_no
(
"Do you want to force the use lxc on this computer?"
,
False
)
if
self
.
force_vpn
:
...
...
@@ -504,8 +509,11 @@ def prepare_from_scratch(config):
,
'--interface-name'
,
'br0'
,
'--ipv6-interface'
,
config
.
ipv6_interface
,
'--partition-number'
,
config
.
partition_amount
])
# Prepare for bridge
enable_bridge
(
slapos_configuration
)
if
config
.
need_bridge
:
setup_bridge
(
slapos_configuration
,
True
)
else
:
setup_bridge
(
slapos_configuration
,
False
)
computer_id
=
get_computer_name
(
os
.
path
.
join
(
'/'
,
slapos_configuration
,
'slapos.cfg'
))
...
...
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