-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
executable file
·285 lines (246 loc) · 7.17 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/python
from mininet_extensions import MininetOSHI
from utility import unmountAll, PropertiesGenerator
import subprocess
def test_add_nodes_and_add_link():
verbose=True
net = MininetOSHI(verbose)
generator = PropertiesGenerator(False)
cr_os = ["cro1","cro2","cro3"]
pe_os = ["peo1","peo2","peo3"]
ctrls = ["ctr1","ctr2","ctr3"]
sws = ["swi1","swi2","swi3"]
ce_os = ["cer1","cer2","cer3"]
net1 = [("cro1","swi1"),("swi1","cro2"),("cro3","swi1")]
net2 = [("peo1","cro1")]
net3 = [("cro2","peo2")]
net4 = [("peo3","cro3")]
net5 = [("cer1","peo1")]
net6 = [("cer2","peo2")]
net7 = [("cer3","peo3")]
net8 = [("cro1","ctr1")]
net9 = [("ctr2","cro2")]
net10 = [("cro3","ctr3")]
vlls = [("cer1","cer2"), ("cer2","cer3"), ("cer3","cer1")]
cr_prop = generator.getVerticesProperties(cr_os)
pe_prop = generator.getVerticesProperties(pe_os)
ct_prop = generator.getVerticesProperties(ctrls)
sw_prop = generator.getVerticesProperties(sws)
ce_prop = generator.getVerticesProperties(ce_os)
net1_properties = generator.getLinksProperties(net1)
net2_properties = generator.getLinksProperties(net2)
net3_properties = generator.getLinksProperties(net3)
net4_properties = generator.getLinksProperties(net4)
net5_properties = generator.getLinksProperties(net5)
net6_properties = generator.getLinksProperties(net6)
net7_properties = generator.getLinksProperties(net7)
net8_properties = generator.getLinksProperties(net8)
net9_properties = generator.getLinksProperties(net9)
net10_properties = generator.getLinksProperties(net10)
vlls_properties = []
for vll in vlls:
vll_properties = generator.getVLLsProperties(vll)
vlls_properties.append(vll_properties)
print "*** Create Core OSHI"
i = 0
for i in range(0, len(cr_os)):
cr_oshi = net.addCrOSHI(name = cr_os[i], params = cr_prop[i])
i = i + 1
print "*** Create Provider Edge OSHI"
i = 0
for i in range(0, len(pe_os)):
pe_oshi = net.addPeOSHI(name = pe_os[i], params = pe_prop[i])
i = i + 1
print "*** Create LegacyL2Switch"
i = 0
for i in range(0, len(sws)):
switch = net.addSwitch(name = sws[i])
i = i + 1
print "*** Create Controllers"
i = 0
for i in range(0, len(cr_os)):
ctrl = net.addController(name = ctrls[i])
i = i + 1
print "*** Create Customer Edge Router"
i = 0
for i in range(0, len(ce_os)):
ce_router = net.addCeRouter(name = ce_os[i])
i = i + 1
i = 0
for link in net1:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net1_properties[i])
i = i + 1
i = 0
for link in net2:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net2_properties[i])
i = i + 1
i = 0
for link in net3:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net3_properties[i])
i = i + 1
i = 0
for link in net4:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net4_properties[i])
i = i + 1
i = 0
for link in net5:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net5_properties[i])
i = i + 1
i = 0
for link in net6:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net6_properties[i])
i = i + 1
i = 0
for link in net7:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net7_properties[i])
i = i + 1
i = 0
for link in net8:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net8_properties[i])
i = i + 1
i = 0
for link in net9:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net9_properties[i])
i = i + 1
i = 0
for link in net10:
lhs = net.getNodeByName(link[0])
rhs = net.getNodeByName(link[1])
net.addLink(lhs, rhs, net10_properties[i])
i = i + 1
net.start()
print "*** Press any key to continue"
a=raw_input()
net.stop()
subprocess.call(["sudo", "mn", "-c"], stdout=None, stderr=None)
unmountAll()
def test_properties_generator():
verbose=True
net = MininetOSHI(verbose)
generator = PropertiesGenerator(False)
cr_os = ["cro1","cro2","cro3"]
pe_os = ["peo1","peo2","peo3"]
ctrls = ["ctr1","ctr2","ctr3"]
sws = ["swi1","swi2","swi3"]
ce_os = ["cer1","cer2","cer3"]
mgm_os = ["mgm1"]
net1 = [("cro1","swi1"),("swi1","cro2"),("cro3","swi1")]
net2 = [("peo1","cro1")]
net3 = [("cro2","peo2")]
net4 = [("peo3","cro3")]
net5 = [("cer1","peo1")]
net6 = [("cer2","peo2")]
net7 = [("cer3","peo3")]
net8 = [("cro1","mgm1")]
print "Vertices Properties"
cr_prop = generator.getVerticesProperties(cr_os)
i = 0
for cr_property in cr_prop:
print "%s -> %s" %(cr_os[i], cr_property)
i = i + 1
i = 0
pe_prop = generator.getVerticesProperties(pe_os)
i = 0
for pe_property in pe_prop:
print "%s -> %s" %(pe_os[i], pe_property)
i = i + 1
i = 0
ct_prop = generator.getVerticesProperties(ctrls)
i = 0
for ct_property in ct_prop:
print "%s -> %s" %(ctrls[i], ct_property)
i = i + 1
i = 0
sw_prop = generator.getVerticesProperties(sws)
i = 0
for sw_property in sw_prop:
print "%s -> %s" %(sws[i], sw_property)
i = i + 1
i = 0
ce_prop = generator.getVerticesProperties(ce_os)
i = 0
for ce_property in ce_prop:
print "%s -> %s" %(ce_os[i], ce_property)
i = i + 1
i = 0
mgm_prop = generator.getVerticesProperties(mgm_os)
for mgm_property in mgm_prop:
print "%s -> %s" %(mgm_os[i], mgm_property)
i = i + 1
print "###################################################"
properties = generator.getLinksProperties(net1)
print "Net1 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net1[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net2)
print "Net2 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net2[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net3)
print "Net3 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net3[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net4)
print "Net4 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net4[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net5)
print "Net5 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net5[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net6)
print "Net6 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net6[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net7)
print "Net7 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net7[i],l_property)
i = i + 1
properties = generator.getLinksProperties(net8)
print "Net8 Properties"
i = 0
for l_property in properties:
print "%s -> %s" %(net8[i],l_property)
i = i + 1
print "###################################################"
print "VLLs Properties"
vlls = [("cer1","cer2"), ("cer2","cer3"), ("cer3","cer1")]
for vll in vlls:
print "%s -> %s" %(vll, generator.getVLLsProperties(vll))
print "###################################################"
subprocess.call(["sudo", "mn", "-c"], stdout=None, stderr=None)
unmountAll()
if __name__ == '__main__':
test_properties_generator()