Adding a newline command in set_cell function at the end
diff --git a/TestON/drivers/common/cli/emulator/lincoedriver.py b/TestON/drivers/common/cli/emulator/lincoedriver.py
index 6f7ce3a..8da1700 100644
--- a/TestON/drivers/common/cli/emulator/lincoedriver.py
+++ b/TestON/drivers/common/cli/emulator/lincoedriver.py
@@ -10,6 +10,7 @@
list your email here for future contact:
andrew@onlab.us
+ shreya@onlab.us
OCT 20 2014
'''
@@ -23,6 +24,7 @@
import re
import sys
import core.teston
+import time
sys.path.append("../")
from math import pow
from drivers.common.cli.emulatordriver import Emulator
@@ -60,9 +62,16 @@
if self.handle :
main.log.info("Handle successfully created")
self.home = "~/linc-oe"
+
self.handle.sendline("cd "+self.home)
self.handle.expect("oe$")
-
+
+ #self.handle.sendline("pgrep -g linc")
+ #self.handle.expect("\$")
+ print "handle = ", self.handle.before
+
+ return main.TRUE
+ '''
main.log.info("Building Linc-OE")
self.handle.sendline("make rel")
i = self.handle.expect(["ERROR","linc-oe\$"],timeout=60)
@@ -73,15 +82,15 @@
x = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT])
main.log.info("make rel returned: "+ str(x))
else:
- main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
- time.sleep(30)
- self.handle.sendline("sudo ./rel/linc/bin/linc console")
- j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
-
+
+ main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
+ time.sleep(30)
+ self.handle.sendline("sudo ./rel/linc/bin/linc console")
+ j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
if j == 0:
main.log.info("Linc-OE CLI started")
return main.TRUE
-
+ '''
else:
main.log.error(self.name+
": Connection failed to the host "+
@@ -90,6 +99,26 @@
": Failed to connect to Linc-OE")
return main.FALSE
+
+ def start_console(self):
+ import time
+ main.log.info(self.name+": Starting Linc-OE CLI.. This may take a while")
+ time.sleep(30)
+ self.handle.sendline("sudo ./rel/linc/bin/linc console")
+ j = self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
+ start_result = self.handle.before
+ if j == 0:
+ main.log.info("Linc-OE CLI started")
+ return main.TRUE
+ else:
+ main.log.error(self.name+
+ ": Connection failed to the host "+self.user_name+"@"+self.ip_address)
+ main.log.error(self.name+
+ ": Failed to connect to Linc-OE")
+ return main.FALSE
+
+
+
def build(self):
'''
Build Linc-OE with the specified settings
@@ -285,18 +314,42 @@
main.log.info(self.name+" :::::::")
main.cleanup()
main.exit()
+
+ def stopLincOEConsole(self):
+ '''
+ This function is only used for packet optical testing
+ Send disconnect prompt to Linc-OE CLI
+ (CTRL+C) and kill the linc process
+ '''
+ try:
+ cmd = "pgrep -f linc"
+ self.handle.sendline("pgrep -f linc")
+ self.handle.expect("linc")
+ print "stophandle = ", self.handle.before
+ except pexpect.EOF:
+ main.log.error(self.name+ ": EOF exception")
+ main.log.error(self.name+ ": " + self.handle.before)
def disconnect(self):
'''
Send disconnect prompt to Linc-OE CLI
- (CTRL+C)
+ (CTRL+C) and kill the linc process
'''
try:
#Send CTRL+C twice to exit CLI
self.handle.send("\x03")
self.handle.send("\x03")
self.handle.expect("\$")
-
+ handle1 = self.handle.before
+ cmd = "pgrep -f linc"
+ self.handle.sendline(cmd)
+ self.handle.expect("\$")
+ handle2 = self.handle.before
+ main.log.info("pid's = "+handle2)
+ cmd = "sudo kill -9 `pgrep -f linc`"
+ self.handle.sendline(cmd)
+ self.handle.expect("\$")
+
except pexpect.EOF:
main.log.error(self.name+ ": EOF exception")
main.log.error(self.name+ ": " + self.handle.before)
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 2f31b7d..92ec312 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -287,7 +287,47 @@
return main.FALSE
else :
return main.TRUE
+
+
+
+ def changeIP(self,host,intf,newIP,newNetmask):
+ '''
+ Changes the ip address of a host on the fly
+ Ex: h2 ifconfig h2-eth0 10.0.1.2 netmask 255.255.255.0
+ '''
+ if self.handle:
+ try:
+ cmd = host+" ifconfig "+intf+" "+newIP+" "+newNetMask
+ self.handle.sendline(cmd)
+ self.handle.expect("mininet>")
+ response = self.handle.before
+ main.log.info("Ip of host "+host+" changed to new IP "+newIP)
+ return main.TRUE
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ return main.FALSE
+
+ def changeDefaultGateway(self,host,newGW):
+ '''
+ Changes the default gateway of a host
+ Ex: h1 route add default gw 10.0.1.2
+ '''
+ if self.handle:
+ try:
+ cmd = host+" route add default gw "+newGW
+ self.handle.sendline(cmd)
+ self.handle.expect("mininet>")
+ response = self.handle.before
+ main.log.info("Default gateway of host "+host+" changed to "+newGW)
+ return main.TRUE
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ return main.FALSE
+
+
def getMacAddress(self,host):
'''
Verifies the host's ip configured or not.
@@ -443,17 +483,40 @@
main.cleanup()
main.exit()
return response
-
- def iperf(self):
+ '''
+ def iperf(self,host1,host2):
main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
try:
- response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
+ if not host1 and not host2:
+ response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
+ else:
+ cmd1 = 'iperf '+ host1 + " " + host2
+ response = self.execute(cmd = cmd1, prompt = '>',timeout = 20)
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
main.log.error(self.name + ": " + self.handle.before)
main.cleanup()
main.exit()
return response
+ '''
+ def iperf(self,host1,host2):
+ main.log.info(self.name+": Simple iperf TCP test between two hosts")
+ try:
+ cmd1 = 'iperf '+ host1 + " " + host2
+ self.handle.sendline(cmd1)
+ self.handle.expect("mininet>")
+ response = self.handle.before
+ if re.search('Results:',response):
+ main.log.info(self.name+": iperf test succssful")
+ return main.TRUE
+ else:
+ main.log.error(self.name+": iperf test failed")
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.error(self.name + ": EOF exception found")
+ main.log.error(self.name + ": " + self.handle.before)
+ main.cleanup()
+ main.exit()
def iperfudp(self):
main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index e2625cf..991bdf3 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -873,6 +873,8 @@
timeout=120)
if i == 1:
return main.FALSE
+ self.handle.sendline("")
+ self.handle.expect("\$")
return main.TRUE
except pexpect.EOF:
@@ -1099,21 +1101,26 @@
str(dir_file))
- def run_onos_topo_cfg(self):
+ def run_onos_topo_cfg(self, instance_name, json_file):
'''
- On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+ On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg $OC1 filename
which starts the rest and copies the json file to the onos instance
'''
- self.handle.sendline("")
- self.handle.expect("\$")
- self.handle.sendline("cd ~/ONOS/tools/test/bin")
- self.handle.expect("/bin$")
- self.handle.sendline("./onos-topo-cfg")
- self.handle.expect("{}")
- self.handle.sendline("cd ~")
- self.handle.expect("\$")
-
-
+ try:
+ self.handle.sendline("")
+ self.handle.expect("\$")
+ self.handle.sendline("cd ~/ONOS/tools/test/bin")
+ self.handle.expect("/bin$")
+ cmd = "./onos-topo-cfg " +instance_name +" " +json_file
+ print "cmd = ", cmd
+ self.handle.sendline(cmd)
+ self.handle.expect("$")
+ self.handle.sendline("cd ~")
+ self.handle.expect("\$")
+ return main.TRUE
+ except:
+ return main.FALSE
+
def tshark_grep(self, grep, directory, interface='eth0'):
'''
Required: