[ONOS-6619] Allow different bash prompts in TestON components, Also including part of ONOS-6595
Change-Id: I31c923347dd8fac018aaf47868394552a2deefbc
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index d5c1114..bfe49f1 100755
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -35,7 +35,7 @@
def __init__( self ):
self.pwd = None
self.user_name = "user"
- super( Controller, self ).__init__()
+ super( OnosRestDriver, self ).__init__()
self.ip_address = "localhost"
self.port = "8080"
self.wrapped = sys.modules[ __name__ ]
diff --git a/TestON/drivers/common/api/controllerdriver.py b/TestON/drivers/common/api/controllerdriver.py
index 6cda814..721e7e0 100644
--- a/TestON/drivers/common/api/controllerdriver.py
+++ b/TestON/drivers/common/api/controllerdriver.py
@@ -31,5 +31,5 @@
# The common functions for emulator included in emulatordriver
def __init__( self ):
- super( API, self ).__init__()
+ super( Controller, self ).__init__()
diff --git a/TestON/drivers/common/api/dockerapidriver.py b/TestON/drivers/common/api/dockerapidriver.py
index 21e2024..6d9650c 100644
--- a/TestON/drivers/common/api/dockerapidriver.py
+++ b/TestON/drivers/common/api/dockerapidriver.py
@@ -24,7 +24,7 @@
self.name = None
self.home = None
self.handle = None
- super( API, self ).__init__()
+ super( DockerApiDriver, self ).__init__()
def connect( self, **connectargs ):
"""
diff --git a/TestON/drivers/common/api/fvtapidriver.py b/TestON/drivers/common/api/fvtapidriver.py
index f861f7d..1a71655 100644
--- a/TestON/drivers/common/api/fvtapidriver.py
+++ b/TestON/drivers/common/api/fvtapidriver.py
@@ -98,7 +98,7 @@
class FvtApiDriver( API, templatetest.TemplateTest ):
def __init__( self ):
- super( API, self ).__init__()
+ super( FvtApiDriver, self ).__init__()
print 'init'
def connect( self, **connectargs ):
diff --git a/TestON/drivers/common/apidriver.py b/TestON/drivers/common/apidriver.py
index 166211e..2a7a1a3 100644
--- a/TestON/drivers/common/apidriver.py
+++ b/TestON/drivers/common/apidriver.py
@@ -34,7 +34,7 @@
This will define common functions for CLI included.
"""
def __init__( self ):
- super( Component, self ).__init__()
+ super( API, self ).__init__()
def connect( self ):
"""
diff --git a/TestON/drivers/common/cli/dpclidriver.py b/TestON/drivers/common/cli/dpclidriver.py
index f3ea3e5..bae91e4 100644
--- a/TestON/drivers/common/cli/dpclidriver.py
+++ b/TestON/drivers/common/cli/dpclidriver.py
@@ -13,7 +13,7 @@
class DPCliDriver( CLI ):
def __init__( self ):
- super( CLI, self ).__init__()
+ super( DPCliDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -46,12 +46,12 @@
and false if a single interface has issues
"""
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "rm /tmp/local_ip.txt" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "touch /tmp/local_ip.txt" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
main.log.info( "Creating interfaces" )
k = 0
@@ -69,7 +69,7 @@
intf ) + " " + ip + " netmask 255.255.255.0" )
i = self.handle.expect( [
- "\$",
+ self.prompt,
"password",
pexpect.TIMEOUT,
pexpect.EOF ],
@@ -78,11 +78,11 @@
if i == 0:
self.handle.sendline(
"echo " + str( ip ) + " >> /tmp/local_ip.txt" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
elif i == 1:
main.log.info( "Sending sudo password" )
self.handle.sendline( self.pwd )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
else:
main.log.error( "INTERFACES NOT CREATED" )
return main.FALSE
@@ -98,7 +98,7 @@
this function will install fping then run the same command
"""
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "scp " + str( destlogin ) + "@" +
str( destip ) +
@@ -123,7 +123,7 @@
return result
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
main.log.info( "Pinging interfaces on the " + str( netdst ) +
" network from " + str( netsrc ) + "." +
@@ -135,7 +135,7 @@
i = self.handle.expect( [
"reachable",
"unreachable",
- "\$",
+ self.prompt,
"password",
pexpect.TIMEOUT,
"not installed" ],
@@ -160,12 +160,12 @@
main.log.info( "fping not installed, installing fping" )
self.handle.sendline( "sudo apt-get install fping" )
i = self.handle.expect( [ "password",
- "\$",
+ self.prompt,
pexpect.TIMEOUT ],
timeout=60 )
if i == 0:
self.handle.sendline( self.pwd )
- self.handle.expect( "\$", timeout=30 )
+ self.handle.expect( self.prompt, timeout=30 )
main.log.info( "fping installed, now pinging interfaces" )
self.handle.sendline(
"sudo fping -S " + str(
diff --git a/TestON/drivers/common/cli/emulator/flowvisordriver.py b/TestON/drivers/common/cli/emulator/flowvisordriver.py
index 35c0bbf..5839e18 100644
--- a/TestON/drivers/common/cli/emulator/flowvisordriver.py
+++ b/TestON/drivers/common/cli/emulator/flowvisordriver.py
@@ -37,7 +37,7 @@
FlowVisorDriver is the basic driver which will handle the Mininet functions
"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( FlowVisorDriver, self ).__init__()
self.handle = self
self.wrapped = sys.modules[ __name__ ]
@@ -61,13 +61,13 @@
# Copying the readme file to process the
if self.handle:
- self.execute( cmd='\r', prompt='\$', timeout=10 )
+ self.execute( cmd='\r', prompt=self.prompt, timeout=10 )
self.options[ 'path' ] = '/home/openflow/flowvisor/scripts/'
#self.handle.logfile = sys.stdout
self.execute(
cmd='cd ' +
self.options[ 'path' ],
- prompt='\$',
+ prompt=self.prompt,
timeout=10 )
main.log.info( "Starting FlowVisor " )
@@ -92,7 +92,7 @@
main.log.info( response )
#import time
# time.sleep( 10 )
- #response = self.execute( cmd='./start_visualizer.sh & \r',prompt='\$',timeout=10 )
+ #response = self.execute( cmd='./start_visualizer.sh & \r',prompt=self.prompt,timeout=10 )
return main.TRUE
else:
@@ -111,13 +111,13 @@
for id in flow_ids:
self.removeFlowSpace( id )
else:
- self.execute( cmd="clear", prompt="\$", timeout=10 )
+ self.execute( cmd="clear", prompt=self.prompt, timeout=10 )
self.execute(
cmd="./fvctl.sh removeFlowSpace " +
id,
prompt="passwd:",
timeout=10 )
- self.execute( cmd="\n", prompt="\$", timeout=10 )
+ self.execute( cmd="\n", prompt=self.prompt, timeout=10 )
main.log.info( "Removed flowSpace which is having id :" + id )
return main.TRUE
@@ -155,13 +155,13 @@
except Exception:
main.log.error( "Please specify flowspace properly" )
"""
- # self.execute( cmd="clear",prompt="\$",timeout=10 )
+ # self.execute( cmd="clear",prompt=self.prompt,timeout=10 )
self.execute(
cmd="./fvctl.sh addFlowSpace " +
flowspace,
prompt="passwd:",
timeout=10 )
- self.execute( cmd="\n", prompt="\$", timeout=10 )
+ self.execute( cmd="\n", prompt=self.prompt, timeout=10 )
sucess_match = re.search( "success\:\s+(\d+)", main.last_response )
if sucess_match:
main.log.info(
@@ -172,12 +172,12 @@
return main.FALSE
def listFlowSpace( self ):
- self.execute( cmd="clear", prompt="\$", timeout=10 )
+ self.execute( cmd="clear", prompt=self.prompt, timeout=10 )
self.execute(
cmd="./fvctl.sh listFlowSpace ",
prompt="passwd:",
timeout=10 )
- self.execute( cmd="\n", prompt="\$", timeout=10 )
+ self.execute( cmd="\n", prompt=self.prompt, timeout=10 )
flow_space = main.last_response
flow_space = self.remove_contol_chars( flow_space )
flow_space = re.sub(
@@ -191,9 +191,9 @@
return flow_space
def listDevices( self ):
- # self.execute( cmd="clear",prompt="\$",timeout=10 )
+ # self.execute( cmd="clear",prompt=self.prompt,timeout=10 )
#self.execute( cmd="./fvctl.sh listDevices ",prompt="passwd:",timeout=10 )
- # self.execute( cmd="\n",prompt="\$",timeout=10 )
+ # self.execute( cmd="\n",prompt=self.prompt,timeout=10 )
devices_list = ''
last_response = re.findall(
"(Device\s\d+\:\s((\d|[a-z])(\d|[a-z])\:)+(\d|[a-z])(\d|[a-z]))",
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 5024f17..dfc7511 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -31,7 +31,7 @@
LincOEDriver class will handle all emulator functions
"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( LincOEDriver, self ).__init__()
self.handle = self
self.wrapped = sys.modules[ __name__ ]
self.flag = 0
@@ -103,12 +103,12 @@
self.handle.sendline( "make rel" )
i = self.handle.expect( [
"ERROR",
- "\$" ] )
+ self.prompt ] )
if i == 0:
self.handle.sendline( "sudo pkill -9 epmd" )
self.handle.sendline( "make rel" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
handle = self.handle.before
return handle
@@ -222,7 +222,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "sudo ~/linc-oe/rel/linc/bin/linc attach" )
self.handle.expect( ">" )
return main.TRUE
@@ -317,19 +317,19 @@
# Send CTRL+C twice to exit CLI
self.handle.send( "\x03" )
self.handle.send( "\x03" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
handle1 = self.handle.before
cmd = "pgrep -f linc"
self.handle.sendline( cmd )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
handle2 = self.handle.before
main.log.info( "pid's = " + handle2 )
cmd = "sudo kill -9 `pgrep -f linc`"
self.handle.sendline( cmd )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
# Close the ssh connection
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "exit" )
self.handle.expect( "closed" )
except pexpect.EOF:
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 90f79a9..21ba948 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -44,12 +44,11 @@
class MininetCliDriver( Emulator ):
-
"""
MininetCliDriver is the basic driver which will handle
the Mininet functions"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( MininetCliDriver, self ).__init__()
self.handle = self
self.name = None
self.home = None
@@ -155,7 +154,7 @@
main.log.info( self.name + ": Sending sudo password" )
self.handle.sendline( self.pwd )
i = self.handle.expect( [ '%s:' % self.user,
- '\$',
+ self.prompt,
pexpect.EOF,
pexpect.TIMEOUT ],
timeout )
@@ -197,7 +196,7 @@
cmdString += mnCmd
# Send the command and check if network started
self.handle.sendline( "" )
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
main.log.info( "Sending '" + cmdString + "' to " + self.name )
self.handle.sendline( cmdString )
while True:
@@ -213,7 +212,7 @@
elif i == 1:
response = str( self.handle.before +
self.handle.after )
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
response += str( self.handle.before +
self.handle.after )
main.log.error(
@@ -2370,7 +2369,7 @@
try:
self.handle.sendline( "" )
i = self.handle.expect( [ 'mininet>',
- '\$',
+ self.prompt,
pexpect.EOF,
pexpect.TIMEOUT ],
timeout )
@@ -2395,7 +2394,7 @@
if fileName:
self.handle.sendline( "" )
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
self.handle.sendline(
"sudo kill -9 \`ps -ef | grep \"" +
fileName +
diff --git a/TestON/drivers/common/cli/emulator/poxclidriver.py b/TestON/drivers/common/cli/emulator/poxclidriver.py
index 02c43b1..349e54e 100644
--- a/TestON/drivers/common/cli/emulator/poxclidriver.py
+++ b/TestON/drivers/common/cli/emulator/poxclidriver.py
@@ -41,7 +41,7 @@
PoxCliDriver driver provides the basic functions of POX controller
"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( PoxCliDriver, self ).__init__()
self.handle = self
self.wrapped = sys.modules[ __name__ ]
@@ -80,12 +80,12 @@
self.execute(
cmd="cd " +
self.options[ 'pox_lib_location' ],
- prompt="/pox\$",
+ prompt="/pox" + self.prompt,
timeout=120 )
else:
self.execute(
cmd="cd ~/TestON/lib/pox/",
- prompt="/pox\$",
+ prompt="/pox" + self.prompt,
timeout=120 )
# launching pox with components
main.log.info( "launching POX controller with given components" )
@@ -102,7 +102,7 @@
def disconnect( self, handle ):
if self.handle:
- self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+ self.execute( cmd="exit()", prompt="/pox" + self.prompt, timeout=120 )
else:
main.log.error( "Connection failed to the host" )
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index 8788af0..4aa8ad4 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -39,7 +39,7 @@
mininet running on the target.
"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( RemoteMininetDriver, self ).__init__()
self.handle = self
self.name = None
self.wrapped = sys.modules[ __name__ ]
@@ -103,12 +103,12 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "cat " + pingList )
self.handle.expect( pingList )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
outputs = self.handle.before + self.handle.after
if re.search( " 0% packet loss", outputs ):
return main.FALSE
@@ -140,7 +140,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
args = utilities.parse_args(
[ "SRC", "TARGET", "PINGTIME" ], **pingParams )
precmd = "sudo rm /tmp/ping." + args[ "SRC" ]
@@ -152,7 +152,7 @@
main.log.info( command )
self.execute( cmd=command, prompt="(.*)", timeout=10 )
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
return main.TRUE
except TypeError:
main.log.exception(self.name + ": Object not as expected")
@@ -179,14 +179,14 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
args = utilities.parse_args( [ "SRC" ], **pingParams )
self.handle.sendline( "tail /tmp/ping." + args[ "SRC" ] )
self.handle.expect( "tail" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
result = self.handle.before + self.handle.after
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
if re.search( 'Unreachable', result ):
main.log.info( "Unreachable found in ping logs..." )
return main.FALSE
@@ -220,7 +220,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
command = "sudo kill -SIGINT `pgrep ping`"
main.log.info( command )
self.execute( cmd=command, prompt="(.*)", timeout=10 )
@@ -231,11 +231,11 @@
self.execute( cmd=command, prompt="100%", timeout=20 )
# Make sure the output is cleared
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "" )
- i = self.handle.expect( [ "password", "\$" ] )
+ i = self.handle.expect( [ "password", self.prompt ] )
if i == 0:
main.log.error( "Error, sudo asking for password" )
main.log.error( self.handle.before )
@@ -260,12 +260,12 @@
def pingLongKill( self ):
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
command = "sudo kill -SIGING `pgrep ping`"
main.log.info( command )
self.execute( cmd=command, prompt="(.*)", timeout=10 )
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
return main.TRUE
except pexpect.TIMEOUT:
main.log.exception( self.name + ": TIMEOUT exception found in pingLongKill" )
@@ -330,7 +330,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
args = utilities.parse_args( [ "SRC", "TARGET" ], **pingParams )
command = "mininet/util/m " + \
args[ "SRC" ] + " ping " + args[ "TARGET" ] + " -c 4 -W 1 -i .2"
@@ -365,15 +365,15 @@
try:
if self.handle:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( 'ifconfig -a | grep "sw.. " | wc -l' )
self.handle.expect( "wc" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
response = self.handle.before
self.handle.sendline(
'ps -ef | grep "bash -ms mininet:sw" | grep -v color | wc -l' )
self.handle.expect( "color" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
response2 = self.handle.before
if re.search( num, response ):
@@ -424,7 +424,7 @@
self.handle.sendline( "" )
self.handle.sendline( "" )
i = self.handle.expect( [ 'No\ssuch\device', 'listening\son',
- pexpect.TIMEOUT, "\$" ], timeout=10 )
+ pexpect.TIMEOUT, self.prompt ], timeout=10 )
main.log.info( self.handle.before + self.handle.after )
if i == 0:
main.log.error( self.name + ": tcpdump - No such device exists.\
@@ -459,7 +459,7 @@
try:
self.handle.sendline( "sudo pkill tcpdump" )
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -487,9 +487,9 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "cd ~/" + name + "/tools/test/topos" )
- self.handle.expect( "topos\$" )
+ self.handle.expect( "topos"+ self.prompt )
if ctrllerIP == None:
main.log.info( "You need to specify the IP" )
return main.FALSE
@@ -531,7 +531,7 @@
"""
try:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "sudo ~/linc-oe/rel/linc/bin/linc attach" )
self.handle.expect( ">" )
return main.TRUE
@@ -548,8 +548,8 @@
if self.handle:
# Close the ssh connection
self.handle.sendline( "" )
- # self.handle.expect( "\$" )
- i = self.handle.expect( [ '\$', 'mininet>', pexpect.TIMEOUT,
+ # self.handle.expect( self.prompt )
+ i = self.handle.expect( [ self.prompt, 'mininet>', pexpect.TIMEOUT,
pexpect.EOF ], timeout=2 )
if i == 0:
self.handle.sendline( "exit" )
@@ -557,7 +557,7 @@
elif i == 1:
self.handle.sendline( "exit" )
self.handle.expect( "exit" )
- self.handle.expect('\$')
+ self.handle.expect(self.prompt)
self.handle.sendline( "exit" )
self.handle.expect( "exit" )
self.handle.expect( "closed" )
@@ -637,7 +637,7 @@
# at the time of writing this function )
# Check for existing rules on current input
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline(
"sudo iptables -C OUTPUT -p " +
str( packetType ) +
@@ -647,7 +647,7 @@
str( dstPort ) +
" -j " +
str( rule ) )
- i = self.handle.expect( [ "iptables:", "\$" ] )
+ i = self.handle.expect( [ "iptables:", self.prompt ] )
print i
print self.handle.before
print "after: "
@@ -656,7 +656,7 @@
elif actionType == 'remove':
# Check for existing rules on current input
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline(
"sudo iptables -C OUTPUT -p " +
str( packetType ) +
@@ -666,7 +666,7 @@
str( dstPort ) +
" -j " +
str( rule ) )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
print "before: "
print self.handle.before
actualString = self.handle.after
@@ -710,7 +710,7 @@
main.log.info( infoString )
self.handle.expect(
- [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
+ [ self.prompt, pexpect.EOF, pexpect.TIMEOUT ] )
except pexpect.TIMEOUT:
main.log.error(
self.name +
@@ -754,7 +754,7 @@
main.log.info( infoString )
self.handle.expect(
- [ "\$", pexpect.EOF, pexpect.TIMEOUT ] )
+ [ self.prompt, pexpect.EOF, pexpect.TIMEOUT ] )
except pexpect.TIMEOUT:
main.log.error(
self.name +
diff --git a/TestON/drivers/common/cli/emulator/scapyclidriver.py b/TestON/drivers/common/cli/emulator/scapyclidriver.py
index f1457ea..f61536c 100644
--- a/TestON/drivers/common/cli/emulator/scapyclidriver.py
+++ b/TestON/drivers/common/cli/emulator/scapyclidriver.py
@@ -38,7 +38,7 @@
ScapyCliDriver is the basic driver which will handle
the Scapy functions"""
def __init__( self ):
- super( Emulator, self ).__init__()
+ super( ScapyCliDriver, self ).__init__()
self.handle = self
self.name = None
self.home = None
@@ -147,7 +147,7 @@
try:
self.handle.sendline( "" )
i = self.handle.expect( [ '>>>',
- '\$',
+ self.prompt,
pexpect.EOF,
pexpect.TIMEOUT ],
timeout )
@@ -171,7 +171,7 @@
if fileName:
self.handle.sendline( "" )
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
self.handle.sendline(
"sudo kill -9 \`ps -ef | grep \"" +
fileName +
diff --git a/TestON/drivers/common/cli/emulatordriver.py b/TestON/drivers/common/cli/emulatordriver.py
index fb7a80d..206c935 100644
--- a/TestON/drivers/common/cli/emulatordriver.py
+++ b/TestON/drivers/common/cli/emulatordriver.py
@@ -26,10 +26,8 @@
"""
from drivers.common.clidriver import CLI
-
class Emulator( CLI ):
# The common functions for emulator included in emulatordriver
def __init__( self ):
- super( CLI, self ).__init__()
-
+ super( Emulator, self ).__init__()
\ No newline at end of file
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index b7a4439..032460b 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -41,9 +41,15 @@
self.name = None
self.home = None
self.handle = None
+ self.karafUser = None
+ self.karafPass = None
self.graph = Graph()
- super( CLI, self ).__init__()
+ super( OnosCliDriver, self ).__init__()
+ def checkOptions(self, var, defaultVar):
+ if var is None or var == "":
+ return defaultVar
+ return var
def connect( self, **connectargs ):
"""
Creates ssh handle for ONOS cli.
@@ -54,10 +60,15 @@
self.home = "~/onos"
for key in self.options:
if key == "home":
- self.home = self.options[ 'home' ]
- break
- if self.home is None or self.home == "":
- self.home = "~/onos"
+ self.home = self.options[ key ]
+ elif key == "karaf_username":
+ self.karafUser = self.options[ key ]
+ elif key == "karaf_password":
+ self.karafPass = self.options[ key ]
+
+ self.home = self.checkOptions(self.home, "~/onos")
+ self.karafUser = self.checkOptions(self.karafUser, self.user_name)
+ self.karafPass = self.checkOptions(self.karafPass, self.pwd )
for key in self.options:
if key == 'onosIp':
@@ -89,7 +100,7 @@
home=self.home )
self.handle.sendline( "cd " + self.home )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
if self.handle:
return self.handle
else:
@@ -118,7 +129,7 @@
i = self.logout()
if i == main.TRUE:
self.handle.sendline( "" )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "exit" )
self.handle.expect( "closed" )
except TypeError:
@@ -146,11 +157,11 @@
try:
if self.handle:
self.handle.sendline( "" )
- i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ],
+ i = self.handle.expect( [ "onos>", self.prompt, pexpect.TIMEOUT ],
timeout=10 )
if i == 0: # In ONOS CLI
self.handle.sendline( "logout" )
- j = self.handle.expect( [ "\$",
+ j = self.handle.expect( [ self.prompt,
"Command not found:",
pexpect.TIMEOUT ] )
if j == 0: # Successfully logged out
@@ -160,7 +171,7 @@
# or the command timed out
self.handle.send( "\x04" ) # send ctrl-d
try:
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
except pexpect.TIMEOUT:
main.log.error( "ONOS did not respond to 'logout' or CTRL-d" )
return main.TRUE
@@ -211,7 +222,7 @@
handleAfter = self.handle.after
# Get the rest of the handle
self.handle.sendline("")
- self.handle.expect("\$")
+ self.handle.expect(self.prompt)
handleMore = self.handle.before
main.log.info( "Cell call returned: " + handleBefore +
@@ -253,7 +264,7 @@
# Check if we are already in the cli
self.handle.sendline( "" )
x = self.handle.expect( [
- "\$", "onos>" ], commandlineTimeout)
+ self.prompt, "onos>" ], commandlineTimeout)
if x == 1:
main.log.info( "ONOS cli is already running" )
return main.TRUE
@@ -276,7 +287,7 @@
"config:property-set -p org.apache.karaf.shell\
sshIdleTimeout " +
karafTimeout )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( startCliCommand + str( ONOSIp ) )
self.handle.expect( "onos>" )
return main.TRUE
@@ -295,7 +306,7 @@
"config:property-set -p org.apache.karaf.shell\
sshIdleTimeout " +
karafTimeout )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( startCliCommand + str( ONOSIp ) )
self.handle.expect( "onos>" )
return main.TRUE
@@ -338,7 +349,7 @@
try:
self.handle.sendline( "" )
x = self.handle.expect( [
- "\$", "onos>" ], commandlineTimeout)
+ self.prompt, "onos>" ], commandlineTimeout)
if x == 1:
main.log.info( "ONOS cli is already running" )
@@ -357,7 +368,7 @@
"config:property-set -p org.apache.karaf.shell\
sshIdleTimeout " +
karafTimeout )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "/opt/onos/bin/onos" )
self.handle.expect( "onos>" )
return main.TRUE
@@ -376,7 +387,7 @@
"config:property-set -p org.apache.karaf.shell\
sshIdleTimeout " +
karafTimeout )
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
self.handle.sendline( "/opt/onos/bin/onos" )
self.handle.expect( "onos>" )
return main.TRUE
@@ -464,7 +475,7 @@
try:
# Try to reconnect if disconnected from cli
self.handle.sendline( "" )
- i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ] )
+ i = self.handle.expect( [ "onos>", self.prompt, pexpect.TIMEOUT ] )
if i == 1:
main.log.error( self.name + ": onos cli session closed. ")
if self.onosIp:
@@ -496,7 +507,7 @@
if dollarSign:
i = self.handle.expect( ["onos>"], timeout )
else:
- i = self.handle.expect( ["onos>", "\$"], timeout )
+ i = self.handle.expect( ["onos>", self.prompt], timeout )
response = self.handle.before
# TODO: do something with i
main.log.info( "Command '" + str( cmdStr ) + "' sent to "
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 805946b..454bd95 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -40,8 +40,7 @@
self.home = None
self.handle = None
self.nicAddr = None
- self.prompt = "\$"
- super( CLI, self ).__init__()
+ super( OnosDriver, self ).__init__()
def connect( self, **connectargs ):
"""
@@ -52,6 +51,7 @@
the ip address needed to ssh to the "bench"
"""
try:
+
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
self.home = "~/onos"
@@ -182,7 +182,7 @@
try:
self.handle.sendline( 'date +%s.%N' )
self.handle.expect( 'date \+\%s\.\%N' )
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
epochMs = self.handle.before
return epochMs
except Exception:
@@ -311,8 +311,8 @@
'Runtime\sEnvironment\sto\scontinue',
'BUILD\sFAILURE',
'BUILD\sSUCCESS',
- 'onos\$', #TODO: fix this to be more generic?
- 'ONOS\$',
+ 'onos' + self.prompt, #TODO: fix this to be more generic?
+ 'ONOS' + self.prompt,
pexpect.TIMEOUT ], mciTimeout )
if i == 0:
main.log.error( self.name + ":There is insufficient memory \
@@ -449,7 +449,7 @@
if i == 0:
main.log.error( self.name + ": Git pull had some issue" )
output = self.handle.after
- self.handle.expect( '\$' )
+ self.handle.expect( self.prompt )
output += self.handle.before
main.log.warn( output )
return main.ERROR
@@ -1733,7 +1733,7 @@
cmd += " old"
self.handle.sendline( cmd )
self.handle.expect( cmd )
- self.handle.expect( "\$ " )
+ self.handle.expect( self.prompt + " " )
response = self.handle.before
return response
except pexpect.EOF:
diff --git a/TestON/drivers/common/cli/ovsdbdriver.py b/TestON/drivers/common/cli/ovsdbdriver.py
index 150e5fa..2a7a919 100644
--- a/TestON/drivers/common/cli/ovsdbdriver.py
+++ b/TestON/drivers/common/cli/ovsdbdriver.py
@@ -24,7 +24,7 @@
self.name = None
self.home = None
self.handle = None
- super( CLI, self ).__init__()
+ super( OvsdbDriver, self ).__init__()
def connect( self, **connectargs ):
try:
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index 721ae6a..5a59d88 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -17,7 +17,7 @@
class QuaggaCliDriver( CLI ):
def __init__( self ):
- super( CLI, self ).__init__()
+ super( QuaggaCliDriver, self ).__init__()
# TODO: simplify this method
def connect( self, **connectargs ):
@@ -51,7 +51,7 @@
if self.handle:
# self.handle.expect( "",timeout=10 )
- # self.handle.expect( "\$",timeout=10 )
+ # self.handle.expect( self.prompt,timeout=10 )
self.handle.sendline( "telnet localhost 2605" )
# self.handle.expect( "Password:", timeout=5 )
self.handle.expect( "Password:" )
@@ -77,7 +77,7 @@
if self.handle:
# self.handle.expect( "" )
- # self.handle.expect( "\$" )
+ # self.handle.expect( self.prompt )
self.handle.sendline( "telnet localhost 2605" )
# self.handle.expect( "Password:", timeout=5 )
self.handle.expect( "Password:" )
@@ -460,7 +460,7 @@
if self.handle:
# self.handle.expect( "" )
- # self.handle.expect( "\$" )
+ # self.handle.expect( self.prompt )
main.log.info( "I in host " + str( ip_address ) )
main.log.info( pingTestFile + " > " + pingTestResultFile + " &" )
self.handle.sendline(
@@ -468,7 +468,7 @@
" > " +
pingTestResultFile +
" &" )
- self.handle.expect( "\$", timeout=60 )
+ self.handle.expect( self.prompt, timeout=60 )
handle = self.handle.before
return handle
diff --git a/TestON/drivers/common/cli/remotesysdriver.py b/TestON/drivers/common/cli/remotesysdriver.py
index a56f644..fae42ac 100644
--- a/TestON/drivers/common/cli/remotesysdriver.py
+++ b/TestON/drivers/common/cli/remotesysdriver.py
@@ -31,7 +31,7 @@
# The common functions for emulator included in emulatordriver
def __init__( self ):
- super( CLI, self ).__init__()
+ super( RemoteSysDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -48,13 +48,13 @@
pwd=self.pwd )
"""
if self.handle:
- self.execute( cmd= "\n",prompt= "\$|>|#",timeout= 10 )
+ self.execute( cmd= "\n",prompt= self.prompt,timeout= 10 )
self.execute( cmd= "ssh -l paxterra 10.128.4.1",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
self.execute( cmd= "\n",prompt= "paxterra@10.128.4.1's password:",timeout= 10 )
- self.execute( cmd="0nLab_gu3st",prompt="\$",timeout=10 )
- self.execute( cmd="cd TestON/bin/",prompt="\$",timeout=10 )
- self.execute( cmd="./cli.py run Assert example 1",prompt="\$",timeout=10 )
- self.execute( cmd= "\n",prompt= "$",timeout= 10 )
+ self.execute( cmd="0nLab_gu3st",prompt=self.prompt,timeout=10 )
+ self.execute( cmd="cd TestON/bin/",prompt=self.prompt,timeout=10 )
+ self.execute( cmd="./cli.py run Assert example 1",prompt=self.prompt,timeout=10 )
+ self.execute( cmd= "\n",prompt= self.prompt,timeout= 10 )
#self.execute( cmd="help",prompt=">",timeout=10 )
#self.execute( cmd="~.",prompt= ".*",timeout= 10 )
diff --git a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
index 4f55a90..68345e6 100644
--- a/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/floodlightclidriver.py
@@ -34,7 +34,7 @@
FloodLightCliDriver is the basic driver which will handle the Mininet functions
"""
def __init__( self ):
- super( RemoteTestBedDriver, self ).__init__()
+ super( FloodLightCliDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -51,16 +51,16 @@
pwd=self.pwd )
if self.handle:
main.log.info( "Connected " + self.name )
- self.execute( cmd="\r", prompt="\$", timeout=10 )
+ self.execute( cmd="\r", prompt=self.prompt, timeout=10 )
self.execute(
cmd="cd /home/openflow/floodlight/",
- prompt="floodlight\$",
+ prompt="floodlight" + self.prompt,
timeout=3 )
self.execute(
cmd="java -jar target/floodlight.jar &",
- prompt="\$",
+ prompt=self.prompt,
timeout=3 )
- self.execute( cmd="\r", prompt="\$", timeout=10 )
+ self.execute( cmd="\r", prompt=self.prompt, timeout=10 )
return self.handle
else:
return main.FALSE
diff --git a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
index 50100c9..0273a18 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotepoxdriver.py
@@ -35,7 +35,7 @@
RemoteVMDriver is the basic driver which will handle the Mininet functions
"""
def __init__( self ):
- super( RemoteTestBedDriver, self ).__init__()
+ super( RemotePoxDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -56,7 +56,7 @@
self.execute(
cmd="cd " +
self.options[ 'pox_lib_location' ],
- prompt="/pox\$",
+ prompt="/pox" + self.prompt,
timeout=120 )
self.execute(
cmd='./pox.py samples.of_tutorial',
@@ -67,6 +67,6 @@
def disconnect( self, handle ):
if self.handle:
- self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
+ self.execute( cmd="exit()", prompt="/pox" + self.prompt, timeout=120 )
else:
main.log.error( "Connection failed to the host" )
diff --git a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
index f4a1f1a..e8f4c00 100644
--- a/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
+++ b/TestON/drivers/common/cli/remotetestbed/remotevmdriver.py
@@ -37,7 +37,7 @@
RemoteVMDriver is the basic driver which will handle the Mininet functions
"""
def __init__( self ):
- super( RemoteTestBedDriver, self ).__init__()
+ super( RemoteVMDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -102,7 +102,7 @@
if i == 1:
main.log.info( "ssh connection asked for password, gave password" )
self.handle.sendline( self.pwd )
- self.handle.expect( '>|#|$' )
+ self.handle.expect( self.prompt )
elif i == 2:
main.log.error( "Connection timeout" )
diff --git a/TestON/drivers/common/cli/remotetestbeddriver.py b/TestON/drivers/common/cli/remotetestbeddriver.py
index ebf8fbe..3c0b109 100644
--- a/TestON/drivers/common/cli/remotetestbeddriver.py
+++ b/TestON/drivers/common/cli/remotetestbeddriver.py
@@ -31,7 +31,7 @@
# The common functions for emulator included in RemoteTestBedDriver
def __init__( self ):
- super( CLI, self ).__init__()
+ super( RemoteTestBedDriver, self ).__init__()
def connect( self, **connectargs ):
for key in connectargs:
@@ -53,9 +53,9 @@
pwd=remote_pwd )
if self.handle:
- self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
- self.execute( cmd="SET CYGWIN=notty", prompt="\$|>|#", timeout=10 )
- self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
+ self.execute( cmd="\n", prompt=self.prompt, timeout=10 )
+ self.execute( cmd="SET CYGWIN=notty", prompt=self.prompt, timeout=10 )
+ self.execute( cmd="\n", prompt=self.prompt, timeout=10 )
main.log.info(
"ssh " +
self.vm_user_name +
@@ -68,8 +68,8 @@
self.vm_ip_address,
prompt="(.*)",
timeout=10 )
- self.execute( cmd="\n", prompt="assword:", timeout=10 )
- self.execute( cmd=self.vm_pwd, prompt="\$", timeout=10 )
+ self.execute( cmd="\n", prompt="password:", timeout=10 )
+ self.execute( cmd=self.vm_pwd, prompt=self.prompt, timeout=10 )
return self.handle
else:
diff --git a/TestON/drivers/common/cli/tool/dpctlclidriver.py b/TestON/drivers/common/cli/tool/dpctlclidriver.py
index 683f16e..bb12089 100644
--- a/TestON/drivers/common/cli/tool/dpctlclidriver.py
+++ b/TestON/drivers/common/cli/tool/dpctlclidriver.py
@@ -84,7 +84,7 @@
cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + \
str( args[ "INPORT" ] ) + ",idle_timeout=" + str(
args[ "TIMEOUT" ] ) + ",actions=" + args[ "ACTION" ]
- response = self.execute( cmd=cmd, prompt="\~\$", timeout=60 )
+ response = self.execute( cmd=cmd, prompt="\~" + self.prompt, timeout=60 )
if utilities.assert_matches( expect="openflow", actual=response, onpass="Flow Added Successfully", onfail="Adding Flow Failed!!!" ):
return main.TRUE
else:
diff --git a/TestON/drivers/common/cli/toolsdriver.py b/TestON/drivers/common/cli/toolsdriver.py
index c96cb4f..a8f5d39 100644
--- a/TestON/drivers/common/cli/toolsdriver.py
+++ b/TestON/drivers/common/cli/toolsdriver.py
@@ -31,4 +31,4 @@
# The common functions for Tools included in toolsdriver
def __init__( self ):
- super( CLI, self ).__init__()
+ super( Tools, self ).__init__()
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index c9a19bb..f9b69bd 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -32,7 +32,12 @@
This will define common functions for CLI included.
"""
def __init__( self ):
- super( Component, self ).__init__()
+ super( CLI, self ).__init__()
+ def checkPrompt(self):
+ for key in self.options:
+ if key == "prompt" and self.options['prompt'] is not None:
+ self.prompt = self.options['prompt']
+ break
def connect( self, **connectargs ):
"""
@@ -42,6 +47,7 @@
"""
for key in connectargs:
vars( self )[ key ] = connectargs[ key ]
+ self.checkPrompt()
connect_result = super( CLI, self ).connect()
ssh_newkey = 'Are you sure you want to continue connecting'
@@ -80,7 +86,7 @@
pexpect.TIMEOUT,
refused,
'teston>',
- '>|#|\$' ],
+ self.prompt ],
120 )
if i == 0: # Accept key, then expect either a password prompt or access
main.log.info( "ssh key confirmation received, send yes" )
@@ -98,7 +104,7 @@
self.pwd = ""
self.handle.sendline( self.pwd )
j = self.handle.expect( [
- '>|#|\$',
+ self.prompt,
'password:|Password:',
pexpect.EOF,
pexpect.TIMEOUT ],
@@ -126,7 +132,7 @@
main.log.info( "Password not required logged in" )
self.handle.sendline( "" )
- self.handle.expect( '>|#|\$' )
+ self.handle.expect( self.prompt )
return self.handle
def disconnect( self ):
@@ -292,7 +298,7 @@
refused,
"No such file or directory",
"Permission denied",
- "\$",
+ self.prompt,
pexpect.EOF,
pexpect.TIMEOUT ],
120 )
@@ -330,7 +336,7 @@
"@" +
ipAddress )
returnVal = main.FALSE
- self.handle.expect( "\$" )
+ self.handle.expect( self.prompt )
return returnVal
def scp( self, remoteHost, filePath, dstPath, direction="from" ):
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index fc17d47..6021071 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -32,6 +32,7 @@
self.default = ''
self.wrapped = sys.modules[ __name__ ]
self.count = 0
+ self.prompt = "\$"
def __getattr__( self, name ):
"""