SAMPstatTemplate2 with driver modifications
Change-Id: I324b060d9d30e5cf26131a4a83bfbe101c5f6ec2
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index c7ae79b..b487096 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -301,6 +301,87 @@
main.cleanup()
main.exit()
+ def startCellCli( self, karafTimeout="",
+ commandlineTimeout=10, onosStartTimeout=60 ):
+ """
+ Start CLI on onos ecll handle.
+
+ karafTimeout is an optional argument. karafTimeout value passed
+ by user would be used to set the current karaf shell idle timeout.
+ Note that when ever this property is modified the shell will exit and
+ the subsequent login would reflect new idle timeout.
+ Below is an example to start a session with 60 seconds idle timeout
+ ( input value is in milliseconds ):
+
+ tValue = "60000"
+
+ Note: karafTimeout is left as str so that this could be read
+ and passed to startOnosCli from PARAMS file as str.
+ """
+
+ try:
+ self.handle.sendline( "" )
+ x = self.handle.expect( [
+ "\$", "onos>" ], commandlineTimeout)
+
+ if x == 1:
+ main.log.info( "ONOS cli is already running" )
+ return main.TRUE
+
+ # Wait for onos start ( -w ) and enter onos cli
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ i = self.handle.expect( [
+ "onos>",
+ pexpect.TIMEOUT ], onosStartTimeout )
+
+ if i == 0:
+ main.log.info( self.name + " CLI Started successfully" )
+ if karafTimeout:
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell\
+ sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ self.handle.expect( "onos>" )
+ return main.TRUE
+ else:
+ # If failed, send ctrl+c to process and try again
+ main.log.info( "Starting CLI failed. Retrying..." )
+ self.handle.send( "\x03" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ i = self.handle.expect( [ "onos>", pexpect.TIMEOUT ],
+ timeout=30 )
+ if i == 0:
+ main.log.info( self.name + " CLI Started " +
+ "successfully after retry attempt" )
+ if karafTimeout:
+ self.handle.sendline(
+ "config:property-set -p org.apache.karaf.shell\
+ sshIdleTimeout " +
+ karafTimeout )
+ self.handle.expect( "\$" )
+ self.handle.sendline( "/opt/onos/bin/onos" )
+ self.handle.expect( "onos>" )
+ return main.TRUE
+ else:
+ main.log.error( "Connection to CLI " +
+ self.name + " timeout" )
+ return main.FALSE
+
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
def log( self, cmdStr, level="" ):
"""
log the commands in the onos CLI.
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 8572131..1aed954 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -795,7 +795,7 @@
handleMore = self.handle.before
cell_result = handleBefore + handleAfter + handleMore
- print cell_result
+ #print cell_result
if( re.search( "No such cell", cell_result ) ):
main.log.error( "Cell call returned: " + handleBefore +
handleAfter + handleMore )
@@ -2253,3 +2253,39 @@
return localhost
except Exception:
main.log.exception( "Uncaught exception" )
+
+ def startBasicONOS(self, nodeList, opSleep = 60, onosStartupSleep = 60):
+
+ '''
+ Start onos cluster with defined nodes, but only with drivers app
+
+ '''
+ import time
+
+ self.createCellFile( self.ip_address,
+ "temp",
+ self.ip_address,
+ "drivers",
+ nodeList )
+
+ main.log.info( self.name + ": Apply cell to environment" )
+ cellResult = self.setCell( "temp" )
+ verifyResult = self.verifyCell()
+
+ main.log.info( self.name + ": Creating ONOS package" )
+ packageResult = self.onosPackage( opTimeout=opSleep )
+
+ main.log.info( self.name + ": Installing ONOS package" )
+ for nd in nodeList:
+ self.onosInstall( node=nd )
+
+ main.log.info( self.name + ": Starting ONOS service" )
+ time.sleep( onosStartupSleep )
+
+ onosStatus = True
+ for nd in nodeList:
+ onosStatus = onosStatus & self.isup( node = nd )
+ #print "onosStatus is: " + str( onosStatus )
+
+ return main.TRUE if onosStatus else main.FALSE
+