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
Boxiang Sun
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,
...
@@ -20,7 +20,10 @@ setup(name=name,
author
=
'VIFIB'
,
author
=
'VIFIB'
,
packages
=
[
'slapprepare'
],
packages
=
[
'slapprepare'
],
include_package_data
=
True
,
include_package_data
=
True
,
install_requires
=
[
'slapos.libnetworkcache'
,],
install_requires
=
[
'slapos.libnetworkcache'
,
'iniparse'
,
],
zip_safe
=
False
,
zip_safe
=
False
,
entry_points
=
{
entry_points
=
{
'console_scripts'
:
[
'console_scripts'
:
[
...
...
slapprepare/slapprepare/slapprepare.py
View file @
2ed1c39e
...
@@ -29,13 +29,14 @@
...
@@ -29,13 +29,14 @@
from
optparse
import
OptionParser
,
Option
from
optparse
import
OptionParser
,
Option
import
ConfigParser
,
os
import
ConfigParser
,
os
import
pkg_resources
import
pkg_resources
import
re
import
socket
import
socket
from
subprocess
import
call
as
subprocessCall
from
subprocess
import
call
as
subprocessCall
import
sys
import
sys
import
urllib2
import
urllib2
from
pwd
import
getpwnam
from
pwd
import
getpwnam
import
iniparse
SLAPOS_MARK
=
'# Added by SlapOS
\
n
'
SLAPOS_MARK
=
'# Added by SlapOS
\
n
'
...
@@ -162,16 +163,16 @@ def get_computer_name(slapos_configuration):
...
@@ -162,16 +163,16 @@ def get_computer_name(slapos_configuration):
return
socket
.
gethostname
()
return
socket
.
gethostname
()
def
enable_bridge
(
slapos_configuration
):
def
setup_bridge
(
slapos_configuration
,
create_tap
):
# we don't use ConfigParser here, as it would remove comments
slapos_cfg_path
=
os
.
path
.
join
(
slapos_configuration
,
'slapos.cfg'
)
slapos_cfg_path
=
os
.
path
.
join
(
slapos_configuration
,
'slapos.cfg'
)
lines
=
[]
for
line
in
open
(
slapos_cfg_path
):
# using iniparse instead of ConfigParser, will retain the comments
if
re
.
match
(
'^create_tap *='
,
line
):
slapos_cfg
=
iniparse
.
RawConfigParser
()
line
=
'create_tap = true
\
n
'
slapos_cfg
.
read
(
slapos_cfg_path
)
lines
.
append
(
line
)
slapos_cfg
.
set
(
'slapformat'
,
'create_tap'
,
'true'
if
create_tap
else
'false'
)
with
open
(
slapos_cfg_path
,
'w'
)
as
fout
:
with
open
(
slapos_cfg_path
,
'w'
)
as
fout
:
fout
.
writelines
(
lines
)
slapos_cfg
.
write
(
fout
)
# Function to get ssh key
# Function to get ssh key
...
@@ -448,11 +449,15 @@ class Config:
...
@@ -448,11 +449,15 @@ class Config:
self
.
partition_amount
=
raw_input
(
"""Number of SlapOS partitions for this computer? Default is 20 :"""
)
self
.
partition_amount
=
raw_input
(
"""Number of SlapOS partitions for this computer? Default is 20 :"""
)
if
self
.
partition_amount
==
''
:
if
self
.
partition_amount
==
''
:
self
.
partition_amount
=
'20'
self
.
partition_amount
=
'20'
self
.
virtual
=
get_yes_no
(
"Is this a virtual Machine?"
,
False
)
self
.
virtual
=
get_yes_no
(
"Is this a virtual Machine?"
,
False
)
if
not
self
.
virtual
:
if
not
self
.
virtual
:
self
.
one_disk
=
not
get_yes_no
(
"Do you want to use SlapOS with a second disk?"
,
True
)
self
.
one_disk
=
not
get_yes_no
(
"Do you want to use SlapOS with a second disk?"
,
True
)
else
:
else
:
self
.
one_disk
=
True
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_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
)
self
.
force_slapcontainer
=
get_yes_no
(
"Do you want to force the use lxc on this computer?"
,
False
)
if
self
.
force_vpn
:
if
self
.
force_vpn
:
...
@@ -504,8 +509,11 @@ def prepare_from_scratch(config):
...
@@ -504,8 +509,11 @@ def prepare_from_scratch(config):
,
'--interface-name'
,
'br0'
,
'--interface-name'
,
'br0'
,
'--ipv6-interface'
,
config
.
ipv6_interface
,
'--ipv6-interface'
,
config
.
ipv6_interface
,
'--partition-number'
,
config
.
partition_amount
])
,
'--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
(
computer_id
=
get_computer_name
(
os
.
path
.
join
(
'/'
,
slapos_configuration
,
'slapos.cfg'
))
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