Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Titouan Soulard
slapos.core
Commits
6522e6f7
Commit
6522e6f7
authored
Jun 01, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'no_bridge'
Conflicts: slapos/grid/SlapObject.py
parents
d41f6522
0c37c785
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
19 deletions
+24
-19
CHANGES.txt
CHANGES.txt
+3
-1
slapos/format.py
slapos/format.py
+21
-18
No files found.
CHANGES.txt
View file @
6522e6f7
...
@@ -4,7 +4,9 @@ Changes
...
@@ -4,7 +4,9 @@ Changes
0.26 (Unreleased)
0.26 (Unreleased)
-----------------
-----------------
* No change yet.
* slapformat: no_bridge option becomes 'not create_tap'.
create_tap is true by default. So a bridge is used and tap will be created by
default. [Cedric de Saint Martin]
0.25 (2012-05-16)
0.25 (2012-05-16)
-----------------
-----------------
...
...
slapos/format.py
View file @
6522e6f7
...
@@ -179,7 +179,7 @@ class Computer(object):
...
@@ -179,7 +179,7 @@ class Computer(object):
def
__getinitargs__
(
self
):
def
__getinitargs__
(
self
):
return
(
self
.
reference
,
self
.
interface
)
return
(
self
.
reference
,
self
.
interface
)
def
getAddress
(
self
):
def
getAddress
(
self
,
allow_tap
=
False
):
"""
"""
Return a list of the interface address not attributed to any partition, (which
Return a list of the interface address not attributed to any partition, (which
are therefore free for the computer itself).
are therefore free for the computer itself).
...
@@ -201,11 +201,15 @@ class Computer(object):
...
@@ -201,11 +201,15 @@ class Computer(object):
if
address_dict
[
'addr'
]
not
in
computer_partition_address_list
:
if
address_dict
[
'addr'
]
not
in
computer_partition_address_list
:
return
address_dict
return
address_dict
# all addresses on interface are for partition, so lets add new one
if
allow_tap
:
computer_tap
=
Tap
(
'compdummy'
)
# all addresses on interface are for partition, so lets add new one
computer_tap
.
createWithOwner
(
User
(
'root'
),
attach_to_tap
=
True
)
computer_tap
=
Tap
(
'compdummy'
)
self
.
interface
.
addTap
(
computer_tap
)
computer_tap
.
createWithOwner
(
User
(
'root'
),
attach_to_tap
=
True
)
return
self
.
interface
.
addAddr
()
self
.
interface
.
addTap
(
computer_tap
)
return
self
.
interface
.
addAddr
()
# Can't find address
return
False
def
send
(
self
,
config
):
def
send
(
self
,
config
):
"""
"""
...
@@ -851,10 +855,6 @@ class Parser(OptionParser):
...
@@ -851,10 +855,6 @@ class Parser(OptionParser):
help
=
"Don't actually do anything."
,
help
=
"Don't actually do anything."
,
default
=
False
,
default
=
False
,
action
=
"store_true"
),
action
=
"store_true"
),
Option
(
"-b"
,
"--no_bridge"
,
help
=
"Don't use bridge but use real interface like eth0."
,
default
=
False
,
action
=
"store_true"
),
Option
(
"-v"
,
"--verbose"
,
Option
(
"-v"
,
"--verbose"
,
default
=
False
,
default
=
False
,
action
=
"store_true"
,
action
=
"store_true"
,
...
@@ -979,7 +979,7 @@ def run(config):
...
@@ -979,7 +979,7 @@ def run(config):
computer
.
instance_root
=
config
.
instance_root
computer
.
instance_root
=
config
.
instance_root
computer
.
software_root
=
config
.
software_root
computer
.
software_root
=
config
.
software_root
config
.
logger
.
info
(
'Updating computer'
)
config
.
logger
.
info
(
'Updating computer'
)
address
=
computer
.
getAddress
()
address
=
computer
.
getAddress
(
config
.
create_tap
)
computer
.
address
=
address
[
'addr'
]
computer
.
address
=
address
[
'addr'
]
computer
.
netmask
=
address
[
'netmask'
]
computer
.
netmask
=
address
[
'netmask'
]
...
@@ -1006,7 +1006,7 @@ def run(config):
...
@@ -1006,7 +1006,7 @@ def run(config):
computer_definition
.
write
(
open
(
filepath
,
'w'
))
computer_definition
.
write
(
open
(
filepath
,
'w'
))
config
.
logger
.
info
(
'Stored computer definition in %r'
%
filepath
)
config
.
logger
.
info
(
'Stored computer definition in %r'
%
filepath
)
computer
.
construct
(
alter_user
=
config
.
alter_user
,
computer
.
construct
(
alter_user
=
config
.
alter_user
,
alter_network
=
config
.
alter_network
,
create_tap
=
not
config
.
no_bridge
)
alter_network
=
config
.
alter_network
,
create_tap
=
config
.
create_tap
)
# Dumping and sending to the erp5 the current configuration
# Dumping and sending to the erp5 the current configuration
if
not
config
.
dry_run
:
if
not
config
.
dry_run
:
...
@@ -1020,6 +1020,7 @@ class Config(object):
...
@@ -1020,6 +1020,7 @@ class Config(object):
cert_file
=
None
cert_file
=
None
alter_network
=
None
alter_network
=
None
alter_user
=
None
alter_user
=
None
create_tap
=
None
computer_xml
=
None
computer_xml
=
None
logger
=
None
logger
=
None
log_file
=
None
log_file
=
None
...
@@ -1067,7 +1068,7 @@ class Config(object):
...
@@ -1067,7 +1068,7 @@ class Config(object):
'tap_base_name'
,
'ipv4_local_network'
,
'ipv6_interface'
]:
'tap_base_name'
,
'ipv4_local_network'
,
'ipv6_interface'
]:
if
getattr
(
self
,
parameter
,
None
)
is
None
:
if
getattr
(
self
,
parameter
,
None
)
is
None
:
setattr
(
self
,
parameter
,
None
)
setattr
(
self
,
parameter
,
None
)
# Backward compatibility
# Backward compatibility
if
not
getattr
(
self
,
"interface_name"
,
None
)
\
if
not
getattr
(
self
,
"interface_name"
,
None
)
\
and
getattr
(
self
,
"bridge_name"
,
None
):
and
getattr
(
self
,
"bridge_name"
,
None
):
...
@@ -1080,6 +1081,8 @@ class Config(object):
...
@@ -1080,6 +1081,8 @@ class Config(object):
self
.
alter_user
=
'True'
self
.
alter_user
=
'True'
if
self
.
software_user
is
None
:
if
self
.
software_user
is
None
:
self
.
software_user
=
'slapsoft'
self
.
software_user
=
'slapsoft'
if
self
.
create_tap
is
None
:
self
.
create_tap
=
True
# set up logging
# set up logging
self
.
logger
=
logging
.
getLogger
(
"slapformat"
)
self
.
logger
=
logging
.
getLogger
(
"slapformat"
)
...
@@ -1088,7 +1091,7 @@ class Config(object):
...
@@ -1088,7 +1091,7 @@ class Config(object):
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
# Convert strings to booleans
# Convert strings to booleans
for
o
in
[
'alter_network'
,
'alter_user'
,
'
no_bridge
'
]:
for
o
in
[
'alter_network'
,
'alter_user'
,
'
create_tap
'
]:
attr
=
getattr
(
self
,
o
)
attr
=
getattr
(
self
,
o
)
if
isinstance
(
attr
,
str
):
if
isinstance
(
attr
,
str
):
if
attr
.
lower
()
==
'true'
:
if
attr
.
lower
()
==
'true'
:
...
@@ -1105,12 +1108,12 @@ class Config(object):
...
@@ -1105,12 +1108,12 @@ class Config(object):
if
not
self
.
dry_run
:
if
not
self
.
dry_run
:
if
self
.
alter_user
:
if
self
.
alter_user
:
self
.
checkRequiredBinary
([
'groupadd'
,
'useradd'
,
'usermod'
])
self
.
checkRequiredBinary
([
'groupadd'
,
'useradd'
,
'usermod'
])
if
not
self
.
no_bridge
:
if
self
.
create_tap
:
self
.
checkRequiredBinary
([
'tunctl'
])
self
.
checkRequiredBinary
([
'tunctl'
])
if
self
.
alter_network
:
if
self
.
alter_network
:
self
.
checkRequiredBinary
([
'ip'
])
self
.
checkRequiredBinary
([
'ip'
])
# Required, even for dry run
# Required, even for dry run
if
self
.
alter_network
and
not
self
.
no_bridge
:
if
self
.
alter_network
and
self
.
create_tap
:
self
.
checkRequiredBinary
([
'brctl'
])
self
.
checkRequiredBinary
([
'brctl'
])
# Check if root is needed
# Check if root is needed
...
@@ -1149,8 +1152,8 @@ class Config(object):
...
@@ -1149,8 +1152,8 @@ class Config(object):
self
.
logger
.
debug
(
"Verbose mode enabled."
)
self
.
logger
.
debug
(
"Verbose mode enabled."
)
if
self
.
dry_run
:
if
self
.
dry_run
:
self
.
logger
.
info
(
"Dry-run mode enabled."
)
self
.
logger
.
info
(
"Dry-run mode enabled."
)
if
self
.
no_bridge
:
if
self
.
create_tap
:
self
.
logger
.
info
(
"
No-bridge
mode enabled."
)
self
.
logger
.
info
(
"
Tap
mode enabled."
)
# Calculate path once
# Calculate path once
self
.
computer_xml
=
os
.
path
.
abspath
(
self
.
computer_xml
)
self
.
computer_xml
=
os
.
path
.
abspath
(
self
.
computer_xml
)
...
...
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