Carmelo Cascone
Committed by Gerrit Code Review

Modified BMv2 demo scripts to work with onos.py

Change-Id: Ie6ff318f9aae2cbbeb288ba894e99a57d4d308db
......@@ -7,42 +7,42 @@
}
},
"devices": {
"bmv2:192.168.57.100:9090#11": {
"bmv2:192.168.123.4:9090#11": {
"basic": {
"name": "bmv2:11",
"latitude": 40,
"longitude": -107
}
},
"bmv2:192.168.57.100:9091#12": {
"bmv2:192.168.123.4:9091#12": {
"basic": {
"name": "bmv2:12",
"latitude": 40,
"longitude": -99
}
},
"bmv2:192.168.57.100:9092#13": {
"bmv2:192.168.123.4:9092#13": {
"basic": {
"name": "bmv2:13",
"latitude": 40,
"longitude": -91
}
},
"bmv2:192.168.57.100:9093#21": {
"bmv2:192.168.123.4:9093#21": {
"basic": {
"name": "bmv2:21",
"latitude": 46,
"longitude": -107
}
},
"bmv2:192.168.57.100:9094#22": {
"bmv2:192.168.123.4:9094#22": {
"basic": {
"name": "bmv2:22",
"latitude": 46,
"longitude": -99
}
},
"bmv2:192.168.57.100:9095#23": {
"bmv2:192.168.123.4:9095#23": {
"basic": {
"name": "bmv2:23",
"latitude": 46,
......@@ -51,83 +51,83 @@
}
},
"links": {
"bmv2:192.168.57.100:9090#11/1-bmv2:192.168.57.100:9093#21/1": {
"bmv2:192.168.123.4:9090#11/1-bmv2:192.168.123.4:9093#21/1": {
"basic": {}
},
"bmv2:192.168.57.100:9093#21/1-bmv2:192.168.57.100:9090#11/1": {
"bmv2:192.168.123.4:9093#21/1-bmv2:192.168.123.4:9090#11/1": {
"basic": {}
},
"bmv2:192.168.57.100:9090#11/2-bmv2:192.168.57.100:9093#21/2": {
"bmv2:192.168.123.4:9090#11/2-bmv2:192.168.123.4:9093#21/2": {
"basic": {}
},
"bmv2:192.168.57.100:9093#21/2-bmv2:192.168.57.100:9090#11/2": {
"bmv2:192.168.123.4:9093#21/2-bmv2:192.168.123.4:9090#11/2": {
"basic": {}
},
"bmv2:192.168.57.100:9090#11/3-bmv2:192.168.57.100:9094#22/1": {
"bmv2:192.168.123.4:9090#11/3-bmv2:192.168.123.4:9094#22/1": {
"basic": {}
},
"bmv2:192.168.57.100:9094#22/1-bmv2:192.168.57.100:9090#11/3": {
"bmv2:192.168.123.4:9094#22/1-bmv2:192.168.123.4:9090#11/3": {
"basic": {}
},
"bmv2:192.168.57.100:9090#11/4-bmv2:192.168.57.100:9095#23/1": {
"bmv2:192.168.123.4:9090#11/4-bmv2:192.168.123.4:9095#23/1": {
"basic": {}
},
"bmv2:192.168.57.100:9095#23/1-bmv2:192.168.57.100:9090#11/4": {
"bmv2:192.168.123.4:9095#23/1-bmv2:192.168.123.4:9090#11/4": {
"basic": {}
},
"bmv2:192.168.57.100:9091#12/1-bmv2:192.168.57.100:9093#21/3": {
"bmv2:192.168.123.4:9091#12/1-bmv2:192.168.123.4:9093#21/3": {
"basic": {}
},
"bmv2:192.168.57.100:9093#21/3-bmv2:192.168.57.100:9091#12/1": {
"bmv2:192.168.123.4:9093#21/3-bmv2:192.168.123.4:9091#12/1": {
"basic": {}
},
"bmv2:192.168.57.100:9091#12/2-bmv2:192.168.57.100:9094#22/2": {
"bmv2:192.168.123.4:9091#12/2-bmv2:192.168.123.4:9094#22/2": {
"basic": {}
},
"bmv2:192.168.57.100:9094#22/2-bmv2:192.168.57.100:9091#12/2": {
"bmv2:192.168.123.4:9094#22/2-bmv2:192.168.123.4:9091#12/2": {
"basic": {}
},
"bmv2:192.168.57.100:9091#12/3-bmv2:192.168.57.100:9094#22/3": {
"bmv2:192.168.123.4:9091#12/3-bmv2:192.168.123.4:9094#22/3": {
"basic": {}
},
"bmv2:192.168.57.100:9094#22/3-bmv2:192.168.57.100:9091#12/3": {
"bmv2:192.168.123.4:9094#22/3-bmv2:192.168.123.4:9091#12/3": {
"basic": {}
},
"bmv2:192.168.57.100:9091#12/4-bmv2:192.168.57.100:9095#23/2": {
"bmv2:192.168.123.4:9091#12/4-bmv2:192.168.123.4:9095#23/2": {
"basic": {}
},
"bmv2:192.168.57.100:9095#23/2-bmv2:192.168.57.100:9091#12/4": {
"bmv2:192.168.123.4:9095#23/2-bmv2:192.168.123.4:9091#12/4": {
"basic": {}
},
"bmv2:192.168.57.100:9092#13/1-bmv2:192.168.57.100:9093#21/4": {
"bmv2:192.168.123.4:9092#13/1-bmv2:192.168.123.4:9093#21/4": {
"basic": {}
},
"bmv2:192.168.57.100:9093#21/4-bmv2:192.168.57.100:9092#13/1": {
"bmv2:192.168.123.4:9093#21/4-bmv2:192.168.123.4:9092#13/1": {
"basic": {}
},
"bmv2:192.168.57.100:9092#13/2-bmv2:192.168.57.100:9094#22/4": {
"bmv2:192.168.123.4:9092#13/2-bmv2:192.168.123.4:9094#22/4": {
"basic": {}
},
"bmv2:192.168.57.100:9094#22/4-bmv2:192.168.57.100:9092#13/2": {
"bmv2:192.168.123.4:9094#22/4-bmv2:192.168.123.4:9092#13/2": {
"basic": {}
},
"bmv2:192.168.57.100:9092#13/3-bmv2:192.168.57.100:9095#23/3": {
"bmv2:192.168.123.4:9092#13/3-bmv2:192.168.123.4:9095#23/3": {
"basic": {}
},
"bmv2:192.168.57.100:9095#23/3-bmv2:192.168.57.100:9092#13/3": {
"bmv2:192.168.123.4:9095#23/3-bmv2:192.168.123.4:9092#13/3": {
"basic": {}
},
"bmv2:192.168.57.100:9092#13/4-bmv2:192.168.57.100:9095#23/4": {
"bmv2:192.168.123.4:9092#13/4-bmv2:192.168.123.4:9095#23/4": {
"basic": {}
},
"bmv2:192.168.57.100:9095#23/4-bmv2:192.168.57.100:9092#13/4": {
"bmv2:192.168.123.4:9095#23/4-bmv2:192.168.123.4:9092#13/4": {
"basic": {}
}
},
"hosts": {
"00:00:00:00:00:01/-1": {
"basic": {
"location": "bmv2:192.168.57.100:9090#11/5",
"location": "bmv2:192.168.123.4:9090#11/5",
"ips": [
"10.0.0.1"
],
......@@ -138,7 +138,7 @@
},
"00:00:00:00:00:02/-1": {
"basic": {
"location": "bmv2:192.168.57.100:9091#12/5",
"location": "bmv2:192.168.123.4:9091#12/5",
"ips": [
"10.0.0.2"
],
......@@ -149,7 +149,7 @@
},
"00:00:00:00:00:03/-1": {
"basic": {
"location": "bmv2:192.168.57.100:9092#13/5",
"location": "bmv2:192.168.123.4:9092#13/5",
"ips": [
"10.0.0.3"
],
......
......@@ -4,23 +4,26 @@ import os
import sys
import argparse
# Find and import bmv2.py
if 'ONOS_ROOT' not in os.environ:
print "Environment var $ONOS_ROOT not set"
exit()
else:
sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet")
from bmv2 import ONOSBmv2Switch
ONOS_ROOT = os.environ["ONOS_ROOT"]
sys.path.append(ONOS_ROOT + "/tools/dev/mininet")
from onos import ONOSCluster, ONOSCLI
from bmv2 import ONOSBmv2Switch
from itertools import combinations
from time import sleep
from subprocess import call
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.node import RemoteController, Host
from mininet.topo import Topo
from mininet.topo import Topo, SingleSwitchTopo
class ClosTopo(Topo):
......@@ -126,39 +129,54 @@ class DemoHost(Host):
def main(args):
topo = ClosTopo()
net = Mininet(topo=topo, build=False)
if not args.onos_ip:
controller = ONOSCluster('c0', 3)
onosIp = controller.nodes()[0].IP()
else:
controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port)
onosIp = args.onos_ip
net.addController('c0', controller=RemoteController, ip=args.onos_ip, port=args.onos_port)
net = Mininet(topo=topo, build=False, controller=[controller])
net.build()
net.start()
print "Network started..."
print "Network started"
# Generates background traffic (needed for host discovery and bmv2 config swap).
# Generate background traffic.
sleep(3)
for (h1, h2) in combinations(net.hosts, 2):
h1.startPingBg(h2)
h2.startPingBg(h1)
print "Background ping started"
for h in net.hosts:
h.startIperfServer()
print "Background ping started..."
print "Iperf servers started"
# sleep(4)
# print "Starting traffic from h1 to h3..."
# net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)
print "Setting netcfg..."
call(("onos-netcfg", onosIp,
"%s/tools/test/topos/bmv2-demo-cfg.json" % ONOS_ROOT))
if not args.onos_ip:
ONOSCLI(net)
else:
CLI(net)
net.stop()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='BMv2 mininet demo script (2-stage Clos topology)')
parser = argparse.ArgumentParser(
description='BMv2 mininet demo script (2-stage Clos topology)')
parser.add_argument('--onos-ip', help='ONOS-BMv2 controller IP address',
type=str, action="store", required=True)
type=str, action="store", required=False)
parser.add_argument('--onos-port', help='ONOS-BMv2 controller port',
type=int, action="store", default=40123)
args = parser.parse_args()
......