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
Xiaowu Zhang
slapos.core
Commits
f9529c25
Commit
f9529c25
authored
Sep 19, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix socket constants.
10 was used for socket.AF_INET6, but it is 30. So don't hardcode values.
parent
ba93d902
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+11
-10
No files found.
slapos/tests/slapformat.py
View file @
f9529c25
...
@@ -3,6 +3,7 @@ import slapos.format
...
@@ -3,6 +3,7 @@ import slapos.format
import
unittest
import
unittest
import
netaddr
import
netaddr
import
socket
# for mocking
# for mocking
import
grp
import
grp
...
@@ -45,12 +46,12 @@ class FakeCallAndRead:
...
@@ -45,12 +46,12 @@ class FakeCallAndRead:
netmask
=
netaddr
.
strategy
.
ipv4
.
int_to_str
(
netmask
=
netaddr
.
strategy
.
ipv4
.
int_to_str
(
netaddr
.
strategy
.
ipv4
.
prefix_to_netmask
[
int
(
ip
.
split
(
'/'
)[
1
])])
netaddr
.
strategy
.
ipv4
.
prefix_to_netmask
[
int
(
ip
.
split
(
'/'
)[
1
])])
ip
=
ip
.
split
(
'/'
)[
0
]
ip
=
ip
.
split
(
'/'
)[
0
]
INTERFACE_DICT
[
interface
][
2
].
append
({
'addr'
:
ip
,
'netmask'
:
netmask
})
INTERFACE_DICT
[
interface
][
socket
.
AF_INET
].
append
({
'addr'
:
ip
,
'netmask'
:
netmask
})
else
:
else
:
netmask
=
netaddr
.
strategy
.
ipv6
.
int_to_str
(
netmask
=
netaddr
.
strategy
.
ipv6
.
int_to_str
(
netaddr
.
strategy
.
ipv6
.
prefix_to_netmask
[
int
(
ip
.
split
(
'/'
)[
1
])])
netaddr
.
strategy
.
ipv6
.
prefix_to_netmask
[
int
(
ip
.
split
(
'/'
)[
1
])])
ip
=
ip
.
split
(
'/'
)[
0
]
ip
=
ip
.
split
(
'/'
)[
0
]
INTERFACE_DICT
[
interface
][
10
].
append
({
'addr'
:
ip
,
'netmask'
:
netmask
})
INTERFACE_DICT
[
interface
][
socket
.
AF_INET6
].
append
({
'addr'
:
ip
,
'netmask'
:
netmask
})
# stabilise by mangling ip to just ip string
# stabilise by mangling ip to just ip string
argument_list
[
3
]
=
'ip/%s'
%
netmask
argument_list
[
3
]
=
'ip/%s'
%
netmask
elif
argument_list
[:
3
]
==
[
'ip'
,
'addr'
,
'list'
]:
elif
argument_list
[:
3
]
==
[
'ip'
,
'addr'
,
'list'
]:
...
@@ -293,9 +294,9 @@ class TestComputer(SlapformatMixin):
...
@@ -293,9 +294,9 @@ class TestComputer(SlapformatMixin):
computer
.
partition_list
=
[
partition
]
computer
.
partition_list
=
[
partition
]
global
INTERFACE_DICT
global
INTERFACE_DICT
INTERFACE_DICT
[
'bridge'
]
=
{
INTERFACE_DICT
[
'bridge'
]
=
{
2
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
socket
.
AF_INET
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
'netmask'
:
'255.255.255.0'
}],
'netmask'
:
'255.255.255.0'
}],
10
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
socket
.
AF_INET6
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
}
}
computer
.
construct
()
computer
.
construct
()
...
@@ -339,9 +340,9 @@ class TestComputer(SlapformatMixin):
...
@@ -339,9 +340,9 @@ class TestComputer(SlapformatMixin):
computer
.
partition_list
=
[
partition
]
computer
.
partition_list
=
[
partition
]
global
INTERFACE_DICT
global
INTERFACE_DICT
INTERFACE_DICT
[
'bridge'
]
=
{
INTERFACE_DICT
[
'bridge'
]
=
{
2
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
socket
.
AF_INET
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
'netmask'
:
'255.255.255.0'
}],
'netmask'
:
'255.255.255.0'
}],
10
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
socket
.
AF_INET6
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
}
}
computer
.
construct
(
alter_user
=
False
)
computer
.
construct
(
alter_user
=
False
)
...
@@ -378,9 +379,9 @@ class TestComputer(SlapformatMixin):
...
@@ -378,9 +379,9 @@ class TestComputer(SlapformatMixin):
computer
.
partition_list
=
[
partition
]
computer
.
partition_list
=
[
partition
]
global
INTERFACE_DICT
global
INTERFACE_DICT
INTERFACE_DICT
[
'bridge'
]
=
{
INTERFACE_DICT
[
'bridge'
]
=
{
2
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
socket
.
AF_INET
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
'netmask'
:
'255.255.255.0'
}],
'netmask'
:
'255.255.255.0'
}],
10
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
socket
.
AF_INET6
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
}
}
computer
.
construct
(
alter_network
=
False
)
computer
.
construct
(
alter_network
=
False
)
...
@@ -418,9 +419,9 @@ class TestComputer(SlapformatMixin):
...
@@ -418,9 +419,9 @@ class TestComputer(SlapformatMixin):
computer
.
partition_list
=
[
partition
]
computer
.
partition_list
=
[
partition
]
global
INTERFACE_DICT
global
INTERFACE_DICT
INTERFACE_DICT
[
'bridge'
]
=
{
INTERFACE_DICT
[
'bridge'
]
=
{
2
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
socket
.
AF_INET
:
[{
'addr'
:
'192.168.242.77'
,
'broadcast'
:
'127.0.0.1'
,
'netmask'
:
'255.255.255.0'
}],
'netmask'
:
'255.255.255.0'
}],
10
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
socket
.
AF_INET6
:
[{
'addr'
:
'2a01:e35:2e27::e59c'
,
'netmask'
:
'ffff:ffff:ffff:ffff::'
}]
}
}
computer
.
construct
(
alter_network
=
False
,
alter_user
=
False
)
computer
.
construct
(
alter_network
=
False
,
alter_user
=
False
)
...
...
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