Tuesday's improvements plus cli script

Change-Id: Ieba2d2e2ac97ff8f599780d9185a8be239b7bc68
diff --git a/TestON/bin/demo-cli b/TestON/bin/demo-cli
new file mode 100755
index 0000000..9cbec9d
--- /dev/null
+++ b/TestON/bin/demo-cli
@@ -0,0 +1,39 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+# Test utility to spawn an iTerm window for testing against current cell.
+#-------------------------------------------------------------------------------
+
+osascript -e "
+tell application \"iTerm\"
+
+  set nodeIP to \"$OCN\"
+
+  set theTerm to (make new terminal)
+
+  tell theTerm
+    launch session \"DemoLeft\"
+    tell the current session
+      set name to \"TestON Log\"
+      write text \"export TERM=vt100\"
+      write text \"ssh admin@\" & nodeIP
+      set name to \"TestON Log\"
+      write text \"cd ~/OnosSystemTest/TestON/bin\"
+      write text \"tail -F /home/admin/ONS16/Demo.log\"
+
+      tell application \"System Events\" to keystroke \"d\" using command down
+      set name to \"TestON Testcase Code \"
+      write text \"export TERM=vt100\"
+      write text \"ssh admin@\" & nodeIP
+      write text \"cd ~/OnosSystemTest/TestON/bin\"
+      write text \"tail -F /home/admin/ONS16/DemoCode.txt\"
+      set foreground color to \"white\"
+      set background color to \"black\"
+    end tell
+
+  end tell
+end tell
+"
+    #set number of columns to 292
+    #set number of rows to 24
+    # set newSession to (split horizontally with profile \"DemoRight\" )
+    # set background color to \"gray\"
diff --git a/TestON/bin/demo-summary b/TestON/bin/demo-summary
index 2f90a55..4ba8c05 100755
--- a/TestON/bin/demo-summary
+++ b/TestON/bin/demo-summary
@@ -13,5 +13,5 @@
     printf "\t-f     : Tails the summary file and updates as the file is written to.\n\n"
     exit 1
 fi
