1
|
|
|
"""Module to overwrite all the needed methods.""" |
2
|
|
|
|
3
|
|
|
# pylint: disable=E0401 |
4
|
1 |
|
from tests.integration.test_paths import TestPaths |
5
|
|
|
|
6
|
|
|
|
7
|
1 |
|
class MetadataSettings(TestPaths): |
8
|
|
|
"""Class to setups all the settings related to topology.""" |
9
|
|
|
|
10
|
1 |
|
@staticmethod |
11
|
1 |
|
def generate_topology(): |
12
|
|
|
"""Generate a predetermined topology.""" |
13
|
1 |
|
switches, interfaces, links = {}, {}, {} |
14
|
|
|
|
15
|
1 |
|
MetadataSettings.setting_switches_interfaces(interfaces, switches) |
16
|
|
|
|
17
|
1 |
|
MetadataSettings.setting_links(interfaces, links) |
18
|
|
|
|
19
|
1 |
|
MetadataSettings.adding_metadata(links) |
20
|
|
|
|
21
|
1 |
|
return switches, links |
22
|
|
|
|
23
|
1 |
|
@staticmethod |
24
|
1 |
|
def setting_switches_interfaces(interfaces, switches): |
25
|
|
|
"""Generate the switches in a a predetermined topology.""" |
26
|
1 |
|
TestPaths.create_switch("User1", switches) |
27
|
1 |
|
TestPaths.add_interfaces(3, switches["User1"], interfaces) |
28
|
|
|
|
29
|
1 |
|
TestPaths.create_switch("S2", switches) |
30
|
1 |
|
TestPaths.add_interfaces(2, switches["S2"], interfaces) |
31
|
|
|
|
32
|
1 |
|
TestPaths.create_switch("User2", switches) |
33
|
1 |
|
TestPaths.add_interfaces(3, switches["User2"], interfaces) |
34
|
|
|
|
35
|
1 |
|
TestPaths.create_switch("S4", switches) |
36
|
1 |
|
TestPaths.add_interfaces(4, switches["S4"], interfaces) |
37
|
|
|
|
38
|
1 |
|
TestPaths.create_switch("S5", switches) |
39
|
1 |
|
TestPaths.add_interfaces(2, switches["S5"], interfaces) |
40
|
|
|
|
41
|
1 |
|
@staticmethod |
42
|
1 |
|
def setting_links(interfaces, links): |
43
|
|
|
"""Generate the links in a a predetermined topology.""" |
44
|
1 |
|
TestPaths.create_link("User1:1", "S2:1", interfaces, links) |
45
|
|
|
|
46
|
1 |
|
TestPaths.create_link("User1:2", "S5:1", interfaces, links) |
47
|
|
|
|
48
|
1 |
|
TestPaths.create_link("User1:3", "S4:1", interfaces, links) |
49
|
|
|
|
50
|
1 |
|
TestPaths.create_link("S2:2", "User2:1", interfaces, links) |
51
|
|
|
|
52
|
1 |
|
TestPaths.create_link("User2:2", "S4:2", interfaces, links) |
53
|
|
|
|
54
|
1 |
|
TestPaths.create_link("S5:2", "S4:3", interfaces, links) |
55
|
|
|
|
56
|
1 |
|
TestPaths.create_link("User2:3", "S4:4", interfaces, links) |
57
|
|
|
|
58
|
1 |
|
@staticmethod |
59
|
1 |
|
def adding_metadata(links): |
60
|
|
|
"""Add the links' metadata in a a predetermined topology.""" |
61
|
1 |
|
TestPaths.add_metadata_to_link( |
62
|
|
|
"User1:1", |
63
|
|
|
"S2:1", |
64
|
|
|
{ |
65
|
|
|
"reliability": 3, |
66
|
|
|
"ownership": { |
67
|
|
|
"B": {"max_utilization": 50}, |
68
|
|
|
"C": {"max_utilization": 50}, |
69
|
|
|
}, |
70
|
|
|
"delay": 30, |
71
|
|
|
"bandwidth": 20, |
72
|
|
|
}, |
73
|
|
|
links, |
74
|
|
|
) |
75
|
|
|
|
76
|
1 |
|
TestPaths.add_metadata_to_link( |
77
|
|
|
"User1:2", |
78
|
|
|
"S5:1", |
79
|
|
|
{ |
80
|
|
|
"reliability": 1, |
81
|
|
|
"ownership": {"A": {}}, |
82
|
|
|
"delay": 5, |
83
|
|
|
"bandwidth": 50, |
84
|
|
|
}, |
85
|
|
|
links, |
86
|
|
|
) |
87
|
|
|
|
88
|
1 |
|
TestPaths.add_metadata_to_link( |
89
|
|
|
"User1:3", |
90
|
|
|
"S4:1", |
91
|
|
|
{ |
92
|
|
|
"reliability": 3, |
93
|
|
|
"ownership": {"A": {}}, |
94
|
|
|
"delay": 60, |
95
|
|
|
"bandwidth": 10, |
96
|
|
|
}, |
97
|
|
|
links, |
98
|
|
|
) |
99
|
|
|
|
100
|
1 |
|
TestPaths.add_metadata_to_link( |
101
|
|
|
"S2:2", |
102
|
|
|
"User2:1", |
103
|
|
|
{ |
104
|
|
|
"reliability": 3, |
105
|
|
|
"ownership": { |
106
|
|
|
"B": {"max_utilization": 50}, |
107
|
|
|
"C": {"max_utilization": 50}, |
108
|
|
|
}, |
109
|
|
|
"delay": 30, |
110
|
|
|
"bandwidth": 20, |
111
|
|
|
}, |
112
|
|
|
links, |
113
|
|
|
) |
114
|
|
|
|
115
|
1 |
|
TestPaths.add_metadata_to_link( |
116
|
|
|
"User2:2", |
117
|
|
|
"S4:2", |
118
|
|
|
{ |
119
|
|
|
"reliability": 3, |
120
|
|
|
"ownership": {"B": {}}, |
121
|
|
|
"delay": 30, |
122
|
|
|
"bandwidth": 10, |
123
|
|
|
}, |
124
|
|
|
links, |
125
|
|
|
) |
126
|
|
|
|
127
|
1 |
|
TestPaths.add_metadata_to_link( |
128
|
|
|
"S5:2", |
129
|
|
|
"S4:3", |
130
|
|
|
{ |
131
|
|
|
"reliability": 1, |
132
|
|
|
"ownership": {"A": {}}, |
133
|
|
|
"delay": 10, |
134
|
|
|
"bandwidth": 50, |
135
|
|
|
}, |
136
|
|
|
links, |
137
|
|
|
) |
138
|
|
|
|
139
|
1 |
|
TestPaths.add_metadata_to_link( |
140
|
|
|
"User2:3", |
141
|
|
|
"S4:4", |
142
|
|
|
{ |
143
|
|
|
"reliability": 3, |
144
|
|
|
"ownership": {"A": {}}, |
145
|
|
|
"delay": 29, |
146
|
|
|
"bandwidth": 20, |
147
|
|
|
}, |
148
|
|
|
links, |
149
|
|
|
) |
150
|
|
|
|
151
|
1 |
|
@staticmethod |
152
|
1 |
|
def generate_topology_1(): |
153
|
|
|
"""Generate a predetermined topology, 2nd variant.""" |
154
|
1 |
|
switches = {} |
155
|
1 |
|
interfaces = {} |
156
|
1 |
|
links = {} |
157
|
|
|
|
158
|
1 |
|
MetadataSettings.setting_switches_interfaces_1(interfaces, switches) |
159
|
|
|
|
160
|
1 |
|
MetadataSettings.setting_links_1(interfaces, links) |
161
|
|
|
|
162
|
1 |
|
MetadataSettings.adding_metadata_1(links) |
163
|
|
|
|
164
|
1 |
|
return switches, links |
165
|
|
|
|
166
|
1 |
|
@staticmethod |
167
|
1 |
|
def setting_switches_interfaces_1(interfaces, switches): |
168
|
|
|
"""Generate the switches in a a topology, 2nd variant.""" |
169
|
1 |
|
TestPaths.create_switch("User1", switches) |
170
|
1 |
|
TestPaths.add_interfaces(2, switches["User1"], interfaces) |
171
|
|
|
|
172
|
1 |
|
TestPaths.create_switch("User2", switches) |
173
|
1 |
|
TestPaths.add_interfaces(2, switches["User2"], interfaces) |
174
|
|
|
|
175
|
1 |
|
TestPaths.create_switch("User3", switches) |
176
|
1 |
|
TestPaths.add_interfaces(2, switches["User3"], interfaces) |
177
|
|
|
|
178
|
1 |
|
TestPaths.create_switch("S1", switches) |
179
|
1 |
|
TestPaths.add_interfaces(1, switches["S1"], interfaces) |
180
|
|
|
|
181
|
1 |
|
TestPaths.create_switch("S2", switches) |
182
|
1 |
|
TestPaths.add_interfaces(1, switches["S2"], interfaces) |
183
|
|
|
|
184
|
1 |
|
TestPaths.create_switch("S3", switches) |
185
|
1 |
|
TestPaths.add_interfaces(2, switches["S3"], interfaces) |
186
|
|
|
|
187
|
1 |
|
@staticmethod |
188
|
1 |
|
def setting_links_1(interfaces, links): |
189
|
|
|
"""Generate the links in a a topology, 2nd variant.""" |
190
|
1 |
|
TestPaths.create_link("User1:1", "S1:1", interfaces, links) |
191
|
|
|
|
192
|
1 |
|
TestPaths.create_link("User1:2", "S3:1", interfaces, links) |
193
|
|
|
|
194
|
1 |
|
TestPaths.create_link("User2:1", "S2:1", interfaces, links) |
195
|
|
|
|
196
|
1 |
|
TestPaths.create_link("User3:1", "S3:2", interfaces, links) |
197
|
|
|
|
198
|
1 |
|
@staticmethod |
199
|
1 |
|
def adding_metadata_1(links): |
200
|
|
|
"""Add the links' metadata in a a topology, 2nd variant.""" |
201
|
1 |
|
TestPaths.add_metadata_to_link( |
202
|
|
|
"User1:1", |
203
|
|
|
"S1:1", |
204
|
|
|
{ |
205
|
|
|
"reliability": 3, |
206
|
|
|
"ownership": {"B": {}}, |
207
|
|
|
"delay": 30, |
208
|
|
|
"bandwidth": 20, |
209
|
|
|
}, |
210
|
|
|
links, |
211
|
|
|
) |
212
|
|
|
|
213
|
1 |
|
TestPaths.add_metadata_to_link( |
214
|
|
|
"User1:2", |
215
|
|
|
"S3:1", |
216
|
|
|
{ |
217
|
|
|
"reliability": 1, |
218
|
|
|
"ownership": {"A": {}}, |
219
|
|
|
"delay": 5, |
220
|
|
|
"bandwidth": 50, |
221
|
|
|
}, |
222
|
|
|
links, |
223
|
|
|
) |
224
|
|
|
|
225
|
1 |
|
TestPaths.add_metadata_to_link( |
226
|
|
|
"User2:1", |
227
|
|
|
"S2:1", |
228
|
|
|
{ |
229
|
|
|
"reliability": 3, |
230
|
|
|
"ownership": {"A": {}}, |
231
|
|
|
"delay": 60, |
232
|
|
|
"bandwidth": 10, |
233
|
|
|
}, |
234
|
|
|
links, |
235
|
|
|
) |
236
|
|
|
|
237
|
1 |
|
TestPaths.add_metadata_to_link( |
238
|
|
|
"User3:1", |
239
|
|
|
"S3:2", |
240
|
|
|
{ |
241
|
|
|
"reliability": 3, |
242
|
|
|
"ownership": {"B": {}}, |
243
|
|
|
"delay": 30, |
244
|
|
|
"bandwidth": 20, |
245
|
|
|
}, |
246
|
|
|
links, |
247
|
|
|
) |
248
|
|
|
|
249
|
1 |
|
@staticmethod |
250
|
1 |
|
def generate_topology_2(): |
251
|
|
|
"""Generate a predetermined topology, 3rd variant.""" |
252
|
1 |
|
switches = {} |
253
|
1 |
|
interfaces = {} |
254
|
1 |
|
links = {} |
255
|
|
|
|
256
|
1 |
|
MetadataSettings.setting_switches_interfaces(interfaces, switches) |
257
|
|
|
|
258
|
1 |
|
MetadataSettings.setting_links(interfaces, links) |
259
|
|
|
|
260
|
1 |
|
MetadataSettings.adding_metadata_2(links) |
261
|
|
|
|
262
|
1 |
|
return switches, links |
263
|
|
|
|
264
|
1 |
|
@staticmethod |
265
|
1 |
|
def adding_metadata_2(links): |
266
|
|
|
"""Add the links' metadata in a topology, 3rd variant.""" |
267
|
1 |
|
TestPaths.add_metadata_to_link( |
268
|
|
|
"User1:1", |
269
|
|
|
"S2:1", |
270
|
|
|
{"reliability": 3, "ownership": {"B": {}}, "bandwidth": 20}, |
271
|
|
|
links, |
272
|
|
|
) |
273
|
|
|
|
274
|
1 |
|
TestPaths.add_metadata_to_link( |
275
|
|
|
"User1:2", |
276
|
|
|
"S5:1", |
277
|
|
|
{"reliability": 1, "delay": 5, "bandwidth": 50}, |
278
|
|
|
links, |
279
|
|
|
) |
280
|
|
|
|
281
|
1 |
|
TestPaths.add_metadata_to_link( |
282
|
|
|
"User1:3", |
283
|
|
|
"S4:1", |
284
|
|
|
{"ownership": {"A": {}}, "delay": 60, "bandwidth": 10}, |
285
|
|
|
links, |
286
|
|
|
) |
287
|
|
|
|
288
|
1 |
|
TestPaths.add_metadata_to_link( |
289
|
|
|
"S2:2", "User2:1", {"reliability": 3, "bandwidth": 20}, links |
290
|
|
|
) |
291
|
|
|
|
292
|
1 |
|
TestPaths.add_metadata_to_link( |
293
|
|
|
"User2:2", "S4:2", {"ownership": {"B": {}}, "bandwidth": 10}, links |
294
|
|
|
) |
295
|
|
|
|
296
|
1 |
|
TestPaths.add_metadata_to_link( |
297
|
|
|
"S5:2", "S4:3", {"delay": 10, "bandwidth": 50}, links |
298
|
|
|
) |
299
|
|
|
|
300
|
1 |
|
TestPaths.add_metadata_to_link( |
301
|
|
|
"User2:3", "S4:4", {"bandwidth": 20}, links |
302
|
|
|
) |
303
|
|
|
|