Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
testbed
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Alan Marsh
testbed
Commits
385a03bd
Commit
385a03bd
authored
7 years ago
by
Mike Marsh
Browse files
Options
Downloads
Patches
Plain Diff
we have a star network!
This seemed to require less futzing than it did previously...
parent
808e4fa6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
start_testbed.py
+20
-10
20 additions, 10 deletions
start_testbed.py
stop_testbed.py
+2
-0
2 additions, 0 deletions
stop_testbed.py
with
22 additions
and
10 deletions
start_testbed.py
+
20
−
10
View file @
385a03bd
...
@@ -23,6 +23,7 @@ base_addr = reduce(
...
@@ -23,6 +23,7 @@ base_addr = reduce(
lambda
a
,
b
:
a
*
256
+
b
,
lambda
a
,
b
:
a
*
256
+
b
,
[
int
(
q
)
for
q
in
ntwk
[
'
subnet_addr
'
].
split
(
'
.
'
)
]
[
int
(
q
)
for
q
in
ntwk
[
'
subnet_addr
'
].
split
(
'
.
'
)
]
)
)
subnet
=
ntwk
[
'
subnet_addr
'
]
+
'
/
'
+
str
(
ntwk
[
'
subnet_len
'
])
nodelist
=
list
()
nodelist
=
list
()
...
@@ -33,6 +34,14 @@ def make_ip(i):
...
@@ -33,6 +34,14 @@ def make_ip(i):
masks
=
[
24
,
16
,
8
,
0
]
masks
=
[
24
,
16
,
8
,
0
]
return
'
.
'
.
join
([
str
((
addr
>>
mask
)
&
0xFF
)
for
mask
in
masks
])
return
'
.
'
.
join
([
str
((
addr
>>
mask
)
&
0xFF
)
for
mask
in
masks
])
def
make_route
(
f
,
net
,
fdev
):
subprocess
.
call
([
'
sudo
'
,
'
ip
'
,
'
netns
'
,
'
exec
'
,
f
[
'
name
'
],
'
ip
'
,
'
route
'
,
'
add
'
,
net
,
'
dev
'
,
fdev
,
'
proto
'
,
'
static
'
,
'
scope
'
,
'
global
'
,
'
src
'
,
f
[
'
addr
'
]
])
def
connect_nodes
(
node1
,
node2
):
def
connect_nodes
(
node1
,
node2
):
ctr1
=
nodelist
[
node1
]
ctr1
=
nodelist
[
node1
]
ctr2
=
nodelist
[
node2
]
ctr2
=
nodelist
[
node2
]
...
@@ -73,13 +82,7 @@ def connect_nodes(node1, node2):
...
@@ -73,13 +82,7 @@ def connect_nodes(node1, node2):
# Set initial routes.
# Set initial routes.
def
route_from_to
(
f
,
t
,
fdev
):
def
route_from_to
(
f
,
t
,
fdev
):
# $ctx ip route add $net dev $dev proto static scope global src $addr
make_route
(
f
,
t
[
'
addr
'
]
+
'
/32
'
,
fdev
)
subprocess
.
call
([
'
sudo
'
,
'
ip
'
,
'
netns
'
,
'
exec
'
,
f
[
'
name
'
],
'
ip
'
,
'
route
'
,
'
add
'
,
t
[
'
addr
'
]
+
'
/32
'
,
'
dev
'
,
fdev
,
'
proto
'
,
'
static
'
,
'
scope
'
,
'
global
'
,
'
src
'
,
f
[
'
addr
'
]
])
route_from_to
(
ctr1
,
ctr2
,
dev_1
)
route_from_to
(
ctr1
,
ctr2
,
dev_1
)
route_from_to
(
ctr2
,
ctr1
,
dev_2
)
route_from_to
(
ctr2
,
ctr1
,
dev_2
)
...
@@ -92,7 +95,12 @@ def make_mesh():
...
@@ -92,7 +95,12 @@ def make_mesh():
for
n2
in
range
(
n1
+
1
,
num_nodes
)
]
for
n2
in
range
(
n1
+
1
,
num_nodes
)
]
def
make_star
():
def
make_star
():
pass
global
nodelist
def
get_dev
(
i
):
return
'
bac0_{i}_0
'
.
format
(
i
=
i
)
num_nodes
=
len
(
nodelist
)
[
connect_nodes
(
0
,
n
)
for
n
in
range
(
1
,
num_nodes
)
]
[
make_route
(
n
,
subnet
,
get_dev
(
n
))
for
n
in
range
(
1
,
num_nodes
)
]
def
start_node
(
base_name
,
i
):
def
start_node
(
base_name
,
i
):
global
nodelist
global
nodelist
...
@@ -137,6 +145,8 @@ def start_node(base_name,i):
...
@@ -137,6 +145,8 @@ def start_node(base_name,i):
for
n
in
range
(
ntwk
[
'
num_nodes
'
]):
for
n
in
range
(
ntwk
[
'
num_nodes
'
]):
start_node
(
ntwk
[
'
name
'
],
n
)
start_node
(
ntwk
[
'
name
'
],
n
)
# XXX - need to check if we're a star or mesh network, and call the appropriate function
if
ntwk
[
'
topology
'
]
==
'
mesh
'
:
make_mesh
()
make_mesh
()
else
:
make_star
()
This diff is collapsed.
Click to expand it.
stop_testbed.py
+
2
−
0
View file @
385a03bd
...
@@ -26,6 +26,8 @@ def stop_node(name,i):
...
@@ -26,6 +26,8 @@ def stop_node(name,i):
retval
=
subprocess
.
call
(
command
)
retval
=
subprocess
.
call
(
command
)
command
=
[
'
docker
'
,
'
rm
'
,
ctr_name
]
command
=
[
'
docker
'
,
'
rm
'
,
ctr_name
]
retval
=
subprocess
.
call
(
command
)
retval
=
subprocess
.
call
(
command
)
command
=
[
'
sudo
'
,
'
rm
'
,
'
/var/run/netns/
'
+
ctr_name
]
retval
=
subprocess
.
call
(
command
)
for
i
in
range
(
ntwk
[
'
num_nodes
'
]):
for
i
in
range
(
ntwk
[
'
num_nodes
'
]):
stop_node
(
ntwk
[
'
name
'
],
i
)
stop_node
(
ntwk
[
'
name
'
],
i
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment