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
66ab304d
Commit
66ab304d
authored
7 years ago
by
Mike Marsh
Browse files
Options
Downloads
Patches
Plain Diff
putting together testbed
parent
a9ecefd2
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
example.yml
+4
-2
4 additions, 2 deletions
example.yml
start_testbed.py
+43
-0
43 additions, 0 deletions
start_testbed.py
stop_testbed.py
+32
-0
32 additions, 0 deletions
stop_testbed.py
tear_down.py
+0
-49
0 additions, 49 deletions
tear_down.py
with
79 additions
and
51 deletions
example.yml
+
4
−
2
View file @
66ab304d
---
# Modify these to suit your needs.
image
:
"
gizmonic.cs.umd.edu:8080/baseline"
image_cmd
:
"
tail
-f
/etc/issue"
image_cmd
:
"
/usr/bin/
tail
-f
/etc/issue"
# Here's how you define the network you want.
# The topology can be "mesh" or "star". The
# latter will designate the first node as the
# center of the star.
# center of the star. Containers will be named
# <name>0 through <name><num-nodes - 1>.
network
:
name
:
test
num_nodes
:
4
topology
:
mesh
subnet_addr
:
186.192.0.0
...
...
This diff is collapsed.
Click to expand it.
start_testbed.py
0 → 100755
+
43
−
0
View file @
66ab304d
#! /usr/bin/env python
import
subprocess
import
yaml
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
()
parser
.
add_argument
(
'
-f
'
,
'
--file
'
,
dest
=
'
file
'
,
default
=
'
example.yml
'
,
help
=
'
YML file containing the testbed configuration
'
)
args
=
parser
.
parse_args
()
with
open
(
args
.
file
)
as
cfile
:
conf
=
yaml
.
load
(
cfile
)
retval
=
subprocess
.
call
([
'
docker
'
,
'
pull
'
,
conf
[
'
image
'
]])
def
make_mesh
():
pass
def
make_star
():
pass
ntwk
=
conf
[
'
network
'
]
def
start_node
(
name
,
i
):
ctr_name
=
'
{name}{i}
'
.
format
(
name
=
name
,
i
=
i
)
command
=
[
'
docker
'
,
'
run
'
,
'
-d
'
,
'
--name
'
,
ctr_name
,
conf
[
'
image
'
]
]
command
.
extend
(
conf
[
'
image_cmd
'
].
split
())
retval
=
subprocess
.
call
(
command
)
for
i
in
range
(
ntwk
[
'
num_nodes
'
]):
start_node
(
ntwk
[
'
name
'
],
i
)
This diff is collapsed.
Click to expand it.
stop_testbed.py
0 → 100755
+
32
−
0
View file @
66ab304d
#! /usr/bin/env python
import
subprocess
import
yaml
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
()
parser
.
add_argument
(
'
-f
'
,
'
--file
'
,
dest
=
'
file
'
,
default
=
'
example.yml
'
,
help
=
'
YML file containing the testbed configuration
'
)
args
=
parser
.
parse_args
()
with
open
(
args
.
file
)
as
cfile
:
conf
=
yaml
.
load
(
cfile
)
retval
=
subprocess
.
call
([
'
docker
'
,
'
pull
'
,
conf
[
'
image
'
]])
ntwk
=
conf
[
'
network
'
]
def
stop_node
(
name
,
i
):
ctr_name
=
'
{name}{i}
'
.
format
(
name
=
name
,
i
=
i
)
command
=
[
'
docker
'
,
'
kill
'
,
ctr_name
]
retval
=
subprocess
.
call
(
command
)
command
=
[
'
docker
'
,
'
rm
'
,
ctr_name
]
retval
=
subprocess
.
call
(
command
)
for
i
in
range
(
ntwk
[
'
num_nodes
'
]):
stop_node
(
ntwk
[
'
name
'
],
i
)
This diff is collapsed.
Click to expand it.
tear_down.py
deleted
100755 → 0
+
0
−
49
View file @
a9ecefd2
#! /usr/bin/env python
import
json
import
docker.client
import
time
import
os
d
=
docker
.
Client
()
fd
=
open
(
"
manifest.json
"
)
j
=
json
.
load
(
fd
)
def
extract_name
(
ctr
):
if
'
Name
'
not
in
ctr
:
return
None
slashed_name
=
ctr
[
'
Name
'
]
return
slashed_name
.
replace
(
"
/
"
,
""
)
def
remove
(
name
):
if
name
is
None
:
return
try
:
d
.
kill
(
name
)
except
:
None
try
:
d
.
remove_container
(
name
)
except
:
None
os
.
system
(
"
sudo ip netns delete %s
"
%
name
)
for
k
in
j
:
subnet
=
j
[
k
]
# First, kill the bridges. We do this because otherwise any tcpdumps we leave
# running will not terminate properly.
if
'
gateways
'
in
subnet
:
gateways
=
subnet
[
'
gateways
'
]
for
g
in
gateways
:
if
'
bridge
'
in
g
:
gname
=
g
[
'
name
'
]
gdev
=
g
[
'
bridge
'
]
os
.
system
(
"
sudo ip netns exec {} ip link delete {} type bridge
"
.
format
(
gname
,
gdev
))
if
'
containers
'
in
subnet
:
containers
=
subnet
[
'
containers
'
]
if
'
gateways
'
in
containers
:
gateways
=
containers
[
'
gateways
'
]
for
g
in
gateways
:
remove
(
extract_name
(
g
))
if
'
nodes
'
in
containers
:
nodes
=
containers
[
'
nodes
'
]
for
n
in
nodes
:
remove
(
extract_name
(
n
))
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