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
Léo-Paul Géneau
slapos.core
Commits
87cd8299
Commit
87cd8299
authored
Sep 09, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format: Add safety check for speed hack.
Also put out the speed hack from the core code.
parent
9f174ada
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
slapos/format.py
slapos/format.py
+29
-21
No files found.
slapos/format.py
View file @
87cd8299
...
...
@@ -54,7 +54,6 @@ import xml_marshaller.xml_marshaller
from
slapos.util
import
chownDirectory
from
slapos.util
import
mkdir_p
from
slapos.util
import
is_string_true
import
slapos.slap
as
slap
...
...
@@ -367,6 +366,33 @@ class Computer(object):
return
computer
def
_speedHackAddAllOldIpsToInterface
(
self
):
"""
Speed hack:
Blindly add all IPs from existing configuration, just to speed up actual
computer configuration later on.
"""
# XXX-TODO: only add an address if it doesn't already exist.
if
self
.
ipv6_interface
:
interface_name
=
self
.
ipv6_interface
elif
self
.
interface
:
interface_name
=
self
.
interface
.
name
else
:
return
for
partition
in
self
.
partition_list
:
try
:
for
address
in
partition
.
address_list
:
try
:
netmask
=
netmaskToPrefixIPv6
(
address
[
'netmask'
])
except
:
continue
callAndRead
([
'ip'
,
'addr'
,
'add'
,
'%s/%s'
%
(
address
[
'addr'
],
netmask
),
'dev'
,
interface_name
])
except
ValueError
:
pass
def
construct
(
self
,
alter_user
=
True
,
alter_network
=
True
,
create_tap
=
True
):
"""
Construct the computer object as it is.
...
...
@@ -389,26 +415,8 @@ class Computer(object):
chownDirectory
(
slapsoft
.
path
,
slapsoft_pw
.
pw_uid
,
slapsoft_pw
.
pw_gid
)
os
.
chmod
(
self
.
software_root
,
0o755
)
# Speed hack:
# Blindly add all IPs from existing configuration, just to speed up actual
# computer configuration later on.
# XXX-TODO: only add an address if it doesn't already exist.
if
self
.
ipv6_interface
:
interface_name
=
self
.
ipv6_interface
else
:
interface_name
=
self
.
interface
.
name
for
partition
in
self
.
partition_list
:
try
:
for
address
in
partition
.
address_list
:
try
:
netmask
=
netmaskToPrefixIPv6
(
address
[
'netmask'
])
except
:
continue
callAndRead
([
'ip'
,
'addr'
,
'add'
,
'%s/%s'
%
(
address
[
'addr'
],
netmask
),
'dev'
,
interface_name
])
except
ValueError
:
pass
if
alter_network
:
self
.
_speedHackAddAllOldIpsToInterface
()
try
:
for
partition_index
,
partition
in
enumerate
(
self
.
partition_list
):
...
...
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