Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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
nexedi
nemu3
Commits
7906d070
Commit
7906d070
authored
Jun 08, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more api
parent
b14c2a3c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
src/netns/__init__.py
src/netns/__init__.py
+12
-5
t/test_interfaces.py
t/test_interfaces.py
+4
-3
t/test_routing.py
t/test_routing.py
+10
-1
No files found.
src/netns/__init__.py
View file @
7906d070
...
...
@@ -18,23 +18,30 @@ class Node(object):
def
__init__
(
self
):
self
.
pid
=
0
def
add_if
(
self
,
mac_address
=
None
,
mtu
=
None
):
return
Interface
()
return
Interface
(
mac_address
,
mtu
)
def
add_route
(
self
,
prefix
,
prefix_len
,
nexthop
=
None
,
interface
=
None
):
assert
nexthop
or
interface
def
add_default_route
(
self
,
nexthop
,
interface
=
None
):
return
self
.
add_route
(
'0.0.0.0'
,
0
,
nexthop
,
interface
)
def
start_process
(
self
,
args
):
return
Process
()
def
run_process
(
self
,
args
):
return
(
""
,
""
)
def
get_routes
(
self
):
return
set
()
class
Link
(
object
):
def
connect
(
self
,
iface
):
pass
class
Interface
(
object
):
def
__init__
(
self
):
def
__init__
(
self
,
mac_address
=
None
,
mtu
=
None
):
self
.
name
=
None
self
.
mac_address
=
None
def
add_v4_address
(
self
,
addr
,
prefix_len
,
broadcast
=
None
):
self
.
mac_address
=
mac_address
self
.
mtu
=
mtu
def
add_v4_address
(
self
,
address
,
prefix_len
,
broadcast
=
None
):
pass
def
add_v6_address
(
self
,
addr
,
prefix_len
):
def
add_v6_address
(
self
,
addr
ess
,
prefix_len
):
pass
class
Process
(
object
):
...
...
t/test_interfaces.py
View file @
7906d070
...
...
@@ -147,10 +147,11 @@ class TestInterfaces(unittest.TestCase):
def test_interface_addresses(self):
node0 = netns.Node()
if0 = node0.add_if()
if0.add_v4_address(addr = '
10.0
.
0.1
', prefix_len = 24,
if0.add_v4_address(addr
ess
= '
10.0
.
0.1
', prefix_len = 24,
broadcast = '
10.0
.
0.255
')
if0.add_v4_address(addr = '
10.0
.
2.1
', prefix_len = 26)
if0.add_v6_address(addr = '
fe80
::
222
:
19
ff
:
fe22
:
615
d
', prefix_len = 64)
if0.add_v4_address(address = '
10.0
.
2.1
', prefix_len = 26)
if0.add_v6_address(address = '
fe80
::
222
:
19
ff
:
fe22
:
615
d
',
prefix_len = 64)
devs = get_devs_netns(node0)
self.assertTrue( {
...
...
t/test_routing.py
View file @
7906d070
...
...
@@ -6,7 +6,16 @@ import unittest
class
TestRouting
(
unittest
.
TestCase
):
def
test_routing
(
self
):
pass
node
=
netns
.
Node
()
if0
=
node
.
add_if
()
if0
.
add_v4_address
(
'10.0.0.1'
,
24
)
node
.
add_default_route
(
nexthop
=
'10.0.0.2'
)
node
.
add_route
(
prefix
=
'10.1.0.0'
,
prefix_len
=
16
,
nexthop
=
'10.0.0.3'
)
node
.
add_route
(
prefix
=
'11.1.0.1'
,
prefix_len
=
32
,
interface
=
if0
)
routes
=
node
.
get_routes
()
# FIXME:...
if
__name__
==
'__main__'
:
unittest
.
main
()
...
...
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