blob: 7f8a9d679d32d272adb0d4d01fa832c8a10a84b8 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001#!/usr/bin/env python
2'''
3Created on 26-Oct-2012
4
5@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
6
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20
21
22MininetCliDriver is the basic driver which will handle the Mininet functions
23'''
24
25import pexpect
26import struct
27import fcntl
28import os
29import signal
30import re
31import sys
32import core.teston
33sys.path.append("../")
34from drivers.common.cli.emulatordriver import Emulator
35from drivers.common.clidriver import CLI
36
37class MininetCliDriver(Emulator):
38 '''
Jon Hall41f40e82014-04-08 16:43:17 -070039 MininetCliDriver is the basic driver which will handle the Mininet functions
adminbae64d82013-08-01 10:50:15 -070040 '''
41 def __init__(self):
42 super(Emulator, self).__init__()
43 self.handle = self
44 self.wrapped = sys.modules[__name__]
45 self.flag = 0
46
47 def connect(self, **connectargs):
Jon Hall41f40e82014-04-08 16:43:17 -070048 '''
49 Here the main is the TestON instance after creating all the log handles.
50 '''
adminbae64d82013-08-01 10:50:15 -070051 for key in connectargs:
52 vars(self)[key] = connectargs[key]
53
54 self.name = self.options['name']
55 self.handle = super(MininetCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd)
56
57 self.ssh_handle = self.handle
58
adminbae64d82013-08-01 10:50:15 -070059 if self.handle :
Jon Hallf2942ce2014-04-10 16:00:16 -070060 main.log.info(self.name+": Clearing any residual state or processes")
adminbae64d82013-08-01 10:50:15 -070061 self.handle.sendline("sudo mn -c")
adminf939f8b2014-04-03 17:22:56 -070062 i=self.handle.expect(['password\sfor\s','Cleanup\scomplete',pexpect.EOF,pexpect.TIMEOUT],120)
adminbae64d82013-08-01 10:50:15 -070063 if i==0:
Jon Hallf2942ce2014-04-10 16:00:16 -070064 main.log.info(self.name+": Sending sudo password")
adminf939f8b2014-04-03 17:22:56 -070065 self.handle.sendline(self.pwd)
66 i=self.handle.expect(['%s:'%(self.user),'\$',pexpect.EOF,pexpect.TIMEOUT],120)
adminbae64d82013-08-01 10:50:15 -070067 if i==1:
Jon Hallf2942ce2014-04-10 16:00:16 -070068 main.log.info(self.name+": Clean")
adminbae64d82013-08-01 10:50:15 -070069 elif i==2:
Jon Hallf2942ce2014-04-10 16:00:16 -070070 main.log.error(self.name+": Connection terminated")
adminbae64d82013-08-01 10:50:15 -070071 elif i==3: #timeout
Jon Hallf2942ce2014-04-10 16:00:16 -070072 main.log.error(self.name+": Something while cleaning MN took too long... " )
adminbae64d82013-08-01 10:50:15 -070073
74 #cmdString = "sudo mn --topo "+self.options['topo']+","+self.options['topocount']+" --mac --switch "+self.options['switch']+" --controller "+self.options['controller']
75 #cmdString = "sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --controller remote --ip 192.168.56.102 --port 6633 --topo mytopo"
Jon Hallf2942ce2014-04-10 16:00:16 -070076 main.log.info(self.name+": building fresh mininet")
adminbeea0032014-01-23 14:54:13 -080077 #### for reactive/PARP enabled tests
admin07529932013-11-22 14:58:28 -080078 cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --controller " + self.options['controller']
adminbeea0032014-01-23 14:54:13 -080079 #### for proactive flow with static ARP entries
80 #cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --arp --controller " + self.options['controller']
adminbae64d82013-08-01 10:50:15 -070081 #resultCommand = self.execute(cmd=cmdString,prompt='mininet>',timeout=120)
82 self.handle.sendline(cmdString)
83 self.handle.expect("sudo mn")
84 while 1:
85 i=self.handle.expect(['mininet>','\*\*\*','Exception',pexpect.EOF,pexpect.TIMEOUT],300)
86 if i==0:
Jon Hallf2942ce2014-04-10 16:00:16 -070087 main.log.info(self.name+": mininet built")
adminbae64d82013-08-01 10:50:15 -070088 return main.TRUE
89 if i==1:
90 self.handle.expect("\n")
91 main.log.info(self.handle.before)
92 elif i==2:
Jon Hallf2942ce2014-04-10 16:00:16 -070093 main.log.error(self.name+": Launching mininet failed...")
adminbae64d82013-08-01 10:50:15 -070094 return main.FALSE
95 elif i==3:
Jon Hallf2942ce2014-04-10 16:00:16 -070096 main.log.error(self.name+": Connection timeout")
adminbae64d82013-08-01 10:50:15 -070097 return main.FALSE
98 elif i==4: #timeout
Jon Hallf2942ce2014-04-10 16:00:16 -070099 main.log.error(self.name+": Something took too long... " )
adminbae64d82013-08-01 10:50:15 -0700100 return main.FALSE
adminbae64d82013-08-01 10:50:15 -0700101 #if utilities.assert_matches(expect=patterns,actual=resultCommand,onpass="Network is being launched",onfail="Network launching is being failed "):
102 return main.TRUE
Jon Hallf2942ce2014-04-10 16:00:16 -0700103 else:#if no handle
104 main.log.error(self.name+": Connection failed to the host "+self.user_name+"@"+self.ip_address)
105 main.log.error(self.name+": Failed to connect to the Mininet")
adminbae64d82013-08-01 10:50:15 -0700106 return main.FALSE
107
108 def pingall(self):
109 '''
Jon Hall41f40e82014-04-08 16:43:17 -0700110 Verifies the reachability of the hosts using pingall command.
adminbae64d82013-08-01 10:50:15 -0700111 '''
112 if self.handle :
Jon Hallf2942ce2014-04-10 16:00:16 -0700113 main.log.info(self.name+": Checking reachabilty to the hosts using pingall")
adminbae64d82013-08-01 10:50:15 -0700114 response = self.execute(cmd="pingall",prompt="mininet>",timeout=10)
115 pattern = 'Results\:\s0\%\sdropped\s\(0\/\d+\slost\)\s*$'
Jon Hallf2942ce2014-04-10 16:00:16 -0700116 #if utilities.assert_matches(expect=pattern,actual=response,onpass="All hosts are reaching",onfail="Unable to reach all the hosts"):
117 if re.search(pattern,response):
118 main.log.info(self.name+": All hosts are reachable")
adminbae64d82013-08-01 10:50:15 -0700119 return main.TRUE
120 else:
Jon Hallf2942ce2014-04-10 16:00:16 -0700121 main.log.error(self.name+": Unable to reach all the hosts")
adminbae64d82013-08-01 10:50:15 -0700122 return main.FALSE
123 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700124 main.log.error(self.name+": Connection failed to the host")
adminbae64d82013-08-01 10:50:15 -0700125 return main.FALSE
adminaeedddd2013-08-02 15:14:15 -0700126
127 def fpingHost(self,**pingParams):
128 '''
129 Uses the fping package for faster pinging...
130 *requires fping to be installed on machine running mininet
131 '''
132 args = utilities.parse_args(["SRC","TARGET"],**pingParams)
admin530b4c92013-08-14 16:54:35 -0700133 command = args["SRC"] + " fping -i 100 -t 20 -C 1 -q "+args["TARGET"]
adminaeedddd2013-08-02 15:14:15 -0700134 self.handle.sendline(command)
135 self.handle.expect(args["TARGET"])
136 self.handle.expect("mininet")
137 response = self.handle.before
138 if re.search(":\s-" ,response):
Jon Hallf2942ce2014-04-10 16:00:16 -0700139 main.log.info(self.name+": Ping fail")
adminaeedddd2013-08-02 15:14:15 -0700140 return main.FALSE
admin530b4c92013-08-14 16:54:35 -0700141 elif re.search(":\s\d{1,2}\.\d\d", response):
Jon Hallf2942ce2014-04-10 16:00:16 -0700142 main.log.info(self.name+": Ping good!")
adminaeedddd2013-08-02 15:14:15 -0700143 return main.TRUE
Jon Hallf2942ce2014-04-10 16:00:16 -0700144 main.log.info(self.name+": Install fping on mininet machine... ")
145 main.log.info(self.name+": \n---\n"+response)
adminaeedddd2013-08-02 15:14:15 -0700146 return main.FALSE
adminbae64d82013-08-01 10:50:15 -0700147
148 def pingHost(self,**pingParams):
Jon Hallf2942ce2014-04-10 16:00:16 -0700149 '''
150 Ping from one mininet host to another
151 Currently the only supported Params: SRC and TARGET
152 '''
adminbae64d82013-08-01 10:50:15 -0700153 args = utilities.parse_args(["SRC","TARGET"],**pingParams)
154 #command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"]
Jon Hallf89c8552014-04-02 13:14:06 -0700155 command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1"
adminbae64d82013-08-01 10:50:15 -0700156 response = self.execute(cmd=command,prompt="mininet",timeout=10 )
Jon Hallf2942ce2014-04-10 16:00:16 -0700157 main.log.info(self.name+": Ping Response: "+ response )
158 #if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"):
159 if re.search(',\s0\%\spacket\sloss',response):
160 main.log.info(self.name+": NO PACKET LOSS, HOST IS REACHABLE")
adminbae64d82013-08-01 10:50:15 -0700161 main.last_result = main.TRUE
162 return main.TRUE
163 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700164 main.log.error(self.name+": PACKET LOST, HOST IS NOT REACHABLE")
adminbae64d82013-08-01 10:50:15 -0700165 main.last_result = main.FALSE
166 return main.FALSE
adminbae64d82013-08-01 10:50:15 -0700167
168 def checkIP(self,host):
169 '''
Jon Hall41f40e82014-04-08 16:43:17 -0700170 Verifies the host's ip configured or not.
adminbae64d82013-08-01 10:50:15 -0700171 '''
172 if self.handle :
173 response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
174
175 pattern = "inet\s(addr|Mask):([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})"
176 #pattern = "inet\saddr:10.0.0.6"
Jon Hallf2942ce2014-04-10 16:00:16 -0700177 #if utilities.assert_matches(expect=pattern,actual=response,onpass="Host Ip configured properly",onfail="Host IP not found") :
178 if re.search(pattern,response):
179 main.log.info(self.name+": Host Ip configured properly")
adminbae64d82013-08-01 10:50:15 -0700180 return main.TRUE
181 else:
Jon Hallf2942ce2014-04-10 16:00:16 -0700182 main.log.error(self.name+": Host IP not found")
adminbae64d82013-08-01 10:50:15 -0700183 return main.FALSE
184 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700185 main.log.error(self.name+": Connection failed to the host")
adminbae64d82013-08-01 10:50:15 -0700186
187 def verifySSH(self,**connectargs):
188 response = self.execute(cmd="h1 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10)
189 response = self.execute(cmd="h4 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10)
190 for key in connectargs:
191 vars(self)[key] = connectargs[key]
192 response = self.execute(cmd="xterm h1 h4 ",prompt="mininet>",timeout=10)
193 import time
194 time.sleep(20)
195 if self.flag == 0:
196 self.flag = 1
197 return main.FALSE
198 else :
199 return main.TRUE
200
201 def getMacAddress(self,host):
202 '''
Jon Hall41f40e82014-04-08 16:43:17 -0700203 Verifies the host's ip configured or not.
adminbae64d82013-08-01 10:50:15 -0700204 '''
205 if self.handle :
206 response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
207
Ahmed El-Hassanyf720e202014-04-04 16:11:36 -0700208 pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
209 mac_address_search = re.search(pattern, response, re.I)
210 mac_address = mac_address_search.group().split(" ")[1]
Jon Hallf2942ce2014-04-10 16:00:16 -0700211 main.log.info(self.name+": Mac-Address of Host "+ host + " is " + mac_address)
Ahmed El-Hassanyf720e202014-04-04 16:11:36 -0700212 return mac_address
adminbae64d82013-08-01 10:50:15 -0700213 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700214 main.log.error(self.name+": Connection failed to the host")
adminbae64d82013-08-01 10:50:15 -0700215 def getIPAddress(self,host):
216 '''
Jon Hall41f40e82014-04-08 16:43:17 -0700217 Verifies the host's ip configured or not.
adminbae64d82013-08-01 10:50:15 -0700218 '''
219 if self.handle :
220 response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10)
221
222 pattern = "inet\saddr:(\d+\.\d+\.\d+\.\d+)"
223 ip_address_search = re.search(pattern, response)
Jon Hallf2942ce2014-04-10 16:00:16 -0700224 main.log.info(self.name+": IP-Address of Host "+host +" is "+ip_address_search.group(1))
adminbae64d82013-08-01 10:50:15 -0700225 return ip_address_search.group(1)
226 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700227 main.log.error(self.name+": Connection failed to the host")
adminbae64d82013-08-01 10:50:15 -0700228
229 def dump(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700230 main.log.info(self.name+": Dump node info")
Ahmed El-Hassanyd1f71702014-04-04 16:12:45 -0700231 response = self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10)
232 return response
adminbae64d82013-08-01 10:50:15 -0700233
234 def intfs(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700235 main.log.info(self.name+": List interfaces")
Jon Hall668ed802014-04-08 17:17:59 -0700236 response = self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10)
237 return response
adminbae64d82013-08-01 10:50:15 -0700238
239 def net(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700240 main.log.info(self.name+": List network connections")
Jon Hall668ed802014-04-08 17:17:59 -0700241 response = self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10)
242 return response
adminbae64d82013-08-01 10:50:15 -0700243
244 def iperf(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700245 main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
Jon Hall668ed802014-04-08 17:17:59 -0700246 response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10)
247 return response
adminbae64d82013-08-01 10:50:15 -0700248
249 def iperfudp(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700250 main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts")
Jon Hall668ed802014-04-08 17:17:59 -0700251 response = self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10)
252 return response
adminbae64d82013-08-01 10:50:15 -0700253
254 def nodes(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700255 main.log.info(self.name+": List all nodes.")
Jon Hall668ed802014-04-08 17:17:59 -0700256 response = self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10)
257 return response
adminbae64d82013-08-01 10:50:15 -0700258
259 def pingpair(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700260 main.log.info(self.name+": Ping between first two hosts")
261 response = self.execute(cmd = 'pingpair',prompt = 'mininet>',timeout = 20)
adminbae64d82013-08-01 10:50:15 -0700262
Jon Hallf2942ce2014-04-10 16:00:16 -0700263 #if utilities.assert_matches(expect='0% packet loss',actual=response,onpass="No Packet loss",onfail="Hosts not reachable"):
264 if re.search(',\s0\%\spacket\sloss',response):
265 main.log.info(self.name+": Ping between two hosts SUCCESSFUL")
adminbae64d82013-08-01 10:50:15 -0700266 main.last_result = main.TRUE
267 return main.TRUE
268 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700269 main.log.error(self.name+": PACKET LOST, HOSTS NOT REACHABLE")
adminbae64d82013-08-01 10:50:15 -0700270 main.last_result = main.FALSE
271 return main.FALSE
272
273 def link(self,**linkargs):
274 '''
275 Bring link(s) between two nodes up or down
276 '''
277 main.log.info('Bring link(s) between two nodes up or down')
278 args = utilities.parse_args(["END1","END2","OPTION"],**linkargs)
279 end1 = args["END1"] if args["END1"] != None else ""
280 end2 = args["END2"] if args["END2"] != None else ""
281 option = args["OPTION"] if args["OPTION"] != None else ""
282 command = "link "+str(end1) + " " + str(end2)+ " " + str(option)
283 response = self.execute(cmd=command,prompt="mininet>",timeout=10)
284 return main.TRUE
285
286
admin530b4c92013-08-14 16:54:35 -0700287 def yank(self,**yankargs):
adminaeedddd2013-08-02 15:14:15 -0700288 '''
admin530b4c92013-08-14 16:54:35 -0700289 yank a mininet switch interface to a host
adminaeedddd2013-08-02 15:14:15 -0700290 '''
admin530b4c92013-08-14 16:54:35 -0700291 main.log.info('Yank the switch interface attached to a host')
292 args = utilities.parse_args(["SW","INTF"],**yankargs)
adminaeedddd2013-08-02 15:14:15 -0700293 sw = args["SW"] if args["SW"] !=None else ""
294 intf = args["INTF"] if args["INTF"] != None else ""
295 command = "py "+ str(sw) + '.detach("' + str(intf) + '")'
296 response = self.execute(cmd=command,prompt="mininet>",timeout=10)
297 return main.TRUE
298
299 def plug(self, **plugargs):
300 '''
301 plug the yanked mininet switch interface to a switch
302 '''
303 main.log.info('Plug the switch interface attached to a switch')
admin530b4c92013-08-14 16:54:35 -0700304 args = utilities.parse_args(["SW","INTF"],**plugargs)
adminaeedddd2013-08-02 15:14:15 -0700305 sw = args["SW"] if args["SW"] !=None else ""
306 intf = args["INTF"] if args["INTF"] != None else ""
307 command = "py "+ str(sw) + '.attach("' + str(intf) + '")'
308 response = self.execute(cmd=command,prompt="mininet>",timeout=10)
309 return main.TRUE
310
311
312
adminbae64d82013-08-01 10:50:15 -0700313 def dpctl(self,**dpctlargs):
314 '''
Jon Hall41f40e82014-04-08 16:43:17 -0700315 Run dpctl command on all switches.
adminbae64d82013-08-01 10:50:15 -0700316 '''
317 main.log.info('Run dpctl command on all switches')
318 args = utilities.parse_args(["CMD","ARGS"],**dpctlargs)
319 cmd = args["CMD"] if args["CMD"] != None else ""
320 cmdargs = args["ARGS"] if args["ARGS"] != None else ""
321 command = "dpctl "+cmd + " " + str(cmdargs)
322 response = self.execute(cmd=command,prompt="mininet>",timeout=10)
323 return main.TRUE
324
325
326 def get_version(self):
327 file_input = path+'/lib/Mininet/INSTALL'
328 version = super(Mininet, self).get_version()
329 pattern = 'Mininet\s\w\.\w\.\w\w*'
330 for line in open(file_input,'r').readlines():
331 result = re.match(pattern, line)
332 if result:
333 version = result.group(0)
334 return version
335
336 def get_sw_controller(self,sw):
337 command = "sh ovs-vsctl get-controller "+str(sw)
338 main.log.info(self.execute(cmd=command,prompt="mininet>",timeout=10))
339
340 def assign_sw_controller(self,**kwargs):
Jon Hallf89c8552014-04-02 13:14:06 -0700341 '''
342 count is only needed if there is more than 1 controller
343 '''
344 args = utilities.parse_args(["COUNT"],**kwargs)
345 count = args["COUNT"] if args!={} else 1
346
347 argstring = "SW"
348 for j in range(count):
349 argstring = argstring + ",IP" + str(j+1) + ",PORT" + str(j+1)
350 args = utilities.parse_args(argstring.split(","),**kwargs)
351
adminbae64d82013-08-01 10:50:15 -0700352 sw = args["SW"] if args["SW"] != None else ""
admin530b4c92013-08-14 16:54:35 -0700353 ptcpA = int(args["PORT1"])+int(sw) if args["PORT1"] != None else ""
Jon Hallf89c8552014-04-02 13:14:06 -0700354 ptcpB = "ptcp:"+str(ptcpA) if ptcpA != "" else ""
355
356 command = "sh ovs-vsctl set-controller s" + str(sw) + " " + ptcpB + " "
357 for j in range(count):
358 i=j+1
359 args = utilities.parse_args(["IP"+str(i),"PORT"+str(i)],**kwargs)
360 ip = args["IP"+str(i)] if args["IP"+str(i)] != None else ""
361 port = args["PORT" + str(i)] if args["PORT" + str(i)] != None else ""
362 tcp = "tcp:" + str(ip) + ":" + str(port) + " " if ip != "" else ""
363 command = command + tcp
adminbae64d82013-08-01 10:50:15 -0700364 self.execute(cmd=command,prompt="mininet>",timeout=5)
365
366 def disconnect(self):
Jon Hallf2942ce2014-04-10 16:00:16 -0700367 main.log.info(self.name+": Disconnecting mininet...")
adminbae64d82013-08-01 10:50:15 -0700368 response = ''
369 if self.handle:
370 response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
371 response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
372
373 else :
Jon Hallf2942ce2014-04-10 16:00:16 -0700374 main.log.error(self.name+": Connection failed to the host")
adminbae64d82013-08-01 10:50:15 -0700375 response = main.FALSE
376 return response
377
378 def ctrl_none(self):
379 #self.execute(cmd="sh ~/ONOS/scripts/test-ctrl-none.sh", prompt="mininet",timeout=20)
380 self.handle.sendline()
381 self.handle.expect("mininet>")
382 self.handle.sendline("sh ~/ONOS/scripts/test-ctrl-none.sh")
383 self.handle.expect("test-ctrl-none")
384 self.handle.expect("mininet>", 20)
385
386 def ctrl_all(self):
387 self.execute(cmd="sh ~/ONOS/scripts/test-ctrl-add-ext.sh", prompt="mininet",timeout=20)
388
389 def ctrl_divide(self):
390 self.execute(cmd="sh ~/ONOS/scripts/ctrl-divide.sh ", prompt="mininet",timeout=20)
391
392 def ctrl_local(self):
393 self.execute(cmd="sh ~/ONOS/scripts/test-ctrl-local.sh ", prompt="mininet",timeout=20)
394
395 def ctrl_one(self, ip):
396 self.execute(cmd="sh ~/ONOS/scripts/ctrl-one.sh "+ip, prompt="mininet",timeout=20)
admin07529932013-11-22 14:58:28 -0800397
398 def arping(self, src, dest, destmac):
399 self.handle.sendline('')
400 self.handle.expect("mininet")
401
402 self.handle.sendline(src + ' arping ' + dest)
403 try:
404 self.handle.expect(destmac)
Jon Hallf2942ce2014-04-10 16:00:16 -0700405 main.log.info(self.name+": ARP successful")
admin07529932013-11-22 14:58:28 -0800406 self.handle.expect("mininet")
407 return main.TRUE
408 except:
Jon Hallf2942ce2014-04-10 16:00:16 -0700409 main.log.warn(self.name+": ARP FAILURE")
admin07529932013-11-22 14:58:28 -0800410 self.handle.expect("mininet")
411 return main.FALSE
412
413 def decToHex(num):
414 return hex(num).split('x')[1]
adminbae64d82013-08-01 10:50:15 -0700415
416if __name__ != "__main__":
417 import sys
418 sys.modules[__name__] = MininetCliDriver()