Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Thomas Gambier
slapos
Commits
0177c913
Commit
0177c913
authored
Mar 03, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get tap network information if exits for partition
Set tap network information in a dict if they are defined
parent
3491677b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
slapos/recipe/slapconfiguration.py
slapos/recipe/slapconfiguration.py
+37
-0
slapos/recipe/softwaretype.py
slapos/recipe/softwaretype.py
+25
-0
No files found.
slapos/recipe/slapconfiguration.py
View file @
0177c913
...
...
@@ -134,6 +134,14 @@ class Recipe(object):
v6_add
=
ipv6_set
.
add
tap_set
=
set
()
tap_add
=
tap_set
.
add
route_gw_set
=
set
()
route_gw_add
=
route_gw_set
.
add
route_mask_set
=
set
()
route_mask_add
=
route_mask_set
.
add
route_ipv4_set
=
set
()
route_v4_add
=
route_ipv4_set
.
add
route_network_set
=
set
()
route_net_add
=
route_network_set
.
add
for
tap
,
ip
in
parameter_dict
.
pop
(
'ip_list'
):
tap_add
(
tap
)
if
valid_ipv4
(
ip
):
...
...
@@ -141,6 +149,21 @@ class Recipe(object):
elif
valid_ipv6
(
ip
):
v6_add
(
ip
)
# XXX: emit warning on unknown address type ?
if
'full_ip_list'
in
parameter_dict
:
for
item
in
parameter_dict
.
pop
(
'full_ip_list'
):
if
len
(
item
)
==
5
:
tap
,
ip
,
gw
,
netmask
,
network
=
item
if
tap
.
startswith
(
'route_'
):
if
valid_ipv4
(
gw
):
route_gw_add
(
gw
)
if
valid_ipv4
(
netmask
):
route_mask_add
(
netmask
)
if
valid_ipv4
(
ip
):
route_v4_add
(
ip
)
if
valid_ipv4
(
network
):
route_net_add
(
network
)
options
[
'ipv4'
]
=
ipv4_set
options
[
'ipv6'
]
=
ipv6_set
...
...
@@ -149,6 +172,20 @@ class Recipe(object):
options
[
'ipv4-random'
]
=
list
(
ipv4_set
)[
0
].
encode
(
'UTF-8'
)
if
ipv6_set
:
options
[
'ipv6-random'
]
=
list
(
ipv6_set
)[
0
].
encode
(
'UTF-8'
)
if
route_ipv4_set
:
options
[
'tap-ipv4'
]
=
list
(
route_ipv4_set
)[
0
].
encode
(
'UTF-8'
)
options
[
'tap-network-information-dict'
]
=
dict
(
ipv4
=
route_ipv4_set
,
netmask
=
route_mask_set
,
gateway
=
route_gw_set
,
network
=
route_network_set
)
else
:
options
[
'tap-network-information-dict'
]
=
{}
if
route_gw_set
:
options
[
'tap-gateway'
]
=
list
(
route_gw_set
)[
0
].
encode
(
'UTF-8'
)
if
route_mask_set
:
options
[
'tap-netmask'
]
=
list
(
route_mask_set
)[
0
].
encode
(
'UTF-8'
)
if
route_network_set
:
options
[
'tap-network'
]
=
list
(
route_network_set
)[
0
].
encode
(
'UTF-8'
)
options
[
'tap'
]
=
tap_set
return
self
.
_expandParameterDict
(
options
,
parameter_dict
)
...
...
slapos/recipe/softwaretype.py
View file @
0177c913
...
...
@@ -54,6 +54,18 @@ class Recipe:
return
ip
raise
AttributeError
def
_getTapIpAddressList
(
self
,
test_method
):
"""Internal helper method to fetch full ip address assigned for tap"""
if
not
'full_ip_list'
in
self
.
parameter_dict
:
return
()
for
item
in
self
.
parameter_dict
[
'full_ip_list'
]:
if
len
(
item
)
==
5
:
tap
,
ip
,
gw
,
mask
,
net
=
item
if
tap
.
startswith
(
'route_'
)
and
test_method
(
ip
)
and
\
test_method
(
gw
)
and
test_method
(
mask
):
return
(
ip
,
gw
,
mask
,
net
)
return
()
def
getLocalIPv4Address
(
self
):
"""Returns local IPv4 address available on partition"""
# XXX: Lack checking for locality of address
...
...
@@ -64,6 +76,11 @@ class Recipe:
# XXX: Lack checking for globality of address
return
self
.
_getIpAddress
(
netaddr
.
valid_ipv6
)
def
getLocalTapIPv4AddressList
(
self
):
"""Returns global IPv6 address available for tap interface"""
# XXX: Lack checking for locality of address
return
self
.
_getTapIpAddressList
(
netaddr
.
valid_ipv4
)
def
getNetworkInterface
(
self
):
"""Returns the network interface available on partition"""
if
not
'ip_list'
in
self
.
parameter_dict
:
...
...
@@ -128,6 +145,14 @@ class Recipe:
self
.
getGlobalIPv6Address
())
buildout
.
set
(
'slap-network-information'
,
'network-interface'
,
self
.
getNetworkInterface
())
tap_ip_list
=
self
.
getLocalTapIPv4AddressList
()
tap_ipv4
=
tap_gateway
=
tap_netmask
=
tap_network
=
''
if
tap_ip_list
:
tap_ipv4
,
tap_gateway
,
tap_netmask
,
tap_network
=
tap_ip_list
buildout
.
set
(
'slap-network-information'
,
'tap-ipv4'
,
tap_ipv4
)
buildout
.
set
(
'slap-network-information'
,
'tap-gateway'
,
tap_gateway
)
buildout
.
set
(
'slap-network-information'
,
'tap-netmask'
,
tap_netmask
)
buildout
.
set
(
'slap-network-information'
,
'tap-network'
,
tap_network
)
# Copy/paste slap_connection
buildout
.
add_section
(
'slap-connection'
)
...
...
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