-ls -t ~/OnosSystemTest/TestON/logs/*/*${file}.txt | head -1 | xargs tail -n+1 -f
+tail -F /home/admin/ONS16/DemoCode.txt
 exit 0
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index 437583e..7734ca1 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -115,14 +115,19 @@
 
         os.mkdir(main.logdir)
 
-        main.LogFileName = main.logdir + "/" + main.TEST + "_" +str(currentTime) + ".log"
+        main.LogFileName = "/home/admin/ONS16/Demo.log"
         main.ReportFileName = main.logdir + "/" + main.TEST + "_" + str(currentTime) + ".rpt"
         main.WikiFileName = main.logdir + "/" + main.TEST + "Wiki.txt"
-        main.DemoCodeFileName = main.logdir + "/" + main.TEST + "-DemoCode.txt"
+        #main.DemoCodeFileName = main.logdir + "/" + main.TEST + "-DemoCode.txt"
+        main.DemoCodeFileName = "/home/admin/ONS16/DemoCode.txt"
         main.DemoSummaryFileName = "/usr/local/apr/htdocs/ONS2016/testLog"
         main.SummaryFileName = main.logdir + "/" + main.TEST + "Summary.txt"
         main.JenkinsCSV = main.logdir + "/" + main.TEST + ".csv"
         main.TOTAL_TC_SUCCESS = 0
+        demoFile = open(main.DemoCodeFileName,"w+")
+        demoFile.close()
+        logfile = open(main.LogFileName,"w+")
+        logfile.close()
 
         #### Add log-level - Report
         logging.addLevelName(9, "REPORT")
@@ -190,7 +195,7 @@
                 elif "main.step" in line:
                     parsedMsg += colors['cyan'] + line + colors['end']
                 elif "utilities.assert_" in line and  "(" in line:
-                    parsedMsg += colors['purple'] + line
+                    parsedMsg += colors['green'] + line
                     if ')' not in line:
                         wrapped = True
                     else:
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index ae4ae3a..cb683dd 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -748,6 +748,12 @@
                     # threads as well
                     print str( thread.getName() ) +\
                           ' could not be terminated'
+        demoFile = open(main.DemoCodeFileName,"w+")
+        demoFile.write( "\n" * 60 )
+        demoFile.close()
+        logfile = open(main.LogFileName,"w+")
+        logfile.write( "\n" * 60 )
+        logfile.close()
         sys.exit()
 
     def stop( self, email=False ):
diff --git a/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.params b/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.params
index 00545a7..0007680 100644
--- a/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.params
+++ b/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.params
@@ -36,7 +36,7 @@
         <TopoDiscovery>10</TopoDiscovery>
         <PingTestWithRoutes>20</PingTestWithRoutes>
         <PingTestWithoutRoutes>100</PingTestWithoutRoutes>
-        <RouteDelivery>10</RouteDelivery>
+        <RouteDelivery>15</RouteDelivery>
         <PathAvailable>10</PathAvailable>
         <Readability>5</Readability>
     </timers>
diff --git a/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.py b/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.py
index c46ba6c..526d33c 100644
--- a/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.py
+++ b/TestON/tests/DEMO_SDNIP/DEMO_SDNIP.py
@@ -61,6 +61,7 @@
         from operator import eq
 
         main.case( "Setting up ONOS environment" )
+        main.log.demoSummary( "DEMO: TestStation: Setting up ONOS environment" )
 
         cellName = main.params[ 'ENV' ][ 'cellName' ]
         global ONOS1Ip
@@ -106,12 +107,15 @@
 
         main.step( "Checking if ONOS CLI is ready to start" )
         main.CLIs = []
+        main.log.demoSummary( "DEMO: ONOS1: Connecting to ONOS1" )
         cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
                 commandlineTimeout=100, onosStartTimeout=600 )
         main.CLIs.append( main.ONOScli1 )
+        main.log.demoSummary( "DEMO: ONOS2: Connecting to ONOS2" )
         cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
                 commandlineTimeout=100, onosStartTimeout=600 )
         main.CLIs.append( main.ONOScli2 )
+        main.log.demoSummary( "DEMO: ONOS3: Connecting to ONOS3" )
         cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
                 commandlineTimeout=100, onosStartTimeout=600 )
         main.CLIs.append( main.ONOScli3 )
@@ -147,7 +151,7 @@
         main.log.info( "Waiting for link discovery......" )
         time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
 
-        main.log.info( "Get links in the network" )
+        main.step( "Get links in the network" )
         summaryResult = main.ONOScli1.summary()
         linkNum = json.loads( summaryResult )[ "links" ]
         main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
@@ -240,6 +244,7 @@
         bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
         if bgpIntentsActualNum != bgpIntentsExpectedNum:
             time.sleep( int( main.params['timers']['RouteDelivery'] ) )
+            getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
             bgpIntentsActualNum = \
                 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
         main.log.info( "bgpIntentsExpected num is:" )
@@ -253,20 +258,20 @@
             onfail="PointToPointIntent Intent Num is wrong!" )
         time.sleep( int( main.params['timers']['Readability'] ) )
 
-
     def CASE3( self, main ):
         '''
         routes and intents check to all BGP peers
         '''
         import time
         main.case( "Check routes and M2S intents to all BGP peers" )
-        main.log.demoSummary( "DEMO:ONOS1: Check BGP routes and Multi-point intents" )
 
+        main.step( "Check routes installed" )
         allRoutesExpected = []
         allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
         allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
         allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
 
+        main.log.demoSummary( "DEMO:Quagga: Check BGP routes" )
         getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
         allRoutesActual = \
             main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
@@ -278,7 +283,6 @@
                 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
             allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
 
-        main.step( "Check routes installed" )
         main.log.info( "Routes expected:" )
         main.log.info( allRoutesStrExpected )
         main.log.info( "Routes get from ONOS CLI:" )
@@ -290,12 +294,14 @@
         time.sleep( int( main.params['timers']['Readability'] ) )
 
         main.step( "Check M2S intents installed" )
+        main.log.demoSummary( "DEMO:ONOS1: Check Multi-point intents" )
         getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
         routeIntentsActualNum = \
             main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
         routeIntentsExpectedNum = 3
         if routeIntentsActualNum != routeIntentsExpectedNum:
             time.sleep( int( main.params['timers']['RouteDelivery'] ) )
+            getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
             routeIntentsActualNum = \
                 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
 
@@ -310,6 +316,7 @@
             onfail="MultiPointToSinglePoint Intent Num is wrong!" )
         time.sleep( int( main.params['timers']['Readability'] ) )
 
+        main.log.demoSummary( "DEMO:ONOS1: Check flows" )
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
                                      main.FALSE,