blob: 51bbe38f6abee377785539156bd5dda4f4874ea3 [file] [log] [blame]
Jon Hall66e001c2015-11-12 09:45:10 -08001
2# Testing the basic intent functionality of ONOS
3
Jon Hallbc080f92017-05-24 16:29:55 -07004
Jon Hall66e001c2015-11-12 09:45:10 -08005class FUNCnetCfg:
6
7 def __init__( self ):
8 self.default = ''
9
10 def CASE1( self, main ):
11 import imp
12 import re
13
14 """
15 - Construct tests variables
16 - GIT ( optional )
17 - Checkout ONOS master branch
18 - Pull latest ONOS code
Jon Hall66e001c2015-11-12 09:45:10 -080019 """
Jon Hall66e001c2015-11-12 09:45:10 -080020 main.case( "Constructing test variables and building ONOS package" )
21 main.step( "Constructing test variables" )
22 main.caseExplanation = "This test case is mainly for loading " +\
23 "from params file, and pull and build the " +\
24 " latest ONOS package"
25 stepResult = main.FALSE
26
27 # Test variables
28 try:
29 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
30 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
31 gitBranch = main.params[ 'GIT' ][ 'branch' ]
32 main.dependencyPath = main.testOnDirectory + \
33 main.params[ 'DEPENDENCY' ][ 'path' ]
34 if main.ONOSbench.maxNodes:
35 main.maxNodes = int( main.ONOSbench.maxNodes )
36 else:
37 main.maxNodes = 0
38 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
39 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
40 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
41 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jon Hallbc080f92017-05-24 16:29:55 -070042 main.gossipTime = int( main.params[ 'SLEEP' ][ 'cfgGossip' ] )
alison15124df2016-10-06 12:04:51 -070043 main.SetNetCfgSleep = int( main.params[ 'SLEEP' ][ 'SetNetCfgSleep' ] )
Jon Hall66e001c2015-11-12 09:45:10 -080044 gitPull = main.params[ 'GIT' ][ 'pull' ]
45 main.cellData = {} # for creating cell file
46 main.hostsData = {}
47 main.nodes = []
48 main.ONOSip = []
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -070049 main.retrytimes = int( main.params[ 'RETRY' ] )
Ming Yan Shudb74bf22016-06-23 14:56:22 -070050 main.retrysleep = main.params[ 'RetrySleep' ]
Jon Hall66e001c2015-11-12 09:45:10 -080051 main.ONOSip = main.ONOSbench.getOnosIps()
52
53 # Assigning ONOS cli handles to a list
54 try:
55 for i in range( 1, main.maxNodes + 1 ):
56 main.nodes.append( getattr( main, 'ONOSrest' + str( i ) ) )
57 except AttributeError:
58 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
59 "was defined in env variables, but only " +
60 str( len( main.nodes ) ) +
61 " nodes were defined in the .topo file. " +
62 "Using " + str( len( main.nodes ) ) +
63 " nodes for the test." )
64
65 main.numCtrls = len( main.nodes )
66
67 # -- INIT SECTION, SHOULD ONLY BE RUN ONCE -- #
68 main.startUp = imp.load_source( wrapperFile1,
69 main.dependencyPath +
70 wrapperFile1 +
71 ".py" )
72
73 main.netCfg = imp.load_source( wrapperFile2,
74 main.dependencyPath +
75 wrapperFile2 +
76 ".py" )
77
78 main.topo = imp.load_source( wrapperFile3,
79 main.dependencyPath +
80 wrapperFile3 +
81 ".py" )
82
83 if main.nodes:
84 stepResult = main.TRUE
85 else:
86 main.log.error( "Did not properly created list of ONOS handle" )
87 stepResult = main.FALSE
88 except Exception as e:
Jeremy Songster2baa44e2016-06-10 10:18:40 -070089 main.log.exception( e )
Jon Hall66e001c2015-11-12 09:45:10 -080090 main.cleanup()
91 main.exit()
92
93 utilities.assert_equals( expect=main.TRUE,
94 actual=stepResult,
95 onpass="Successfully construct " +
96 "test variables ",
97 onfail="Failed to construct test variables" )
98
99 if gitPull == 'True':
100 main.step( "Building ONOS in " + gitBranch + " branch" )
101 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
102 stepResult = onosBuildResult
103 utilities.assert_equals( expect=main.TRUE,
104 actual=stepResult,
105 onpass="Successfully compiled " +
106 "latest ONOS",
107 onfail="Failed to compile " +
108 "latest ONOS" )
109 else:
110 main.log.warn( "Did not pull new code so skipping mvn " +
111 "clean install" )
112 main.ONOSbench.getVersion( report=True )
113
114 def CASE2( self, main ):
115 """
116 - Set up cell
117 - Create cell file
118 - Set cell file
119 - Verify cell file
120 - Kill ONOS process
121 - Uninstall ONOS cluster
Jon Hall66e001c2015-11-12 09:45:10 -0800122 - Install ONOS cluster
Jon Hall72ecaa02017-06-06 09:41:48 -0700123 - Verify ONOS start up
Jon Hall66e001c2015-11-12 09:45:10 -0800124 - Connect to cli
125 """
126 import time
127 main.case( "Starting up " + str( main.numCtrls ) +
128 " node(s) ONOS cluster" )
129 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
130 " node(s) ONOS cluster"
131
132 # kill off all onos processes
133 main.log.info( "Safety check, killing all ONOS processes" +
134 " before initiating environment setup" )
135
136 for i in range( main.maxNodes ):
137 main.ONOSbench.onosStop( main.ONOSip[ i ] )
138 main.ONOSbench.onosDie( main.ONOSip[ i ] )
139
140 tempOnosIp = []
141 for i in range( main.numCtrls ):
Jon Hallbc080f92017-05-24 16:29:55 -0700142 tempOnosIp.append( main.ONOSip[ i ] )
Jon Hall66e001c2015-11-12 09:45:10 -0800143
144 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
145 "temp", main.Mininet1.ip_address,
Devin Lim461f0872017-06-05 16:49:33 -0700146 main.apps, tempOnosIp, main.ONOScli1.user_name )
Jon Hall66e001c2015-11-12 09:45:10 -0800147
148 main.step( "Apply cell to environment" )
149 cellResult = main.ONOSbench.setCell( "temp" )
150 verifyResult = main.ONOSbench.verifyCell()
151 stepResult = cellResult and verifyResult
152 utilities.assert_equals( expect=main.TRUE,
153 actual=stepResult,
154 onpass="Successfully applied cell to environment",
155 onfail="Failed to apply cell to environment " )
156
157 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700158 packageResult = main.ONOSbench.buckBuild()
Jon Hall66e001c2015-11-12 09:45:10 -0800159 stepResult = packageResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=stepResult,
162 onpass="Successfully created ONOS package",
163 onfail="Failed to create ONOS package" )
164
Jon Hall66e001c2015-11-12 09:45:10 -0800165 main.step( "Uninstalling ONOS package" )
166 onosUninstallResult = main.TRUE
167 for ip in main.ONOSip:
168 onosUninstallResult = onosUninstallResult and \
169 main.ONOSbench.onosUninstall( nodeIp=ip )
170 stepResult = onosUninstallResult
171 utilities.assert_equals( expect=main.TRUE,
172 actual=stepResult,
173 onpass="Successfully uninstalled ONOS package",
174 onfail="Failed to uninstall ONOS package" )
175
176 time.sleep( main.startUpSleep )
177 main.step( "Installing ONOS package" )
178 onosInstallResult = main.TRUE
179 for i in range( main.numCtrls ):
180 onosInstallResult = onosInstallResult and \
181 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
182 stepResult = onosInstallResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully installed ONOS package",
186 onfail="Failed to install ONOS package" )
187
188 time.sleep( main.startUpSleep )
Jon Hall72ecaa02017-06-06 09:41:48 -0700189 main.step( "Set up ONOS secure SSH" )
190 secureSshResult = main.TRUE
191 for i in range( int( main.numCtrls ) ):
192 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] )
193 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
194 onpass="Test step PASS",
195 onfail="Test step FAIL" )
196
197 time.sleep( main.startUpSleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800198 main.step( "Starting ONOS service" )
199 stopResult = main.TRUE
200 startResult = main.TRUE
201 onosIsUp = main.TRUE
202
203 for i in range( main.numCtrls ):
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700204 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
205 onosIsUp = onosIsUp and isUp
206 if isUp == main.TRUE:
207 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
208 else:
209 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
210 "start ONOS again " )
Jon Hall66e001c2015-11-12 09:45:10 -0800211 stopResult = stopResult and \
212 main.ONOSbench.onosStop( main.ONOSip[ i ] )
Jon Hall66e001c2015-11-12 09:45:10 -0800213 startResult = startResult and \
214 main.ONOSbench.onosStart( main.ONOSip[ i ] )
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700215 stepResult = onosIsUp and stopResult and startResult
Jon Hall66e001c2015-11-12 09:45:10 -0800216 utilities.assert_equals( expect=main.TRUE,
217 actual=stepResult,
218 onpass="ONOS service is ready",
219 onfail="ONOS service did not start properly" )
220
221 def CASE8( self, main ):
222 """
223 Compare Topo
224 """
225 import json
226
227 main.case( "Compare ONOS Topology view to Mininet topology" )
228 main.caseExplanation = "Compare topology elements between Mininet" +\
229 " and ONOS"
230
231 main.step( "Gathering topology information" )
232 # TODO: add a parameterized sleep here
233 devicesResults = main.TRUE
234 linksResults = main.TRUE
235 hostsResults = main.TRUE
236 devices = main.topo.getAllDevices( main )
237 hosts = main.topo.getAllHosts( main )
238 ports = main.topo.getAllPorts( main )
239 links = main.topo.getAllLinks( main )
240 clusters = main.topo.getAllClusters( main )
241
242 mnSwitches = main.Mininet1.getSwitches()
243 mnLinks = main.Mininet1.getLinks()
244 mnHosts = main.Mininet1.getHosts()
245
246 main.step( "Comparing MN topology to ONOS topology" )
247 for controller in range( main.numCtrls ):
248 controllerStr = str( controller + 1 )
249 if devices[ controller ] and ports[ controller ] and\
250 "Error" not in devices[ controller ] and\
251 "Error" not in ports[ controller ]:
252
253 currentDevicesResult = main.Mininet1.compareSwitches(
254 mnSwitches,
255 json.loads( devices[ controller ] ),
256 json.loads( ports[ controller ] ) )
257 else:
258 currentDevicesResult = main.FALSE
259 utilities.assert_equals( expect=main.TRUE,
260 actual=currentDevicesResult,
261 onpass="ONOS" + controllerStr +
262 " Switches view is correct",
263 onfail="ONOS" + controllerStr +
264 " Switches view is incorrect" )
265
266 if links[ controller ] and "Error" not in links[ controller ]:
267 currentLinksResult = main.Mininet1.compareLinks(
268 mnSwitches, mnLinks,
269 json.loads( links[ controller ] ) )
270 else:
271 currentLinksResult = main.FALSE
272 utilities.assert_equals( expect=main.TRUE,
273 actual=currentLinksResult,
274 onpass="ONOS" + controllerStr +
275 " links view is correct",
276 onfail="ONOS" + controllerStr +
277 " links view is incorrect" )
278
279 if hosts[ controller ] or "Error" not in hosts[ controller ]:
280 currentHostsResult = main.Mininet1.compareHosts(
281 mnHosts,
282 json.loads( hosts[ controller ] ) )
283 else:
284 currentHostsResult = main.FALSE
285 utilities.assert_equals( expect=main.TRUE,
286 actual=currentHostsResult,
287 onpass="ONOS" + controllerStr +
288 " hosts exist in Mininet",
289 onfail="ONOS" + controllerStr +
290 " hosts don't match Mininet" )
291
292 def CASE9( self, main ):
Jon Hallbc080f92017-05-24 16:29:55 -0700293 """
Jon Hall66e001c2015-11-12 09:45:10 -0800294 Report errors/warnings/exceptions
Jon Hallbc080f92017-05-24 16:29:55 -0700295 """
Jon Hall66e001c2015-11-12 09:45:10 -0800296 main.log.info( "Error report: \n" )
297 main.ONOSbench.logReport(
Jon Hallbc080f92017-05-24 16:29:55 -0700298 globalONOSip[ 0 ],
299 [ "INFO", "WARN", "ERROR", "Except" ],
Jon Hall66e001c2015-11-12 09:45:10 -0800300 "s" )
Jon Hallbc080f92017-05-24 16:29:55 -0700301 # main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
Jon Hall66e001c2015-11-12 09:45:10 -0800302
303 def CASE10( self, main ):
304 """
305 Start Mininet topology with OF 1.0 switches
306 """
307 main.OFProtocol = "1.0"
308 main.log.report( "Start Mininet topology with OF 1.0 switches" )
309 main.case( "Start Mininet topology with OF 1.0 switches" )
310 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
311 "switches to test intents, exits out if " +\
312 "topology did not start correctly"
313
314 main.step( "Starting Mininet topology with OF 1.0 switches" )
Jon Hall53c5e662016-04-13 16:06:56 -0700315 args = "--controller none --switch ovs,protocols=OpenFlow10"
Jon Hallbc080f92017-05-24 16:29:55 -0700316 switches = int( main.params[ 'MININET' ][ 'switch' ] )
Jon Hall66e001c2015-11-12 09:45:10 -0800317 cmd = "mn --topo linear,{} {}".format( switches, args )
Jon Hallbc080f92017-05-24 16:29:55 -0700318 topoResult = main.Mininet1.startNet( mnCmd=cmd )
Jon Hall66e001c2015-11-12 09:45:10 -0800319 stepResult = topoResult
320 utilities.assert_equals( expect=main.TRUE,
321 actual=stepResult,
322 onpass="Successfully loaded topology",
323 onfail="Failed to load topology" )
324 # Exit if topology did not load properly
325 if not topoResult:
326 main.cleanup()
327 main.exit()
328
329 def CASE11( self, main ):
330 """
331 Start Mininet topology with OF 1.3 switches
332 """
333 import re
334 main.OFProtocol = "1.3"
335 main.log.report( "Start Mininet topology with OF 1.3 switches" )
336 main.case( "Start Mininet topology with OF 1.3 switches" )
337 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
338 "switches to test intents, exits out if " +\
339 "topology did not start correctly"
340
341 main.step( "Starting Mininet topology with OF 1.3 switches" )
Jon Hall53c5e662016-04-13 16:06:56 -0700342 args = "--controller none --switch ovs,protocols=OpenFlow13"
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700343 switches = int( main.params[ 'MININET' ][ 'switch' ] )
Jon Hall66e001c2015-11-12 09:45:10 -0800344 cmd = "mn --topo linear,{} {}".format( switches, args )
Jon Hallbc080f92017-05-24 16:29:55 -0700345 topoResult = main.Mininet1.startNet( mnCmd=cmd )
Jon Hall66e001c2015-11-12 09:45:10 -0800346 stepResult = topoResult
347 utilities.assert_equals( expect=main.TRUE,
348 actual=stepResult,
349 onpass="Successfully loaded topology",
350 onfail="Failed to load topology" )
351 # Exit if topology did not load properly
352 if not topoResult:
353 main.cleanup()
354 main.exit()
355
356 tempONOSip = []
357 for i in range( main.numCtrls ):
358 tempONOSip.append( main.ONOSip[ i ] )
359
360 swList = [ "s" + str( i ) for i in range( 1, switches + 1 ) ]
361 assignResult = main.Mininet1.assignSwController( sw=swList,
362 ip=tempONOSip,
363 port='6653' )
364 if not assignResult:
365 main.cleanup()
366 main.exit()
367
368 assignResult = main.TRUE
369 for sw in swList:
370 response = main.Mininet1.getSwController( "s" + str( i ) )
371 main.log.info( "Response is " + str( response ) )
372 for ip in tempONOSip:
373 if re.search( "tcp:" + ip, response ):
374 assignResult = assignResult and main.TRUE
375 else:
376 assignResult = assignResult and main.FALSE
377 stepResult = assignResult
378 utilities.assert_equals( expect=main.TRUE,
379 actual=stepResult,
380 onpass="Successfully assigned switches" +
381 "to controller",
382 onfail="Failed to assign switches to " +
383 "controller" )
384
385 def CASE14( self, main ):
386 """
387 Stop mininet
388 """
389 main.log.report( "Stop Mininet topology" )
390 main.case( "Stop Mininet topology" )
391 main.caseExplanation = "Stopping the current mininet topology " +\
392 "to start up fresh"
393
394 main.step( "Stopping Mininet Topology" )
Jon Hallbc080f92017-05-24 16:29:55 -0700395 topoResult = main.Mininet1.stopNet()
Jon Hall66e001c2015-11-12 09:45:10 -0800396 stepResult = topoResult
397 utilities.assert_equals( expect=main.TRUE,
398 actual=stepResult,
399 onpass="Successfully stop mininet",
400 onfail="Failed to stop mininet" )
401 # Exit if topology did not load properly
402 if not topoResult:
403 main.cleanup()
404 main.exit()
405
406 def CASE20( self, main ):
407 """
408 Add some device configurations and then check they are distributed
409 to all nodes
410 """
alison15124df2016-10-06 12:04:51 -0700411 import time
Pratik Parabc6083c22017-04-27 13:24:41 -0700412 import json
413 import os
Jon Hall66e001c2015-11-12 09:45:10 -0800414 main.case( "Add Network configurations to the cluster" )
415 main.caseExplanation = "Add Network Configurations for devices" +\
416 " not discovered yet. One device is allowed" +\
417 ", the other disallowed."
Jon Hallbc080f92017-05-24 16:29:55 -0700418 pprint = main.nodes[ 0 ].pprint
Jon Hall66e001c2015-11-12 09:45:10 -0800419
420 main.step( "Add Net Cfg for switch1" )
Pratik Parab6f418632017-04-25 17:05:50 -0700421
Pratik Parab6f418632017-04-25 17:05:50 -0700422 try:
423 with open( os.path.dirname( main.testFile ) + '/dependencies/s1Json', 'r' ) as s1Jsondata:
424 s1Json = json.load( s1Jsondata )
425 except IOError:
426 main.log.exception( "s1Json File not found." )
Pratik Parabc6083c22017-04-27 13:24:41 -0700427 main.cleanup()
428 main.exit()
Pratik Parab6f418632017-04-25 17:05:50 -0700429 main.log.info( "s1Json:" + str( s1Json ) )
430
Jon Hall66e001c2015-11-12 09:45:10 -0800431 main.s1Json = s1Json
432 setS1Allow = main.ONOSrest1.setNetCfg( s1Json,
433 subjectClass="devices",
434 subjectKey="of:0000000000000001",
435 configKey="basic" )
436 s1Result = False
alison15124df2016-10-06 12:04:51 -0700437 #Wait 5 secs after set up netCfg
438 time.sleep( main.SetNetCfgSleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800439 if setS1Allow:
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700440 getS1 = utilities.retry( f=main.ONOSrest1.getNetCfg,
441 retValue=False,
442 kwargs={"subjectClass":"devices",
443 "subjectKey" : "of:0000000000000001",
444 "configKey" : "basic"},
445 attempts=main.retrytimes,
446 sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800447 onosCfg = pprint( getS1 )
448 sentCfg = pprint( s1Json )
449 if onosCfg == sentCfg:
alison15124df2016-10-06 12:04:51 -0700450 main.log.info( "ONOS NetCfg match what was sent" )
Jon Hall66e001c2015-11-12 09:45:10 -0800451 s1Result = True
452 else:
453 main.log.error( "ONOS NetCfg doesn't match what was sent" )
454 main.log.debug( "ONOS config: {}".format( onosCfg ) )
455 main.log.debug( "Sent config: {}".format( sentCfg ) )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700456 utilities.retry( f=main.ONOSrest1.getNetCfg, retValue=False, attempts=main.retrytimes, sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800457 utilities.assert_equals( expect=True,
458 actual=s1Result,
459 onpass="Net Cfg added for device s1",
460 onfail="Net Cfg for device s1 not correctly set" )
461
462 main.step( "Add Net Cfg for switch3" )
Pratik Parab6f418632017-04-25 17:05:50 -0700463
464 try:
465 with open( os.path.dirname( main.testFile ) + '/dependencies/s3Json', 'r' ) as s3Jsondata:
466 s3Json = json.load( s3Jsondata )
467 except IOError:
468 main.log.exception( "s3Json File not found" )
Pratik Parabc6083c22017-04-27 13:24:41 -0700469 main.cleanup()
470 main.exit()
Jon Hallbc080f92017-05-24 16:29:55 -0700471 main.log.info( "s3Json:" + str( s3Json ) )
Pratik Parab6f418632017-04-25 17:05:50 -0700472
Jon Hall66e001c2015-11-12 09:45:10 -0800473 main.s3Json = s3Json
474 setS3Disallow = main.ONOSrest1.setNetCfg( s3Json,
475 subjectClass="devices",
476 subjectKey="of:0000000000000003",
477 configKey="basic" )
478 s3Result = False
alison15124df2016-10-06 12:04:51 -0700479 time.sleep( main.SetNetCfgSleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800480 if setS3Disallow:
481 # Check what we set is what is in ONOS
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700482 getS3 = utilities.retry( f=main.ONOSrest1.getNetCfg,
483 retValue=False,
484 kwargs={"subjectClass": "devices",
485 "subjectKey": "of:0000000000000003",
486 "configKey": "basic"},
487 attempts=main.retrytimes,
488 sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800489 onosCfg = pprint( getS3 )
490 sentCfg = pprint( s3Json )
491 if onosCfg == sentCfg:
Jon Hallbc080f92017-05-24 16:29:55 -0700492 main.log.info( "ONOS NetCfg match what was sent" )
Jon Hall66e001c2015-11-12 09:45:10 -0800493 s3Result = True
494 else:
495 main.log.error( "ONOS NetCfg doesn't match what was sent" )
496 main.log.debug( "ONOS config: {}".format( onosCfg ) )
497 main.log.debug( "Sent config: {}".format( sentCfg ) )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700498 utilities.retry( f=main.ONOSrest1.getNetCfg, retValue=False, attempts=main.retrytimes, sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800499 utilities.assert_equals( expect=True,
500 actual=s3Result,
501 onpass="Net Cfg added for device s3",
502 onfail="Net Cfg for device s3 not correctly set" )
503 main.netCfg.compareCfg( main, main.gossipTime )
504
505 def CASE21( self, main ):
506 """
507 Initial check of devices
508 """
509 import json
510 try:
511 assert main.s1Json, "s1Json not defined"
512 except AssertionError:
513 main.log.exception( "Case Prerequisites not set: " )
514 main.cleanup()
515 main.exit()
516 main.case( "Check Devices After they initially connect to ONOS" )
517
518 main.netCfg.compareCfg( main )
519
520 main.step( "ONOS should only show devices S1, S2, and S4" )
521 devices = main.ONOSrest1.devices()
522 main.log.debug( main.ONOSrest1.pprint( devices ) )
523 allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2, 4 ] ]
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700524 main.log.debug( allowedDevices )
Jon Hall66e001c2015-11-12 09:45:10 -0800525 onosDevices = []
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700526 try:
527 for sw in json.loads( devices ):
Jon Hallbc080f92017-05-24 16:29:55 -0700528 onosDevices.append( str( sw[ 'id' ] ) )
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700529 onosDevices.sort()
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700530 main.log.debug( onosDevices )
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700531 except( TypeError, ValueError ):
532 main.log.error( "Problem loading devices" )
Jon Hall66e001c2015-11-12 09:45:10 -0800533 utilities.assert_equals( expect=allowedDevices,
534 actual=onosDevices,
535 onpass="Only allowed devices are in ONOS",
536 onfail="ONOS devices doesn't match the list" +
537 " of allowed devices" )
Jon Hall66e001c2015-11-12 09:45:10 -0800538 main.step( "Check device annotations" )
539 keys = [ 'name', 'owner', 'rackAddress' ]
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700540 try:
541 for sw in json.loads( devices ):
Jon Hallbc080f92017-05-24 16:29:55 -0700542 if "of:0000000000000001" in sw[ 'id' ]:
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700543 s1Correct = True
544 for k in keys:
Jon Hallbc080f92017-05-24 16:29:55 -0700545 if str( sw.get( 'annotations', {} ).get( k ) ) != str( main.s1Json[ k ] ):
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700546 s1Correct = False
547 main.log.debug( "{} is wrong on s1".format( k ) )
548 if not s1Correct:
549 main.log.error( "Annotations for s1 are incorrect: {}".format( sw ) )
550 except( TypeError, ValueError ):
551 main.log.error( "Problem loading devices" )
552 s1Correct = False
Jon Hall66e001c2015-11-12 09:45:10 -0800553 try:
554 stepResult = s1Correct
555 except NameError:
556 stepResult = False
557 main.log.error( "s1 not found in devices" )
558 utilities.assert_equals( expect=True,
559 actual=stepResult,
560 onpass="Configured device's annotations are correct",
561 onfail="Incorrect annotations for configured devices." )
562
563 def CASE22( self, main ):
564 """
565 Add some device configurations for connected devices and then check
566 they are distributed to all nodes
567 """
568 main.case( "Add Network configurations for connected devices to the cluster" )
569 main.caseExplanation = "Add Network Configurations for discovered " +\
570 "devices. One device is allowed" +\
571 ", the other disallowed."
Jon Hallbc080f92017-05-24 16:29:55 -0700572 pprint = main.nodes[ 0 ].pprint
Jon Hall66e001c2015-11-12 09:45:10 -0800573
574 main.step( "Add Net Cfg for switch2" )
Pratik Parab6f418632017-04-25 17:05:50 -0700575 try:
576 with open( os.path.dirname( main.testFile ) + '/dependencies/s2Json', 'r' ) as s2Jsondata:
577 s2Json = json.load( s2Jsondata )
578 except IOError:
579 main.log.exception( "s2Json File not found" )
Pratik Parabc6083c22017-04-27 13:24:41 -0700580 main.cleanup()
581 main.exit()
Pratik Parab6f418632017-04-25 17:05:50 -0700582 main.log.info( "s2Json:" + str( s2Json ) )
Jon Hall66e001c2015-11-12 09:45:10 -0800583 main.s2Json = s2Json
584 setS2Allow = main.ONOSrest2.setNetCfg( s2Json,
585 subjectClass="devices",
586 subjectKey="of:0000000000000002",
587 configKey="basic" )
588 s2Result = False
589 if setS2Allow:
590 # Check what we set is what is in ONOS
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700591 getS2 = utilities.retry( f=main.ONOSrest2.getNetCfg,
592 retValue=False,
593 kwargs={"subjectClass": "devices",
594 "subjectKey": "of:0000000000000002",
595 "configKey": "basic"},
596 attempts=main.retrytimes,
597 sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800598 onosCfg = pprint( getS2 )
599 sentCfg = pprint( s2Json )
600 if onosCfg == sentCfg:
601 s2Result = True
602 else:
603 main.log.error( "ONOS NetCfg doesn't match what was sent" )
604 main.log.debug( "ONOS config: {}".format( onosCfg ) )
605 main.log.debug( "Sent config: {}".format( sentCfg ) )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700606 utilities.retry( f=main.ONOSrest2.getNetCfg, retValue=False, attempts=main.retrytimes, sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800607 utilities.assert_equals( expect=True,
608 actual=s2Result,
609 onpass="Net Cfg added for device s2",
610 onfail="Net Cfg for device s2 not correctly set" )
611
612 main.step( "Add Net Cfg for switch4" )
Pratik Parab6f418632017-04-25 17:05:50 -0700613
614 try:
615 with open( os.path.dirname( main.testFile ) + '/dependencies/s4Json', 'r' ) as s4Jsondata:
616 s4Json = json.load( s4Jsondata )
617 except IOError:
618 main.log.exception( "s4Json File not found" )
Pratik Parabc6083c22017-04-27 13:24:41 -0700619 main.cleanup()
620 main.exit()
Pratik Parab6f418632017-04-25 17:05:50 -0700621 main.log.info( "s4Json:" + str( s4Json ) )
Jon Hall66e001c2015-11-12 09:45:10 -0800622 main.s4Json = s4Json
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700623 setS4Disallow = main.ONOSrest3.setNetCfg( s4Json,
Jon Hall66e001c2015-11-12 09:45:10 -0800624 subjectClass="devices",
625 subjectKey="of:0000000000000004",
626 configKey="basic" )
627 s4Result = False
628 if setS4Disallow:
629 # Check what we set is what is in ONOS
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700630 getS4 = utilities.retry( f=main.ONOSrest3.getNetCfg,
631 retValue=False,
632 kwargs={"subjectClass": "devices",
633 "subjectKey": "of:0000000000000004",
634 "configKey": "basic"},
635 attempts=main.retrytimes,
636 sleep=main.retrysleep )
637
Jon Hall66e001c2015-11-12 09:45:10 -0800638 onosCfg = pprint( getS4 )
639 sentCfg = pprint( s4Json )
640 if onosCfg == sentCfg:
641 s4Result = True
642 else:
643 main.log.error( "ONOS NetCfg doesn't match what was sent" )
644 main.log.debug( "ONOS config: {}".format( onosCfg ) )
645 main.log.debug( "Sent config: {}".format( sentCfg ) )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700646 main.step( "Retrying main.ONOSrest3.getNetCfg" )
647 utilities.retry( f=main.ONOSrest3.getNetCfg, retValue=False, attempts=main.retrytimes, sleep=main.retrysleep )
Jon Hall66e001c2015-11-12 09:45:10 -0800648 utilities.assert_equals( expect=True,
649 actual=s4Result,
650 onpass="Net Cfg added for device s4",
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700651 onfail="Net Cfg for device s4 not correctly set" )
Jon Hall66e001c2015-11-12 09:45:10 -0800652 main.netCfg.compareCfg( main, main.gossipTime )
653
654 def CASE23( self, main ):
655 """
656 Check of devices after all Network Configurations are set
657 """
658 import json
659 try:
660 assert main.s1Json, "s1Json not defined"
661 assert main.s2Json, "s2Json not defined"
662 except AssertionError:
663 main.log.exception( "Case Prerequisites not set: " )
664 main.cleanup()
665 main.exit()
666 main.case( "Check Devices after all configurations are set" )
667
668 main.netCfg.compareCfg( main )
669
670 main.step( "ONOS should only show devices S1 and S2" )
671 devices = main.ONOSrest1.devices()
672 main.log.debug( main.ONOSrest1.pprint( devices ) )
673 allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2 ] ]
674 onosDevices = []
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700675 try:
676 for sw in json.loads( devices ):
677 onosDevices.append( str( sw.get( 'id' ) ) )
678 onosDevices.sort()
679 failMsg = "ONOS devices doesn't match the list of allowed devices.\n"
680 failMsg += "Expected devices: {}\nActual devices: {}".format( allowedDevices,
681 onosDevices )
682 except( TypeError, ValueError ):
683 main.log.error( "Problem loading devices" )
Jon Hall66e001c2015-11-12 09:45:10 -0800684 utilities.assert_equals( expect=allowedDevices,
685 actual=onosDevices,
686 onpass="Only allowed devices are in ONOS",
687 onfail=failMsg )
688
689 main.step( "Check device annotations" )
690 keys = [ 'name', 'owner', 'rackAddress' ]
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700691 try:
692 for sw in json.loads( devices ):
693 if "of:0000000000000001" in sw.get( 'id' ):
694 s1Correct = True
695 for k in keys:
Jon Hallbc080f92017-05-24 16:29:55 -0700696 if str( sw.get( 'annotations', {} ).get( k ) ) != str( main.s1Json[ k ] ):
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700697 s1Correct = False
698 main.log.debug( "{} is wrong on s1".format( k ) )
699 if not s1Correct:
700 main.log.error( "Annotations for s1 are incorrect: {}".format( sw ) )
Jon Hallbc080f92017-05-24 16:29:55 -0700701 elif "of:0000000000000002" in sw[ 'id' ]:
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700702 s2Correct = True
703 for k in keys:
Jon Hallbc080f92017-05-24 16:29:55 -0700704 if str( sw.get( 'annotations', {} ).get( k ) ) != str( main.s2Json[ k ] ):
Jeremy Songster5c3fdb42016-04-27 12:19:27 -0700705 s2Correct = False
706 main.log.debug( "{} is wrong on s2".format( k ) )
707 if not s2Correct:
708 main.log.error( "Annotations for s2 are incorrect: {}".format( sw ) )
709 except( TypeError, ValueError ):
710 main.log.error( "Problem loading devices" )
711 stepResult = False
Jon Hall66e001c2015-11-12 09:45:10 -0800712 try:
713 stepResult = s1Correct and s2Correct
714 except NameError:
715 stepResult = False
716 main.log.error( "s1 and/or s2 not found in devices" )
717 utilities.assert_equals( expect=True,
718 actual=stepResult,
719 onpass="Configured device's annotations are correct",
720 onfail="Incorrect annotations for configured devices." )
721
722 def CASE24( self, main ):
723 """
724 Testing removal of configurations
725 """
Jon Hall541b8e02015-12-14 19:29:01 -0800726 import time
Jon Hall66e001c2015-11-12 09:45:10 -0800727 try:
728 assert main.s1Json, "s1Json not defined"
729 assert main.s2Json, "s2Json not defined"
730 assert main.s3Json, "s3Json not defined"
731 assert main.s4Json, "s4Json not defined"
732 except AssertionError:
733 main.log.exception( "Case Prerequisites not set: " )
734 main.cleanup()
735 main.exit()
736 main.case( "Testing removal of configurations" )
737 main.step( "Remove 'allowed' configuration from all devices" )
738
739 s1Json = main.s1Json # NOTE: This is a reference
740 try:
Jon Hallbc080f92017-05-24 16:29:55 -0700741 del s1Json[ 'allowed' ]
Jon Hall66e001c2015-11-12 09:45:10 -0800742 except KeyError:
743 main.log.exception( "Key not found" )
744 setS1 = main.ONOSrest1.setNetCfg( s1Json,
745 subjectClass="devices",
746 subjectKey="of:0000000000000001",
747 configKey="basic" )
748
749 s2Json = main.s2Json # NOTE: This is a reference
750 try:
Jon Hall541b8e02015-12-14 19:29:01 -0800751 time.sleep( main.gossipTime )
Jon Hallbc080f92017-05-24 16:29:55 -0700752 del s2Json[ 'allowed' ]
Jon Hall66e001c2015-11-12 09:45:10 -0800753 except KeyError:
754 main.log.exception( "Key not found" )
755 setS2 = main.ONOSrest2.setNetCfg( s2Json,
756 subjectClass="devices",
757 subjectKey="of:0000000000000002",
758 configKey="basic" )
759
760 s3Json = main.s3Json # NOTE: This is a reference
761 try:
Jon Hall541b8e02015-12-14 19:29:01 -0800762 time.sleep( main.gossipTime )
Jon Hallbc080f92017-05-24 16:29:55 -0700763 del s3Json[ 'allowed' ]
Jon Hall66e001c2015-11-12 09:45:10 -0800764 except KeyError:
765 main.log.exception( "Key not found" )
766 setS3 = main.ONOSrest3.setNetCfg( s3Json,
767 subjectClass="devices",
768 subjectKey="of:0000000000000003",
769 configKey="basic" )
770
771 s4Json = main.s4Json # NOTE: This is a reference
772 try:
Jon Hall541b8e02015-12-14 19:29:01 -0800773 time.sleep( main.gossipTime )
Jon Hallbc080f92017-05-24 16:29:55 -0700774 del s4Json[ 'allowed' ]
Jon Hall66e001c2015-11-12 09:45:10 -0800775 except KeyError:
776 main.log.exception( "Key not found" )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700777 setS4 = main.ONOSrest3.setNetCfg( s4Json,
Jon Hall66e001c2015-11-12 09:45:10 -0800778 subjectClass="devices",
779 subjectKey="of:0000000000000004",
780 configKey="basic" )
781 removeAllowed = setS1 and setS2 and setS3 and setS4
782 utilities.assert_equals( expect=main.TRUE,
783 actual=removeAllowed,
784 onpass="Successfully removed 'allowed' config from devices",
785 onfail="Failed to remove the 'allowed' config key." )
786
787 main.netCfg.compareCfg( main, main.gossipTime )
788
789 main.step( "Delete basic config for s1 and s2" )
790 removeS1 = main.ONOSrest1.removeNetCfg( subjectClass="devices",
791 subjectKey="of:0000000000000001",
792 configKey="basic" )
793 removeS2 = main.ONOSrest2.removeNetCfg( subjectClass="devices",
794 subjectKey="of:0000000000000002",
795 configKey="basic" )
796 removeSingles = removeS1 and removeS2
797 utilities.assert_equals( expect=main.TRUE,
798 actual=removeSingles,
799 onpass="Successfully removed S1 and S2 basic config",
800 onfail="Failed to removed S1 and S2 basic config" )
801
802 main.netCfg.compareCfg( main, main.gossipTime )
803
804 main.step( "Delete the net config for S3" )
805 removeS3 = main.ONOSrest3.removeNetCfg( subjectClass="devices",
806 subjectKey="of:0000000000000003" )
807 utilities.assert_equals( expect=main.TRUE,
808 actual=removeS3,
809 onpass="Successfully removed S3's config",
810 onfail="Failed to removed S3's config" )
811
812 main.netCfg.compareCfg( main, main.gossipTime )
813
814 main.step( "Delete the net config for all devices" )
815 remove = main.ONOSrest3.removeNetCfg( subjectClass="devices" )
816 utilities.assert_equals( expect=main.TRUE,
817 actual=remove,
818 onpass="Successfully removed device config",
819 onfail="Failed to remove device config" )
820
821 main.netCfg.compareCfg( main, main.gossipTime )
822
823 main.step( "Assert the net config for devices is empty" )
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700824
825 get = utilities.retry( f=main.ONOSrest3.getNetCfg,
826 retValue = False,
827 kwargs={"subjectClass":"devices"},
828 sleep=main.retrysleep,
829 attempts=main.retrytimes )
830
Jon Hall66e001c2015-11-12 09:45:10 -0800831 utilities.assert_equals( expect='{}',
832 actual=get,
833 onpass="Successfully removed device config",
834 onfail="Failed to remove device config" )
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700835
836 def CASE25( self, main ):
837 """
838 Use network-cfg.json to configure devices during ONOS startup
839 """
840 main.case( "Preparing network-cfg.json to load configurations" )
841 main.step( "Moving network-cfg.json to $ONOS_ROOT/tools/package/config/" )
842 prestartResult = main.TRUE
843 srcPath = "~/OnosSystemTest/TestON/tests/FUNC/FUNCnetCfg/dependencies/network-cfg.json"
844 dstPath = "~/onos/tools/package/config/network-cfg.json"
845 prestartResult = main.ONOSbench.scp( main.ONOSbench, srcPath, dstPath, direction="to" )
846 utilities.assert_equals( expect=main.TRUE,
847 actual=prestartResult,
848 onpass="Successfully copied network-cfg.json to target directory",
849 onfail="Failed to copy network-cfg.json to target directory" )
850
851 def CASE26( self, main ):
852 """
853 Check to see that pre-startup configurations were set correctly
854 """
855 import json
856 main.case( "Check to see if the pre-startup configurations were set, then remove their allowed status" )
857 main.step( "Checking configurations for Switches 5 and 6" )
Jon Hallbc080f92017-05-24 16:29:55 -0700858 main.step( "ONOS should only show devices S1, S2, S4, and S5" ) # and S6
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700859 devices = main.ONOSrest1.devices()
860 main.log.debug( main.ONOSrest1.pprint( devices ) )
Jon Hallbc080f92017-05-24 16:29:55 -0700861 allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2, 4, 5 ] ] # 6
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700862 main.log.debug( allowedDevices )
863 onosDevices = []
864 try:
865 for sw in json.loads( devices ):
Jon Hallbc080f92017-05-24 16:29:55 -0700866 onosDevices.append( str( sw[ 'id' ] ) )
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700867 onosDevices.sort()
868 main.log.debug( onosDevices )
869 except( TypeError, ValueError ):
870 main.log.error( "Problem loading devices" )
871 utilities.assert_equals( expect=allowedDevices,
872 actual=onosDevices,
873 onpass="Only allowed devices are in ONOS",
874 onfail="ONOS devices doesn't match the list" +
875 " of allowed devices" )
876
877 main.step( "Removing allowed status from Switches 5 and 6" )
Pratik Parab6f418632017-04-25 17:05:50 -0700878 try:
879 with open( os.path.dirname( main.testFile ) + '/dependencies/s5Json', 'r' ) as s5Jsondata:
880 main.s5Json = json.load( s5Jsondata )
881 except IOError:
882 main.log.exception( "s5Json File not found" )
Pratik Parabc6083c22017-04-27 13:24:41 -0700883 main.cleanup()
884 main.exit()
Pratik Parab6f418632017-04-25 17:05:50 -0700885 main.log.info( "s5Json:" + str( main.s5Json ) )
886
887 try:
888 with open( os.path.dirname( main.testFile ) + '/dependencies/s6Json', 'r' ) as s6Jsondata:
889 main.s6Json = json.load( s6Jsondata )
890 except IOError:
891 main.log.exception( "s6Json File not found" )
Pratik Parabc6083c22017-04-27 13:24:41 -0700892 main.cleanup()
893 main.exit()
Pratik Parab6f418632017-04-25 17:05:50 -0700894 main.log.info( "s6Json:" + str( main.s6Json ) )
895
Jeremy Songster2baa44e2016-06-10 10:18:40 -0700896 s5Json = main.s5Json
897 setS1 = main.ONOSrest1.setNetCfg( s5Json,
898 subjectClass="devices",
899 subjectKey="of:0000000000000005",
900 configKey="basic" )
901
902 s6Json = main.s6Json
903 setS1 = main.ONOSrest1.setNetCfg( s6Json,
904 subjectClass="devices",
905 subjectKey="of:0000000000000006",
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700906 configKey="basic" )
907
908 def CASE27( self, main ):
909 """
Jon Hallbc080f92017-05-24 16:29:55 -0700910 1 ) A = get /network/configuration
911 2 ) Post A
912 3 ) Compare A with ONOS
913 4 ) Modify A so S6 is disallowed
914 5 ) Check
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700915
916 """
917 import json
Jon Hallbc080f92017-05-24 16:29:55 -0700918 pprint = main.nodes[ 0 ].pprint
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700919 main.case( "Posting network configurations to the top level web resource" )
920 main.step( "Get json object from Net Cfg" )
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700921 getinfo = utilities.retry( f=main.ONOSrest1.getNetCfg,
922 retValue=False,
923 sleep=main.retrysleep,
924 attempts=main.retrytimes )
925
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700926 main.log.debug( getinfo )
927 main.step( "Posting json object to Net Cfg" )
928 postinfo = main.ONOSrest1.setNetCfg( json.loads( getinfo ) )
929 main.step( "Compare device with ONOS" )
930 main.netCfg.compareCfg( main )
Jon Hallbc080f92017-05-24 16:29:55 -0700931 main.step( "ONOS should only show devices S1, S2, S4, S5 and S6" )
932 devices = main.ONOSrest1.devices()
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700933 main.log.debug( main.ONOSrest1.pprint( devices ) )
934 allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2, 4, 5, 6 ] ]
935 onosDevices = []
936 try:
937 for sw in json.loads( devices ):
938 onosDevices.append( str( sw.get( 'id' ) ) )
Jon Hallbc080f92017-05-24 16:29:55 -0700939 onosDevices.sort()
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700940 failMsg = "ONOS devices doesn't match the list of allowed devices. \n"
941 failMsg += "Expected devices: {}\nActual devices: {}".format( allowedDevices, onosDevices )
942 except( TypeError, ValueError ):
943 main.log.error( "Problem loading devices" )
944 utilities.assert_equals( expect=allowedDevices, actual=onosDevices,
945 onpass="Only allowed devices are in ONOS", onfail=failMsg )
946
947 main.step( "Modify json object so S6 is disallowed" )
948 main.s6Json = { "allowed": False }
949 s6Json = main.s6Json
950 setS6Disallow = main.ONOSrest1.setNetCfg( s6Json, subjectClass="devices",
951 subjectKey="of:0000000000000006", configKey="basic" )
952 s6Result = False
953 if setS6Disallow:
Jeremy Ronquillo4a30ffe2017-06-07 11:36:35 -0700954 getS6 = utilities.retry( f=main.ONOSrest1.getNetCfg,
955 retValue=False,
956 kwargs={"subjectClass":"devices",
957 "subjectKey" : "of:0000000000000006",
958 "configKey" : "basic"},
959 sleep=main.retrysleep,
960 attempts=main.retrytimes )
Ming Yan Shudb74bf22016-06-23 14:56:22 -0700961 onosCfg = pprint( getS6 )
962 sentCfg = pprint( s6Json )
963 if onosCfg == sentCfg:
964 s6Result = True
965 else:
966 main.log.error( "ONOS NetCfg doesn't match what was sent" )
967 main.log.debug( "ONOS config: {}".format( onosCfg ) )
968 main.log.debug( "Sent config: {}".format( sentCfg ) )
969 utilities.retry( f=main.ONOSrest1.getNetCfg, retValue=False, attempts=main.retrytimes, sleep=main.retrysleep )
970 utilities.assert_equals( expect=True, actual=s6Result,
971 onpass="Net Cfg added for devices s6",
972 onfail="Net Cfg for device s6 not correctly set" )