blob: ab4d3d0bab3453457bb383969eee705f212584a6 [file] [log] [blame]
acsmars51a7fe02015-10-29 18:33:32 -07001# Testing the basic intent functionality of ONOS
2
3class FUNCoptical:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
10 import imp
11 import re
12
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
25 main.caseExplanation = "This test case is mainly for loading " +\
26 "from params file, and pull and build the " +\
27 " latest ONOS package"
28 stepResult = main.FALSE
29
30 # Test variables
31 try:
32 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
33 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
38 if main.ONOSbench.maxNodes:
39 main.maxNodes = int( main.ONOSbench.maxNodes )
40 else:
41 main.maxNodes = 0
42 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
43 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
44 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
45 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
46 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
47 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
48 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
49 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
50 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
51 gitPull = main.params[ 'GIT' ][ 'pull' ]
52 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
53 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
54 main.cellData = {} # For creating cell file
55 main.hostsData = {}
56 main.CLIs = []
57 main.ONOSip = [] # List of IPs of active ONOS nodes. CASE 2
58 main.activeONOSip = []
59 main.assertReturnString = '' # Assembled assert return string
60
61 main.ONOSip = main.ONOSbench.getOnosIps()
62
63 # Assigning ONOS cli handles to a list
64 for i in range( 1, main.maxNodes + 1 ):
65 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
66
67 # -- INIT SECTION, ONLY RUNS ONCE -- #
68 main.startUp = imp.load_source( wrapperFile1,
69 main.dependencyPath +
70 wrapperFile1 +
71 ".py" )
72
73 main.intentFunction = 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.CLIs:
84 stepResult = main.TRUE
85 else:
86 main.log.error( "Did not properly created list of ONOS CLI handle" )
87 stepResult = main.FALSE
88 except Exception as e:
89 main.log.exception(e)
90 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
122 - Verify ONOS start up
123 - Install ONOS cluster
124 - Connect to cli
125 """
126
127 # main.scale[ 0 ] determines the current number of ONOS controller
128 main.numCtrls = int( main.scale[ 0 ] )
Jeremye4bc7132016-03-30 14:04:01 -0700129 main.flowCompiler = "Flow Rules"
acsmars51a7fe02015-10-29 18:33:32 -0700130
131 main.case( "Starting up " + str( main.numCtrls ) +
132 " node(s) ONOS cluster" )
133 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
134 " node(s) ONOS cluster"
135
136
137
138 #kill off all onos processes
139 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800140 " before initiating environment setup" )
acsmars51a7fe02015-10-29 18:33:32 -0700141
142 for i in range( main.maxNodes ):
143 main.ONOSbench.onosDie( main.ONOSip[ i ] )
144
145 print "NODE COUNT = ", main.numCtrls
146
147 tempOnosIp = []
148 for i in range( main.numCtrls ):
149 tempOnosIp.append( main.ONOSip[i] )
150
151 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
152 "temp", main.Mininet1.ip_address,
153 main.apps, tempOnosIp )
154
155 main.step( "Apply cell to environment" )
156 cellResult = main.ONOSbench.setCell( "temp" )
157 verifyResult = main.ONOSbench.verifyCell()
158 stepResult = cellResult and verifyResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully applied cell to " + \
162 "environment",
163 onfail="Failed to apply cell to environment " )
164
165 main.step( "Creating ONOS package" )
166 packageResult = main.ONOSbench.onosPackage()
167 stepResult = packageResult
168 utilities.assert_equals( expect=main.TRUE,
169 actual=stepResult,
170 onpass="Successfully created ONOS package",
171 onfail="Failed to create ONOS package" )
172
173 time.sleep( main.startUpSleep )
174 main.step( "Uninstalling ONOS package" )
175 onosUninstallResult = main.TRUE
176 for ip in main.ONOSip:
177 onosUninstallResult = onosUninstallResult and \
178 main.ONOSbench.onosUninstall( nodeIp=ip )
179 stepResult = onosUninstallResult
180 utilities.assert_equals( expect=main.TRUE,
181 actual=stepResult,
182 onpass="Successfully uninstalled ONOS package",
183 onfail="Failed to uninstall ONOS package" )
184
185 time.sleep( main.startUpSleep )
186 main.step( "Installing ONOS package" )
187 onosInstallResult = main.TRUE
188 for i in range( main.numCtrls ):
189 onosInstallResult = onosInstallResult and \
190 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
191 # Populate activeONOSip
192 main.activeONOSip.append( main.ONOSip[ i ] )
193 stepResult = onosInstallResult
194 utilities.assert_equals( expect=main.TRUE,
195 actual=stepResult,
196 onpass="Successfully installed ONOS package",
197 onfail="Failed to install ONOS package" )
198
199 time.sleep( main.startUpSleep )
200 main.step( "Starting ONOS service" )
201 stopResult = main.TRUE
202 startResult = main.TRUE
203 onosIsUp = main.TRUE
204
205 for i in range( main.numCtrls ):
206 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
207 if onosIsUp == main.TRUE:
208 main.log.report( "ONOS instance is up and ready" )
209 else:
210 main.log.report( "ONOS instance may not be up, stop and " +
211 "start ONOS again " )
212
213 for i in range( main.numCtrls ):
214 stopResult = stopResult and \
215 main.ONOSbench.onosStop( main.ONOSip[ i ] )
216 for i in range( main.numCtrls ):
217 startResult = startResult and \
218 main.ONOSbench.onosStart( main.ONOSip[ i ] )
219 stepResult = onosIsUp and stopResult and startResult
220 utilities.assert_equals( expect=main.TRUE,
221 actual=stepResult,
222 onpass="ONOS service is ready",
223 onfail="ONOS service did not start properly" )
224
225 main.step( "Start ONOS cli" )
226 cliResult = main.TRUE
227 for i in range( main.numCtrls ):
228 cliResult = cliResult and \
229 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
230 stepResult = cliResult
231 utilities.assert_equals( expect=main.TRUE,
232 actual=stepResult,
233 onpass="Successfully start ONOS cli",
234 onfail="Failed to start ONOS cli" )
235
236 # Remove the first element in main.scale list
237 main.scale.remove( main.scale[ 0 ] )
238
239 main.intentFunction.report( main )
240
241
242 def CASE10( self, main ):
243 """
244 Start Mininet opticalTest Topology
245 """
246 main.case( "Mininet with Linc-OE startup")
247 main.caseExplanation = "Start opticalTest.py topology included with ONOS"
248 main.step( "Starting mininet and LINC-OE" )
249 topoResult = main.TRUE
250 time.sleep( 10 )
251 controllerIPs = ' '.join( main.activeONOSip )
252 opticalMnScript = main.LincOE.runOpticalMnScript(ctrllerIP = controllerIPs)
253 topoResult = opticalMnScript
254 utilities.assert_equals(
255 expect=main.TRUE,
256 actual=topoResult,
257 onpass="Started the topology successfully ",
258 onfail="Failed to start the topology")
259
260 # Exit if topology did not load properly
261 if not topoResult:
262 main.cleanup()
263 main.exit()
264
Jeremye4bc7132016-03-30 14:04:01 -0700265
acsmars51a7fe02015-10-29 18:33:32 -0700266
267
268 def CASE14( self, main ):
269 """
270 Stop mininet
271 """
272 main.log.report( "Stop Mininet topology" )
273 main.case( "Stop Mininet topology" )
274 main.caseExplanation = "Stopping the current mininet topology " +\
275 "to start up fresh"
276
277 main.step( "Stopping Mininet Topology" )
278 topoResult = main.LincOE.stopNet( timeout=180 )
279 utilities.assert_equals( expect=main.TRUE,
280 actual=topoResult,
281 onpass="Successfully stopped mininet",
282 onfail="Failed to stopped mininet" )
283 # Exit if topology did not load properly
284 if not topoResult:
285 main.cleanup()
286 main.exit()
287
Jeremye4bc7132016-03-30 14:04:01 -0700288 def CASE17( self, main ):
289 """
290 Use Flow Objectives
291 """
292 main.case( "Enable intent compilation using Flow Objectives" )
293 main.step( "Enabling Flow Objectives" )
294
295 main.flowCompiler = "Flow Objectives"
296
297 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
298
299 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
300 propName="useFlowObjectives", value="true" )
301
302 utilities.assert_equals( expect=main.TRUE,
303 actual=stepResult,
304 onpass="Successfully activated Flow Objectives",
305 onfail="Failed to activate Flow Objectives" )
306
acsmars51a7fe02015-10-29 18:33:32 -0700307 def CASE21( self,main ):
308 """
309 Run pingall to discover all hosts
310 """
311 main.case( "Running Pingall" )
312 main.caseExplanation = "Use pingall to discover all hosts. Pingall is expected to fail."
313 main.step( "Discover Hosts through Pingall" )
314 pingResult = main.LincOE.pingall( timeout = 600 )
315
316 utilities.assert_equals( expect=main.FALSE,
317 actual=pingResult,
318 onpass="Pingall Completed",
319 onfail="Pingall did not complete or did not return fales" )
320
321 def CASE22( self,main ):
322 """
323 Send arpings to discover all hosts
324 """
325 main.case( "Discover Hosts with arping" )
326 main.caseExplanation = "Send arpings between all the hosts to discover and verify them"
327
328 main.step( "Send arping between all hosts" )
329
330 hosts = [ "h1","h2","h3","h4","h5","h6" ]
331
332 arpingHostResults = main.TRUE
333 for host in hosts:
334 if main.LincOE.arping( host ):
335 main.log.info( "Successfully reached host {} with arping".format( host ) )
336 else:
337 main.log.error( "Could not reach host {} with arping".format( host ) )
338 arpingHostResults = main.FALSE
339
340 utilities.assert_equals( expect=main.TRUE,
341 actual=arpingHostResults,
342 onpass="Successfully discovered all hosts",
343 onfail="Could not descover some hosts" )
344
345 def CASE23( self, main ):
346 """
347 Compare ONOS Topology to Mininet Topology
348 """
349 import json
350
351 main.case( "Compare ONOS Topology view to Mininet topology" )
352 main.caseExplanation = "Compare topology elements between Mininet" +\
353 " and ONOS"
354
355 main.log.info( "Gathering topology information from Mininet" )
356 devicesResults = main.FALSE # Overall Boolean for device correctness
357 linksResults = main.FALSE # Overall Boolean for link correctness
358 hostsResults = main.FALSE # Overall Boolean for host correctness
359 deviceFails = [] # Nodes where devices are incorrect
360 linkFails = [] # Nodes where links are incorrect
361 hostFails = [] # Nodes where hosts are incorrect
362 attempts = main.checkTopoAttempts # Remaining Attempts
363
364 mnSwitches = 16
365 mnLinks = 46
366 mnHosts = 6
367
Jon Hall70b2ff42015-11-17 15:49:44 -0800368 main.step( "Comparing Mininet topology to ONOS topology" )
acsmars51a7fe02015-10-29 18:33:32 -0700369
370 while ( attempts >= 0 ) and\
371 ( not devicesResults or not linksResults or not hostsResults ):
372 time.sleep( 2 )
373 if not devicesResults:
374 devices = main.topo.getAllDevices( main )
375 ports = main.topo.getAllPorts( main )
376 devicesResults = main.TRUE
377 deviceFails = [] # Reset for each attempt
378 if not linksResults:
379 links = main.topo.getAllLinks( main )
380 linksResults = main.TRUE
381 linkFails = [] # Reset for each attempt
382 if not hostsResults:
383 hosts = main.topo.getAllHosts( main )
384 hostsResults = main.TRUE
385 hostFails = [] # Reset for each attempt
386
387 # Check for matching topology on each node
388 for controller in range( main.numCtrls ):
389 controllerStr = str( controller + 1 ) # ONOS node number
390 # Compare Devices
391 if devices[ controller ] and ports[ controller ] and\
392 "Error" not in devices[ controller ] and\
393 "Error" not in ports[ controller ]:
394
395 try:
396 deviceData = json.loads( devices[ controller ] )
397 portData = json.loads( ports[ controller ] )
398 except (TypeError,ValueError):
399 main.log.error("Could not load json:" + str( devices[ controller ] ) + ' or ' + str( ports[ controller ] ))
400 currentDevicesResult = main.FALSE
401 else:
402 if mnSwitches == len( deviceData ):
403 currentDevicesResult = main.TRUE
404 else:
405 currentDevicesResult = main.FALSE
Jeremye4bc7132016-03-30 14:04:01 -0700406 main.log.error( "Node {} only sees {} device(s) but {} exist".format(
acsmars51a7fe02015-10-29 18:33:32 -0700407 controllerStr,len( deviceData ),mnSwitches ) )
408 else:
409 currentDevicesResult = main.FALSE
410 if not currentDevicesResult:
411 deviceFails.append( controllerStr )
412 devicesResults = devicesResults and currentDevicesResult
413 # Compare Links
414 if links[ controller ] and "Error" not in links[ controller ]:
415 try:
416 linkData = json.loads( links[ controller ] )
417 except (TypeError,ValueError):
418 main.log.error("Could not load json:" + str( links[ controller ] ) )
419 currentLinksResult = main.FALSE
420 else:
421 if mnLinks == len( linkData ):
422 currentLinksResult = main.TRUE
423 else:
424 currentLinksResult = main.FALSE
Jeremye4bc7132016-03-30 14:04:01 -0700425 main.log.error( "Node {} only sees {} link(s) but {} exist".format(
acsmars51a7fe02015-10-29 18:33:32 -0700426 controllerStr,len( linkData ),mnLinks ) )
427 else:
428 currentLinksResult = main.FALSE
429 if not currentLinksResult:
430 linkFails.append( controllerStr )
431 linksResults = linksResults and currentLinksResult
432 # Compare Hosts
433 if hosts[ controller ] and "Error" not in hosts[ controller ]:
434 try:
435 hostData = json.loads( hosts[ controller ] )
436 except (TypeError,ValueError):
437 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
438 currentHostsResult = main.FALSE
439 else:
440 if mnHosts == len( hostData ):
441 currentHostsResult = main.TRUE
442 else:
443 currentHostsResult = main.FALSE
Jeremye4bc7132016-03-30 14:04:01 -0700444 main.log.error( "Node {} only sees {} host(s) but {} exist".format(
acsmars51a7fe02015-10-29 18:33:32 -0700445 controllerStr,len( hostData ),mnHosts ) )
446 else:
447 currentHostsResult = main.FALSE
448 if not currentHostsResult:
449 hostFails.append( controllerStr )
450 hostsResults = hostsResults and currentHostsResult
451 # Decrement Attempts Remaining
452 attempts -= 1
453
454 utilities.assert_equals( expect=[],
455 actual=deviceFails,
456 onpass="ONOS correctly discovered all devices",
457 onfail="ONOS incorrectly discovered devices on nodes: " +
458 str( deviceFails ) )
459 utilities.assert_equals( expect=[],
460 actual=linkFails,
461 onpass="ONOS correctly discovered all links",
462 onfail="ONOS incorrectly discovered links on nodes: " +
463 str( linkFails ) )
464 utilities.assert_equals( expect=[],
465 actual=hostFails,
466 onpass="ONOS correctly discovered all hosts",
467 onfail="ONOS incorrectly discovered hosts on nodes: " +
468 str( hostFails ) )
469 if hostsResults and linksResults and devicesResults:
470 topoResults = main.TRUE
471 else:
472 topoResults = main.FALSE
473 utilities.assert_equals( expect=main.TRUE,
474 actual=topoResults,
475 onpass="ONOS correctly discovered the topology",
476 onfail="ONOS incorrectly discovered the topology" )
477
478
479 def CASE31( self, main ):
480 import time
481 """
482 Add bidirectional point intents between 2 packet layer( mininet )
483 devices and ping mininet hosts
484 """
485 main.log.report(
486 "This testcase adds bidirectional point intents between 2 " +
487 "packet layer( mininet ) devices and ping mininet hosts" )
488 main.case( "Install point intents between 2 packet layer device and " +
489 "ping the hosts" )
490 main.caseExplanation = "This testcase adds bidirectional point intents between 2 " +\
491 "packet layer( mininet ) devices and ping mininet hosts"
492
493 main.step( "Adding point intents" )
494 checkFlowResult = main.TRUE
495 main.pIntentsId = []
496 pIntent1 = main.CLIs[ 0 ].addPointIntent(
497 "of:0000ffffffff0001/1",
498 "of:0000ffffffff0005/1" )
499 time.sleep( 10 )
500 pIntent2 = main.CLIs[ 0 ].addPointIntent(
501 "of:0000ffffffff0005/1",
502 "of:0000ffffffff0001/1" )
503 main.pIntentsId.append( pIntent1 )
504 main.pIntentsId.append( pIntent2 )
505 time.sleep( 10 )
506 main.log.info( "Checking intents state")
507 checkStateResult = main.CLIs[ 0 ].checkIntentState(
508 intentsId = main.pIntentsId )
509 time.sleep( 10 )
510 main.log.info( "Checking flows state")
511 checkFlowResult = main.CLIs[ 0 ].checkFlowsState()
512 # Sleep for 10 seconds to provide time for the intent state to change
513 time.sleep( 10 )
514 main.log.info( "Checking intents state one more time")
515 checkStateResult = main.CLIs[ 0 ].checkIntentState(
516 intentsId = main.pIntentsId )
Jeremye4bc7132016-03-30 14:04:01 -0700517
acsmars51a7fe02015-10-29 18:33:32 -0700518 if checkStateResult and checkFlowResult:
519 addIntentsResult = main.TRUE
520 else:
521 addIntentsResult = main.FALSE
522 utilities.assert_equals(
523 expect=main.TRUE,
524 actual=addIntentsResult,
525 onpass="Successfully added point intents",
526 onfail="Failed to add point intents")
527
528 if not addIntentsResult:
529 main.log.error( "Intents were not properly installed. Exiting case." )
530 main.skipCase()
531
532 main.step( "Ping h1 and h5" )
533 pingResult = main.LincOE.pingHostOptical( src="h1", target="h5" )
534 utilities.assert_equals(
535 expect=main.TRUE,
536 actual=pingResult,
537 onpass="Successfully pinged h1 and h5",
538 onfail="Failed to ping between h1 and h5")
539
540 def CASE32( self ):
541 """
542 Add host intents between 2 packet layer host
543 """
544 import time
545 import json
546 main.log.report( "Adding host intents between 2 optical layer host" )
547 main.case( "Test add host intents between optical layer host" )
548 main.caseExplanation = "Test host intents between 2 optical layer host"
549
550 main.step( "Adding host intents to h1 and h2" )
551 hostMACs = []
552 hostId = []
553 # Listing host MAC addresses
554 for i in range( 1 , 7 ):
555 hostMACs.append( "00:00:00:00:00:" +
556 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
557 for macs in hostMACs:
558 hostId.append( macs + "/-1" )
559 host1 = hostId[ 0 ]
560 host2 = hostId[ 1 ]
561
562 intentsId = []
563 intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne = host1,
564 hostIdTwo = host2 )
565 intentsId.append( intent1 )
566 # Checking intents state before pinging
567 main.log.info( "Checking intents state" )
568 intentResult = main.CLIs[ 0 ].checkIntentState( intentsId = intentsId )
569 # Check intent state again if intents are not in installed state
Jeremye4bc7132016-03-30 14:04:01 -0700570
acsmars51a7fe02015-10-29 18:33:32 -0700571
572 # If intent state is wrong, wait 3 sec and try again
573 if not intentResult:
574 time.sleep( 3 )
575 intentResult = main.CLIs[ 0 ].checkIntentState( intentsId = intentsId )
576
577 # If intent state is still wrong, display intent states
578 if not intentResult:
579 main.log.error( main.CLIs[ 0 ].intents() )
Jeremye4bc7132016-03-30 14:04:01 -0700580
acsmars51a7fe02015-10-29 18:33:32 -0700581 utilities.assert_equals( expect=main.TRUE,
582 actual=intentResult,
583 onpass="All intents are in INSTALLED state ",
584 onfail="Some of the intents are not in " +
585 "INSTALLED state " )
586
587 if not intentResult:
588 main.log.error( "Intents were not properly installed. Skipping Ping" )
589 else:
590 # Pinging h1 to h2 and then ping h2 to h1
591 main.step( "Pinging h1 and h2" )
592 pingResult = main.TRUE
593 pingResult = main.LincOE.pingHostOptical( src="h1", target="h2" ) \
594 and main.LincOE.pingHostOptical( src="h2",target="h1" )
Jeremye4bc7132016-03-30 14:04:01 -0700595
acsmars51a7fe02015-10-29 18:33:32 -0700596 utilities.assert_equals( expect=main.TRUE,
597 actual=pingResult,
598 onpass="Pinged successfully between h1 and h2",
599 onfail="Pinged failed between h1 and h2" )
600
601 # Removed all added host intents
602 main.step( "Removing host intents" )
603 removeResult = main.TRUE
604 # Check remaining intents
Jeremy7134f5b2016-04-05 13:50:21 -0700605 try:
606 intentsJson = json.loads( main.CLIs[ 0 ].intents() )
607 main.CLIs[ 0 ].removeIntent( intentId=intent1, purge=True )
608 #main.CLIs[ 0 ].removeIntent( intentId=intent2, purge=True )
609 main.log.debug(intentsJson)
610 for intents in intentsJson:
Jeremye4bc7132016-03-30 14:04:01 -0700611 main.CLIs[ 0 ].removeIntent( intentId=intents.get( 'id' ),
612 app='org.onosproject.optical',
613 purge=True )
acsmars51a7fe02015-10-29 18:33:32 -0700614
Jeremy7134f5b2016-04-05 13:50:21 -0700615 for i in range( main.numCtrls ):
616 if len( json.loads( main.CLIs[ i ].intents() ) ):
617 print json.loads( main.CLIs[ i ].intents() )
618 removeResult = main.FALSE
619 except ( TypeError, ValueError ):
620 main.log.error( "Cannot see intents on Node " + str( main.CLIs[ 0 ] ) +\
621 ". Removing all intents.")
622 main.CLIs[ 0 ].removeAllIntents( purge=True )
623 main.CLIs[ 0 ].removeAllIntents( purge=True, app='org.onosproject.optical')
624
625 utilities.assert_equals( expect=main.TRUE,
626 actual=removeResult,
627 onpass="Successfully removed host intents",
628 onfail="Failed to remove host intents" )