blob: d82ae0442337be63ebb43f654424f115569bcc9d [file] [log] [blame]
Devin Lim58046fa2017-07-05 16:55:00 -07001class Utils:
2 def __init__( self ):
3 self.default = ''
4
5 def mininetCleanIntro( self ):
6 main.log.report( "Stop Mininet" )
7
8 main.case( "Stop Mininet" )
9 main.caseExplanation = "Stopping the current mininet to start up fresh"
10
11 def mininetCleanup( self, Mininet, timeout=5 ):
12 main.step( "Stopping Mininet" )
13 topoResult = Mininet.stopNet( timeout=timeout )
14 utilities.assert_equals( expect=main.TRUE,
15 actual=topoResult,
16 onpass="Successfully stopped mininet",
17 onfail="Failed to stopped mininet" )
18 return topoResult
19
20 def copyKarafLog( self ):
21 """
22 Copy the karaf.log files after each testcase cycle
23 """
24 main.log.report( "Copy karaf logs" )
25 main.case( "Copy karaf logs" )
26 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
27 "reinstalling ONOS"
28 main.step( "Copying karaf logs" )
29 stepResult = main.TRUE
30 scpResult = main.TRUE
31 copyResult = main.TRUE
32 for i in range( main.numCtrls ):
33 main.node = main.CLIs[ i ]
34 ip = main.ONOSip[ i ]
35 main.node.ip_address = ip
36 scpResult = scpResult and main.ONOSbench.scp( main.node,
37 "/opt/onos/log/karaf.log",
38 "/tmp/karaf.log",
39 direction="from" )
40 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
41 copyFileName=( "karaf.log.node{0}.cycle{1}".format(
42 str( i + 1 ), str( main.cycle ) ) ) )
43 if scpResult and copyResult:
44 stepResult = main.TRUE and stepResult
45 else:
46 stepResult = main.FALSE and stepResult
47 utilities.assert_equals( expect=main.TRUE,
48 actual=stepResult,
49 onpass="Successfully copied remote ONOS logs",
50 onfail="Failed to copy remote ONOS logs" )