Committed by
Gerrit Code Review
Modified BMv2 demo scripts to work with onos.py
Change-Id: Ie6ff318f9aae2cbbeb288ba894e99a57d4d308db
Showing
2 changed files
with
63 additions
and
45 deletions
... | @@ -7,42 +7,42 @@ | ... | @@ -7,42 +7,42 @@ |
7 | } | 7 | } |
8 | }, | 8 | }, |
9 | "devices": { | 9 | "devices": { |
10 | - "bmv2:192.168.57.100:9090#11": { | 10 | + "bmv2:192.168.123.4:9090#11": { |
11 | "basic": { | 11 | "basic": { |
12 | "name": "bmv2:11", | 12 | "name": "bmv2:11", |
13 | "latitude": 40, | 13 | "latitude": 40, |
14 | "longitude": -107 | 14 | "longitude": -107 |
15 | } | 15 | } |
16 | }, | 16 | }, |
17 | - "bmv2:192.168.57.100:9091#12": { | 17 | + "bmv2:192.168.123.4:9091#12": { |
18 | "basic": { | 18 | "basic": { |
19 | "name": "bmv2:12", | 19 | "name": "bmv2:12", |
20 | "latitude": 40, | 20 | "latitude": 40, |
21 | "longitude": -99 | 21 | "longitude": -99 |
22 | } | 22 | } |
23 | }, | 23 | }, |
24 | - "bmv2:192.168.57.100:9092#13": { | 24 | + "bmv2:192.168.123.4:9092#13": { |
25 | "basic": { | 25 | "basic": { |
26 | "name": "bmv2:13", | 26 | "name": "bmv2:13", |
27 | "latitude": 40, | 27 | "latitude": 40, |
28 | "longitude": -91 | 28 | "longitude": -91 |
29 | } | 29 | } |
30 | }, | 30 | }, |
31 | - "bmv2:192.168.57.100:9093#21": { | 31 | + "bmv2:192.168.123.4:9093#21": { |
32 | "basic": { | 32 | "basic": { |
33 | "name": "bmv2:21", | 33 | "name": "bmv2:21", |
34 | "latitude": 46, | 34 | "latitude": 46, |
35 | "longitude": -107 | 35 | "longitude": -107 |
36 | } | 36 | } |
37 | }, | 37 | }, |
38 | - "bmv2:192.168.57.100:9094#22": { | 38 | + "bmv2:192.168.123.4:9094#22": { |
39 | "basic": { | 39 | "basic": { |
40 | "name": "bmv2:22", | 40 | "name": "bmv2:22", |
41 | "latitude": 46, | 41 | "latitude": 46, |
42 | "longitude": -99 | 42 | "longitude": -99 |
43 | } | 43 | } |
44 | }, | 44 | }, |
45 | - "bmv2:192.168.57.100:9095#23": { | 45 | + "bmv2:192.168.123.4:9095#23": { |
46 | "basic": { | 46 | "basic": { |
47 | "name": "bmv2:23", | 47 | "name": "bmv2:23", |
48 | "latitude": 46, | 48 | "latitude": 46, |
... | @@ -51,83 +51,83 @@ | ... | @@ -51,83 +51,83 @@ |
51 | } | 51 | } |
52 | }, | 52 | }, |
53 | "links": { | 53 | "links": { |
54 | - "bmv2:192.168.57.100:9090#11/1-bmv2:192.168.57.100:9093#21/1": { | 54 | + "bmv2:192.168.123.4:9090#11/1-bmv2:192.168.123.4:9093#21/1": { |
55 | "basic": {} | 55 | "basic": {} |
56 | }, | 56 | }, |
57 | - "bmv2:192.168.57.100:9093#21/1-bmv2:192.168.57.100:9090#11/1": { | 57 | + "bmv2:192.168.123.4:9093#21/1-bmv2:192.168.123.4:9090#11/1": { |
58 | "basic": {} | 58 | "basic": {} |
59 | }, | 59 | }, |
60 | - "bmv2:192.168.57.100:9090#11/2-bmv2:192.168.57.100:9093#21/2": { | 60 | + "bmv2:192.168.123.4:9090#11/2-bmv2:192.168.123.4:9093#21/2": { |
61 | "basic": {} | 61 | "basic": {} |
62 | }, | 62 | }, |
63 | - "bmv2:192.168.57.100:9093#21/2-bmv2:192.168.57.100:9090#11/2": { | 63 | + "bmv2:192.168.123.4:9093#21/2-bmv2:192.168.123.4:9090#11/2": { |
64 | "basic": {} | 64 | "basic": {} |
65 | }, | 65 | }, |
66 | - "bmv2:192.168.57.100:9090#11/3-bmv2:192.168.57.100:9094#22/1": { | 66 | + "bmv2:192.168.123.4:9090#11/3-bmv2:192.168.123.4:9094#22/1": { |
67 | "basic": {} | 67 | "basic": {} |
68 | }, | 68 | }, |
69 | - "bmv2:192.168.57.100:9094#22/1-bmv2:192.168.57.100:9090#11/3": { | 69 | + "bmv2:192.168.123.4:9094#22/1-bmv2:192.168.123.4:9090#11/3": { |
70 | "basic": {} | 70 | "basic": {} |
71 | }, | 71 | }, |
72 | - "bmv2:192.168.57.100:9090#11/4-bmv2:192.168.57.100:9095#23/1": { | 72 | + "bmv2:192.168.123.4:9090#11/4-bmv2:192.168.123.4:9095#23/1": { |
73 | "basic": {} | 73 | "basic": {} |
74 | }, | 74 | }, |
75 | - "bmv2:192.168.57.100:9095#23/1-bmv2:192.168.57.100:9090#11/4": { | 75 | + "bmv2:192.168.123.4:9095#23/1-bmv2:192.168.123.4:9090#11/4": { |
76 | "basic": {} | 76 | "basic": {} |
77 | }, | 77 | }, |
78 | - "bmv2:192.168.57.100:9091#12/1-bmv2:192.168.57.100:9093#21/3": { | 78 | + "bmv2:192.168.123.4:9091#12/1-bmv2:192.168.123.4:9093#21/3": { |
79 | "basic": {} | 79 | "basic": {} |
80 | }, | 80 | }, |
81 | - "bmv2:192.168.57.100:9093#21/3-bmv2:192.168.57.100:9091#12/1": { | 81 | + "bmv2:192.168.123.4:9093#21/3-bmv2:192.168.123.4:9091#12/1": { |
82 | "basic": {} | 82 | "basic": {} |
83 | }, | 83 | }, |
84 | - "bmv2:192.168.57.100:9091#12/2-bmv2:192.168.57.100:9094#22/2": { | 84 | + "bmv2:192.168.123.4:9091#12/2-bmv2:192.168.123.4:9094#22/2": { |
85 | "basic": {} | 85 | "basic": {} |
86 | }, | 86 | }, |
87 | - "bmv2:192.168.57.100:9094#22/2-bmv2:192.168.57.100:9091#12/2": { | 87 | + "bmv2:192.168.123.4:9094#22/2-bmv2:192.168.123.4:9091#12/2": { |
88 | "basic": {} | 88 | "basic": {} |
89 | }, | 89 | }, |
90 | - "bmv2:192.168.57.100:9091#12/3-bmv2:192.168.57.100:9094#22/3": { | 90 | + "bmv2:192.168.123.4:9091#12/3-bmv2:192.168.123.4:9094#22/3": { |
91 | "basic": {} | 91 | "basic": {} |
92 | }, | 92 | }, |
93 | - "bmv2:192.168.57.100:9094#22/3-bmv2:192.168.57.100:9091#12/3": { | 93 | + "bmv2:192.168.123.4:9094#22/3-bmv2:192.168.123.4:9091#12/3": { |
94 | "basic": {} | 94 | "basic": {} |
95 | }, | 95 | }, |
96 | - "bmv2:192.168.57.100:9091#12/4-bmv2:192.168.57.100:9095#23/2": { | 96 | + "bmv2:192.168.123.4:9091#12/4-bmv2:192.168.123.4:9095#23/2": { |
97 | "basic": {} | 97 | "basic": {} |
98 | }, | 98 | }, |
99 | - "bmv2:192.168.57.100:9095#23/2-bmv2:192.168.57.100:9091#12/4": { | 99 | + "bmv2:192.168.123.4:9095#23/2-bmv2:192.168.123.4:9091#12/4": { |
100 | "basic": {} | 100 | "basic": {} |
101 | }, | 101 | }, |
102 | - "bmv2:192.168.57.100:9092#13/1-bmv2:192.168.57.100:9093#21/4": { | 102 | + "bmv2:192.168.123.4:9092#13/1-bmv2:192.168.123.4:9093#21/4": { |
103 | "basic": {} | 103 | "basic": {} |
104 | }, | 104 | }, |
105 | - "bmv2:192.168.57.100:9093#21/4-bmv2:192.168.57.100:9092#13/1": { | 105 | + "bmv2:192.168.123.4:9093#21/4-bmv2:192.168.123.4:9092#13/1": { |
106 | "basic": {} | 106 | "basic": {} |
107 | }, | 107 | }, |
108 | - "bmv2:192.168.57.100:9092#13/2-bmv2:192.168.57.100:9094#22/4": { | 108 | + "bmv2:192.168.123.4:9092#13/2-bmv2:192.168.123.4:9094#22/4": { |
109 | "basic": {} | 109 | "basic": {} |
110 | }, | 110 | }, |
111 | - "bmv2:192.168.57.100:9094#22/4-bmv2:192.168.57.100:9092#13/2": { | 111 | + "bmv2:192.168.123.4:9094#22/4-bmv2:192.168.123.4:9092#13/2": { |
112 | "basic": {} | 112 | "basic": {} |
113 | }, | 113 | }, |
114 | - "bmv2:192.168.57.100:9092#13/3-bmv2:192.168.57.100:9095#23/3": { | 114 | + "bmv2:192.168.123.4:9092#13/3-bmv2:192.168.123.4:9095#23/3": { |
115 | "basic": {} | 115 | "basic": {} |
116 | }, | 116 | }, |
117 | - "bmv2:192.168.57.100:9095#23/3-bmv2:192.168.57.100:9092#13/3": { | 117 | + "bmv2:192.168.123.4:9095#23/3-bmv2:192.168.123.4:9092#13/3": { |
118 | "basic": {} | 118 | "basic": {} |
119 | }, | 119 | }, |
120 | - "bmv2:192.168.57.100:9092#13/4-bmv2:192.168.57.100:9095#23/4": { | 120 | + "bmv2:192.168.123.4:9092#13/4-bmv2:192.168.123.4:9095#23/4": { |
121 | "basic": {} | 121 | "basic": {} |
122 | }, | 122 | }, |
123 | - "bmv2:192.168.57.100:9095#23/4-bmv2:192.168.57.100:9092#13/4": { | 123 | + "bmv2:192.168.123.4:9095#23/4-bmv2:192.168.123.4:9092#13/4": { |
124 | "basic": {} | 124 | "basic": {} |
125 | } | 125 | } |
126 | }, | 126 | }, |
127 | "hosts": { | 127 | "hosts": { |
128 | "00:00:00:00:00:01/-1": { | 128 | "00:00:00:00:00:01/-1": { |
129 | "basic": { | 129 | "basic": { |
130 | - "location": "bmv2:192.168.57.100:9090#11/5", | 130 | + "location": "bmv2:192.168.123.4:9090#11/5", |
131 | "ips": [ | 131 | "ips": [ |
132 | "10.0.0.1" | 132 | "10.0.0.1" |
133 | ], | 133 | ], |
... | @@ -138,7 +138,7 @@ | ... | @@ -138,7 +138,7 @@ |
138 | }, | 138 | }, |
139 | "00:00:00:00:00:02/-1": { | 139 | "00:00:00:00:00:02/-1": { |
140 | "basic": { | 140 | "basic": { |
141 | - "location": "bmv2:192.168.57.100:9091#12/5", | 141 | + "location": "bmv2:192.168.123.4:9091#12/5", |
142 | "ips": [ | 142 | "ips": [ |
143 | "10.0.0.2" | 143 | "10.0.0.2" |
144 | ], | 144 | ], |
... | @@ -149,7 +149,7 @@ | ... | @@ -149,7 +149,7 @@ |
149 | }, | 149 | }, |
150 | "00:00:00:00:00:03/-1": { | 150 | "00:00:00:00:00:03/-1": { |
151 | "basic": { | 151 | "basic": { |
152 | - "location": "bmv2:192.168.57.100:9092#13/5", | 152 | + "location": "bmv2:192.168.123.4:9092#13/5", |
153 | "ips": [ | 153 | "ips": [ |
154 | "10.0.0.3" | 154 | "10.0.0.3" |
155 | ], | 155 | ], | ... | ... |
... | @@ -4,23 +4,26 @@ import os | ... | @@ -4,23 +4,26 @@ import os |
4 | import sys | 4 | import sys |
5 | import argparse | 5 | import argparse |
6 | 6 | ||
7 | -# Find and import bmv2.py | ||
8 | if 'ONOS_ROOT' not in os.environ: | 7 | if 'ONOS_ROOT' not in os.environ: |
9 | print "Environment var $ONOS_ROOT not set" | 8 | print "Environment var $ONOS_ROOT not set" |
10 | exit() | 9 | exit() |
11 | else: | 10 | else: |
12 | - sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet") | 11 | + ONOS_ROOT = os.environ["ONOS_ROOT"] |
13 | - from bmv2 import ONOSBmv2Switch | 12 | + sys.path.append(ONOS_ROOT + "/tools/dev/mininet") |
13 | + | ||
14 | +from onos import ONOSCluster, ONOSCLI | ||
15 | +from bmv2 import ONOSBmv2Switch | ||
14 | 16 | ||
15 | from itertools import combinations | 17 | from itertools import combinations |
16 | from time import sleep | 18 | from time import sleep |
19 | +from subprocess import call | ||
17 | 20 | ||
18 | from mininet.cli import CLI | 21 | from mininet.cli import CLI |
19 | from mininet.link import TCLink | 22 | from mininet.link import TCLink |
20 | from mininet.log import setLogLevel | 23 | from mininet.log import setLogLevel |
21 | from mininet.net import Mininet | 24 | from mininet.net import Mininet |
22 | from mininet.node import RemoteController, Host | 25 | from mininet.node import RemoteController, Host |
23 | -from mininet.topo import Topo | 26 | +from mininet.topo import Topo, SingleSwitchTopo |
24 | 27 | ||
25 | 28 | ||
26 | class ClosTopo(Topo): | 29 | class ClosTopo(Topo): |
... | @@ -126,39 +129,54 @@ class DemoHost(Host): | ... | @@ -126,39 +129,54 @@ class DemoHost(Host): |
126 | def main(args): | 129 | def main(args): |
127 | topo = ClosTopo() | 130 | topo = ClosTopo() |
128 | 131 | ||
129 | - net = Mininet(topo=topo, build=False) | 132 | + if not args.onos_ip: |
133 | + controller = ONOSCluster('c0', 3) | ||
134 | + onosIp = controller.nodes()[0].IP() | ||
135 | + else: | ||
136 | + controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port) | ||
137 | + onosIp = args.onos_ip | ||
130 | 138 | ||
131 | - net.addController('c0', controller=RemoteController, ip=args.onos_ip, port=args.onos_port) | 139 | + net = Mininet(topo=topo, build=False, controller=[controller]) |
132 | 140 | ||
133 | net.build() | 141 | net.build() |
134 | net.start() | 142 | net.start() |
135 | 143 | ||
136 | - print "Network started..." | 144 | + print "Network started" |
137 | 145 | ||
138 | - # Generates background traffic (needed for host discovery and bmv2 config swap). | 146 | + # Generate background traffic. |
139 | sleep(3) | 147 | sleep(3) |
140 | for (h1, h2) in combinations(net.hosts, 2): | 148 | for (h1, h2) in combinations(net.hosts, 2): |
141 | h1.startPingBg(h2) | 149 | h1.startPingBg(h2) |
142 | h2.startPingBg(h1) | 150 | h2.startPingBg(h1) |
143 | 151 | ||
152 | + print "Background ping started" | ||
153 | + | ||
144 | for h in net.hosts: | 154 | for h in net.hosts: |
145 | h.startIperfServer() | 155 | h.startIperfServer() |
146 | 156 | ||
147 | - print "Background ping started..." | 157 | + print "Iperf servers started" |
148 | 158 | ||
149 | # sleep(4) | 159 | # sleep(4) |
150 | # print "Starting traffic from h1 to h3..." | 160 | # print "Starting traffic from h1 to h3..." |
151 | # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10) | 161 | # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10) |
152 | 162 | ||
153 | - CLI(net) | 163 | + print "Setting netcfg..." |
164 | + call(("onos-netcfg", onosIp, | ||
165 | + "%s/tools/test/topos/bmv2-demo-cfg.json" % ONOS_ROOT)) | ||
166 | + | ||
167 | + if not args.onos_ip: | ||
168 | + ONOSCLI(net) | ||
169 | + else: | ||
170 | + CLI(net) | ||
154 | 171 | ||
155 | net.stop() | 172 | net.stop() |
156 | 173 | ||
157 | 174 | ||
158 | if __name__ == '__main__': | 175 | if __name__ == '__main__': |
159 | - parser = argparse.ArgumentParser(description='BMv2 mininet demo script (2-stage Clos topology)') | 176 | + parser = argparse.ArgumentParser( |
177 | + description='BMv2 mininet demo script (2-stage Clos topology)') | ||
160 | parser.add_argument('--onos-ip', help='ONOS-BMv2 controller IP address', | 178 | parser.add_argument('--onos-ip', help='ONOS-BMv2 controller IP address', |
161 | - type=str, action="store", required=True) | 179 | + type=str, action="store", required=False) |
162 | parser.add_argument('--onos-port', help='ONOS-BMv2 controller port', | 180 | parser.add_argument('--onos-port', help='ONOS-BMv2 controller port', |
163 | type=int, action="store", default=40123) | 181 | type=int, action="store", default=40123) |
164 | args = parser.parse_args() | 182 | args = parser.parse_args() | ... | ... |
-
Please register or login to post a comment