blob: 3aab38b1ba1df7d9d116610a4ba344978754834c [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001#!/usr/bin/env python
2'''
3Created on 31-May-2013
4
5@author: Anil Kumar (anilkumar.s@paxterrasolutions.com)
6
7 TestON is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12 TestON is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with TestON. If not, see <http://www.gnu.org/licenses/>.
19
20
21'''
22import time
23import pexpect
24import struct, fcntl, os, sys, signal
25import sys
26import re
27import json
28sys.path.append("../")
29from drivers.common.clidriver import CLI
30
31class OnosCliDriver(CLI):
32
33 def __init__(self):
34 super(CLI, self).__init__()
35
36 def connect(self,**connectargs):
37 '''
38 Creates ssh handle for ONOS.
39 '''
40 for key in connectargs:
41 vars(self)[key] = connectargs[key]
42
43
44 self.name = self.options['name']
45 self.handle = super(OnosCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd)
46
47 if self.handle:
48 #self.start()
49 #self.start_rest()
50 return self.handle
51 else :
52 main.log.info("NO HANDLE")
53 return main.FALSE
54
55 def start(self):
56 '''
57 Starts ONOS on remote machine.
58 Returns false if any errors were encountered.
59 '''
60 self.handle.sendline("")
61 self.handle.expect("\$")
admin530b4c92013-08-14 16:54:35 -070062 self.handle.sendline("~/ONOS/start-onos.sh start")
adminaeedddd2013-08-02 15:14:15 -070063 self.handle.expect("onos.sh start")
adminbae64d82013-08-01 10:50:15 -070064 i=self.handle.expect(["Starting\sONOS\scontroller","Cassandra\sis\snot\srunning"])
65 if i==0:
adminaeedddd2013-08-02 15:14:15 -070066 try:
admin530b4c92013-08-14 16:54:35 -070067 self.handle.expect("\$", timeout=60)
adminbae64d82013-08-01 10:50:15 -070068 main.log.info("ONOS Started ")
adminaeedddd2013-08-02 15:14:15 -070069 except:
adminbae64d82013-08-01 10:50:15 -070070 main.log.info("ONOS NOT Started, stuck while waiting for it to start ")
71 return main.FALSE
adminaeedddd2013-08-02 15:14:15 -070072 return main.TRUE
adminbae64d82013-08-01 10:50:15 -070073 elif i==1:
74 main.log.error("ONOS didn't start because cassandra wasn't running.")
75 return main.FALSE
76
77 main.log.error("ONOS expect script missed something... ")
78 return main.FALSE
admine0ae8202013-08-28 11:51:43 -070079
80 def start_embedded(self):
81 self.handle.sendline("")
82 self.handle.expect("\$")
83 self.handle.sendline("~/ONOS/start-onos-embedded.sh start")
84 try:
85 self.handle.expect("start...")
86 main.log.info("Embedded ONOS started")
87 except:
88 main.log.info("Embedded ONOS failed to start")
89
adminbae64d82013-08-01 10:50:15 -070090 def link_down(self, **linkParams):
91 '''
92 Specifically used for the ONOS demo on the HW.
93 Should be replaced by actual switch drivers in the future.
94 '''
95 args = utilities.parse_args(["SDPID","SPORT","DDPID","DPORT"], **linkParams)
96 sdpid = args["SDPID"] if args["SDPID"] != None else "00:00:00:00:ba:5e:ba:13"
97 sport = args["SPORT"] if args["SPORT"] != None else "22"
98 ddpid = args["DDPID"] if args["DDPID"] != None else "00:00:20:4e:7f:51:8a:35"
99 dport = args["DPORT"] if args["DPORT"] != None else "22"
100
101 cmd = "curl -s 10.128.4.11:9000/gui/link/down/" + sdpid + "/" + sport + "/" + ddpid + "/" + dport + " > /tmp/log &"
102 os.popen( cmd )
103
104 def link_up(self, **linkParams):
105 '''
106 Specifically used for the ONOS demo on the HW.
107 Should be replaced by actual switch drivers in the future.
108 '''
109 args = utilities.parse_args(["SDPID","SPORT","DDPID","DPORT"], **linkParams)
110 sdpid = args["SDPID"] if args["SDPID"] != None else "00:00:00:00:ba:5e:ba:13"
111 sport = args["SPORT"] if args["SPORT"] != None else "22"
112 ddpid = args["DDPID"] if args["DDPID"] != None else "00:00:20:4e:7f:51:8a:35"
113 dport = args["DPORT"] if args["DPORT"] != None else "22"
114
115 cmd = "curl -s 10.128.4.11:9000/gui/link/up/" + sdpid + "/" + sport + "/" + ddpid + "/" + dport + " > /tmp/log &"
116 os.popen( cmd )
117
118 def start_rest(self):
119 '''
120 Starts the rest server on ONOS.
121 '''
admin530b4c92013-08-14 16:54:35 -0700122 response = self.execute(cmd="~/ONOS/start-rest.sh start",prompt="\$",timeout=10)
adminbae64d82013-08-01 10:50:15 -0700123 if re.search("admin",response):
124 main.log.info("Rest Server Started Successfully")
125 time.sleep(5)
126 return main.TRUE
127 else :
128 main.log.warn("Failed to start Rest Server")
129 return main.FALSE
130
131 def status(self):
132 '''
133 Called start-onos.sh status and returns TRUE/FALSE accordingly
134 '''
135 self.execute(cmd="\r",prompt="\$",timeout=10)
136 response = self.execute(cmd="~/ONOS/start-onos.sh status ",prompt="\d+\sinstance\sof\sonos\srunning",timeout=10)
137 self.execute(cmd="\r",prompt="\$",timeout=10)
138 if re.search("1\sinstance\sof\sonos\srunning",response):
139 return main.TRUE
140 elif re.search("0\sinstance\sof\sonos\srunning",response):
141 return main.FALSE
142 else :
143 return main.FALSE
144
145 def isup(self):
146 '''
147 A more complete check to see if ONOS is up and running properly.
148 First, it checks if the process is up.
149 Second, it reads the logs for "Exception: Connection refused"
150 Third, it makes sure the logs are actually moving.
151 returns TRUE/FALSE accordingly.
152 '''
153 self.execute(cmd="\r",prompt="\$",timeout=10)
154 response = self.execute(cmd="~/ONOS/start-onos.sh status ",prompt="running",timeout=10)
155 self.execute(cmd="\r",prompt="\$",timeout=10)
156 tail1 = self.execute(cmd="tail ~/ONOS/onos-logs/onos.*.log",prompt="\$",timeout=10)
admin07529932013-11-22 14:58:28 -0800157 time.sleep(30)
adminbae64d82013-08-01 10:50:15 -0700158 self.execute(cmd="\r",prompt="\$",timeout=10)
159 tail2 = self.execute(cmd="tail ~/ONOS/onos-logs/onos.*.log",prompt="\$",timeout=10)
160 pattern = '(.*)1 instance(.*)'
161 pattern2 = '(.*)Exception: Connection refused(.*)'
162 if utilities.assert_matches(expect=pattern,actual=response,onpass="ONOS process is running...",onfail="ONOS process not running..."):
163 if tail1 == tail2:
164 main.log.error("ONOS is frozen...")
165 return main.FALSE
166 elif re.search( pattern2,tail1 ):
167 main.log.info("Connection Refused found in onos log")
168 return main.FALSE
169 elif re.search( pattern2,tail2 ):
170 main.log.info("Connection Refused found in onos log")
171 return main.FALSE
172 else:
173 main.log.info("Onos log is moving! It's looking good!")
174 return main.TRUE
175 else:
176 return main.FALSE
177
178
179 def rest_status(self):
180 '''
181 Checks if the rest server is running.
182 '''
183 response = self.execute(cmd="~/ONOS/start-rest.sh status ",prompt="running",timeout=10)
184 if re.search("rest\sserver\sis\srunning",response):
185 main.log.info("Rest Server is running")
186 elif re.search("rest\sserver\sis\snot\srunning",response):
187 main.log.warn("Rest Server is not Running")
188 else :
189 main.log.error("No response" +response)
190 self.execute(cmd="\r",prompt="\$",timeout=10)
191
192 return response
193
194 def stop(self):
195 '''
196 Runs ./start-onos.sh stop to stop ONOS
197 '''
198 self.handle.sendline("")
199 self.handle.expect("\$")
admin530b4c92013-08-14 16:54:35 -0700200 self.handle.sendline("~/ONOS/start-onos.sh stop")
adminbae64d82013-08-01 10:50:15 -0700201 self.handle.expect("stop", 2)
adminaeedddd2013-08-02 15:14:15 -0700202 result = self.handle.before
admin530b4c92013-08-14 16:54:35 -0700203 self.handle.expect("\$", 60)
adminaeedddd2013-08-02 15:14:15 -0700204 if re.search("Killed", result):
adminbae64d82013-08-01 10:50:15 -0700205 main.log.info("ONOS Killed Successfully")
206 return main.TRUE
207 else :
208 main.log.warn("ONOS wasn't running")
209 return main.FALSE
210
211 def rest_stop(self):
212 '''
213 Runs ./start-rest.sh stop to stop ONOS rest server
214 '''
215 response = self.execute(cmd="~/ONOS/start-rest.sh stop ",prompt="killing",timeout=10)
216 self.execute(cmd="\r",prompt="\$",timeout=10)
217 if re.search("killing", response):
218 main.log.info("Rest Server Stopped")
219 return main.TRUE
220 else :
221 main.log.error("Failed to Stop, Rest Server is not Running")
222 return main.FALSE
223
224 def disconnect(self):
225 '''
adminaeedddd2013-08-02 15:14:15 -0700226 Called when Test is complete to disconnect the ONOS handle.
adminbae64d82013-08-01 10:50:15 -0700227 '''
adminaeedddd2013-08-02 15:14:15 -0700228 response = ''
229 try:
adminbae64d82013-08-01 10:50:15 -0700230 self.handle.sendline("exit")
adminaeedddd2013-08-02 15:14:15 -0700231 self.handle.expect("closed")
232 except:
adminbae64d82013-08-01 10:50:15 -0700233 main.log.error("Connection failed to the host")
234 response = main.FALSE
adminaeedddd2013-08-02 15:14:15 -0700235 return response
236
adminbae64d82013-08-01 10:50:15 -0700237 def get_version(self):
238 '''
239 Writes the COMMIT number to the report to be parsed by Jenkins data collecter.
240 '''
241 self.handle.sendline("cat /home/admin/ONOS/.git/ORIG_HEAD")
242 self.handle.expect("ORIG_HEAD")
243 self.handle.expect("\$")
244 main.log.report( "COMMIT: " + str(self.handle.before + self.handle.after))
245
246 def add_flow(self, path):
247 '''
248 Copies the flowdef file from TestStation -> ONOS machine
249 Then runs ./add_flow.py to add the flows to ONOS
250 '''
251 main.log.info("Adding Flows...")
252 self.handle.sendline("scp admin@10.128.7.7:%s /tmp/flowtmp" % path)
253 self.handle.expect("100%")
254 self.handle.expect("\$", 30)
255 self.handle.sendline("~/ONOS/web/add_flow.py -m onos -f /tmp/flowtmp")
256 self.handle.expect("add_flow")
257 self.handle.expect("\$", 1000)
258 main.log.info("Flows added")
259
260 def delete_flow(self, *delParams):
261 '''
262 Deletes a specific flow, a range of flows, or all flows.
263 '''
264 if len(delParams)==1:
265 if str(delParams[0])=="all":
266 main.log.info("Deleting ALL flows...")
267 #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh all",prompt="done",timeout=150)
268 self.handle.sendline("~/ONOS/web/delete_flow.py all")
269 self.handle.expect("delete_flow")
270 self.handle.expect("\$",1000)
adminbae64d82013-08-01 10:50:15 -0700271 main.log.info("Flows deleted")
272 else:
273 main.log.info("Deleting flow "+str(delParams[0])+"...")
274 #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh "+str(delParams[0]),prompt="done",timeout=150)
275 #self.execute(cmd="\n",prompt="\$",timeout=60)
276 self.handle.sendline("~/ONOS/web/delete_flow.py %d" % int(delParams[0]))
277 self.handle.expect("delete_flow")
278 self.handle.expect("\$",60)
adminbae64d82013-08-01 10:50:15 -0700279 main.log.info("Flow deleted")
280 elif len(delParams)==2:
281 main.log.info("Deleting flows "+str(delParams[0])+" through "+str(delParams[1])+"...")
282 #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh "+str(delParams[0])+" "+str(delParams[1]),prompt="done",timeout=150)
283 #self.execute(cmd="\n",prompt="\$",timeout=60)
284 self.handle.sendline("~/ONOS/web/delete_flow.py %d %d" % (int(delParams[0]), int(delParams[1])))
285 self.handle.expect("delete_flow")
286 self.handle.expect("\$",600)
adminbae64d82013-08-01 10:50:15 -0700287 main.log.info("Flows deleted")
288
289 def check_flow(self):
290 '''
291 Calls the ./get_flow.py all and checks:
292 - If each FlowPath has at least one FlowEntry
293 - That there are no "NOT"s found
294 returns TRUE/FALSE
295 '''
296 flowEntryDetect = 1
297 count = 0
298 self.handle.sendline("clear")
299 time.sleep(1)
300 self.handle.sendline("~/ONOS/web/get_flow.py all")
301 self.handle.expect("get_flow")
302 while 1:
303 i=self.handle.expect(['FlowPath','FlowEntry','NOT','\$',pexpect.TIMEOUT],timeout=180)
304 if i==0:
305 count = count + 1
306 if flowEntryDetect == 0:
307 main.log.info("FlowPath without FlowEntry")
308 return main.FALSE
309 else:
310 flowEntryDetect = 0
311 elif i==1:
312 flowEntryDetect = 1
313 elif i==2:
314 main.log.error("Found a NOT")
315 return main.FALSE
316 elif i==3:
317 if count == 0:
318 main.log.info("There don't seem to be any flows here...")
319 return main.FALSE
320 else:
321 main.log.info("All flows pass")
322 main.log.info("Number of FlowPaths: "+str(count))
323 return main.TRUE
324 elif i==4:
325 main.log.error("Command Timeout!")
326 return main.FALSE
327
328 def get_flow(self, *flowParams):
329 '''
330 Returns verbose output of ./get_flow.py
331 '''
332 if len(flowParams)==1:
333 if str(flowParams[0])=="all":
334 self.execute(cmd="\n",prompt="\$",timeout=60)
335 main.log.info("Getting all flow data...")
336 data = self.execute(cmd="~/ONOS/scripts/TestON_get_flow.sh all",prompt="done",timeout=150)
337 self.execute(cmd="\n",prompt="\$",timeout=60)
338 return data
339 else:
340 main.log.info("Retrieving flow "+str(flowParams[0])+" data...")
341 data = self.execute(cmd="~/ONOS/scripts/TestON_get_flow.sh "+str(flowParams[0]),prompt="done",timeout=150)
342 self.execute(cmd="\n",prompt="\$",timeout=60)
343 return data
344 elif len(flowParams)==5:
345 main.log.info("Retrieving flow installer data...")
346 data = self.execute(cmd="~/ONOS/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3])+" "+str(flowParams[4]),prompt="done",timeout=150)
347 self.execute(cmd="\n",prompt="\$",timeout=60)
348 return data
349 elif len(flowParams)==4:
350 main.log.info("Retrieving flow endpoints...")
351 data = self.execute(cmd="~/ONOS/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3]),prompt="done",timeout=150)
352 self.execute(cmd="\n",prompt="\$",timeout=60)
353 return data
354
355
356# http://localhost:8080/wm/core/topology/switches/all/json
357# http://localhost:8080/wm/core/topology/links/json
358# http://localhost:8080/wm/registry/controllers/json
359# http://localhost:8080/wm/registry/switches/json"
360
361 def get_json(self, url):
362 '''
363 Helper functions used to parse the json output of a rest call
364 '''
365 try:
366 command = "curl -s %s" % (url)
367 result = os.popen(command).read()
368 parsedResult = json.loads(result)
369 except:
370 print "REST IF %s has issue" % command
371 parsedResult = ""
372
373 if type(parsedResult) == 'dict' and parsedResult.has_key('code'):
374 print "REST %s returned code %s" % (command, parsedResult['code'])
375 parsedResult = ""
376 return parsedResult
377
378 def check_switch(self,RestIP,correct_nr_switch ):
379 '''
380 Used by check_status
381 '''
382 buf = ""
383 retcode = 0
384 RestPort="8080"
385 url="http://%s:%s/wm/core/topology/switches/all/json" % (RestIP, RestPort)
386 parsedResult = self.get_json(url)
387 if parsedResult == "":
388 retcode = 1
389 return (retcode, "Rest API has an issue")
390 url = "http://%s:%s/wm/registry/switches/json" % (RestIP, RestPort)
391 registry = self.get_json(url)
392
393 if registry == "":
394 retcode = 1
395 return (retcode, "Rest API has an issue")
396
397 cnt = 0
398 active = 0
399
400 for s in parsedResult:
401 cnt += 1
402 if s['state'] == "ACTIVE":
403 active += 1
404
405 buf += "switch: network %d : %d switches %d active\n" % (0+1, cnt, active)
406 if correct_nr_switch != cnt:
407 buf += "switch fail: network %d should have %d switches but has %d\n" % (1, correct_nr_switch, cnt)
408 retcode = 1
409
410 if correct_nr_switch != active:
411 buf += "switch fail: network %d should have %d active switches but has %d\n" % (1, correct_nr_switch, active)
412 retcode = 1
413
414 return (retcode, buf)
415
416 def check_link(self,RestIP, nr_links):
417 '''
418 Used by check_status
419 '''
420 RestPort = "8080"
421 buf = ""
422 retcode = 0
423
424 url = "http://%s:%s/wm/core/topology/links/json" % (RestIP, RestPort)
425 parsedResult = self.get_json(url)
426
427 if parsedResult == "":
428 retcode = 1
429 return (retcode, "Rest API has an issue")
430
431 buf += "link: total %d links (correct : %d)\n" % (len(parsedResult), nr_links)
432 intra = 0
433 interlink=0
434
435 for s in parsedResult:
436 intra = intra + 1
437
438 if intra != nr_links:
439 buf += "link fail\n"
440 retcode = 1
441
442 return (retcode, buf)
443
444 def check_status_report(self, ip, numoswitch, numolink):
445 '''
446 Checks the number of swithes & links that ONOS sees against the supplied values.
447 Writes to the report log.
448 '''
449 main.log.info("Making some rest calls...")
450 switch = self.check_switch(ip, int(numoswitch))
451 link = self.check_link(ip, int(numolink))
452 value = switch[0]
453 value += link[0]
454 main.log.report( "\n-----\n%s%s-----\n" % ( switch[1], link[1]) )
455 if value != 0:
456 return 0
457 else:
458 # "PASS"
459 return 1
460
461 def check_status(self, ip, numoswitch, numolink):
462 '''
463 Checks the number of swithes & links that ONOS sees against the supplied values.
464 Writes to the main log.
465 '''
466 main.log.info("Making some rest calls...")
467 switch = self.check_switch(ip, int(numoswitch))
468 link = self.check_link(ip, int(numolink))
469 value = switch[0]
470 value += link[0]
471 main.log.info( "\n-----\n%s%s-----\n" % ( switch[1], link[1]) )
472 if value != 0:
473 return 0
474 else:
475 # "PASS"
476 return 1
477
478 def drop_keyspace(self):
479 '''
480 Drops the ONOS keyspace
481 '''
482 self.handle.sendline("~/ONOS/scripts/test-drop-keyspace.sh")
483 self.handle.expect("keyspace")
484 self.handle.sendline("")
485 self.handle.expect("\$")
486 self.handle.expect("\$")
admin07529932013-11-22 14:58:28 -0800487 main.log.info("Keyspace dropped")
adminbae64d82013-08-01 10:50:15 -0700488
489 def ctrl_none(self):
490 '''
491 Points all the mininet swithces to no controllers
492 *NOTE will only work if CLUSTER is set up on ONOS nodes
493 '''
494 self.execute(cmd="switch none", prompt="\$",timeout=10)
495
496 def ctrl_one(self, ip):
497 '''
498 Points all the mininet swithces to all controllers
499 *NOTE will only work if CLUSTER is set up on ONOS nodes
500 '''
501 self.execute(cmd="switch one", prompt="\$",timeout=10)
502
503 def check_for_no_exceptions(self):
504 '''
505 Used by CassndraCheck.py to scan ONOS logs for Exceptions
506 '''
admin530b4c92013-08-14 16:54:35 -0700507 self.handle.sendline("dsh 'grep Exception ~/ONOS/onos-logs/onos.*.log'")
adminbae64d82013-08-01 10:50:15 -0700508 self.handle.expect("\$ dsh")
509 self.handle.expect("\$")
510 output = self.handle.before
511 main.log.info( output )
512 if re.search("Exception",output):
513 return main.FALSE
514 else :
515 return main.TRUE
516
517 def git_pull(self):
518 '''
519 Stops the ONOS, pulls the latest code, and builds with mvn.
520 Assumes that "git pull" works without login
521 '''
522 main.log.info("Stopping onos")
523 self.stop()
524 self.handle.sendline("cd ~/ONOS")
525 self.handle.expect("ONOS\$")
526 self.handle.sendline("git pull")
admin530b4c92013-08-14 16:54:35 -0700527
528 uptodate = 0
admin07529932013-11-22 14:58:28 -0800529 i=self.handle.expect(['fatal','Username\sfor\s(.*):\s','Unpacking\sobjects',pexpect.TIMEOUT,'Already up-to-date','Aborting'],timeout=60)
adminbae64d82013-08-01 10:50:15 -0700530 if i==0:
531 main.log.error("Git pull had some issue...")
532 return main.FALSE
533 elif i==1:
534 main.log.error("Asking for username!!! BADD!")
535 return false
536
537 self.handle.expect('Password\sfor\s(.*):\s')
538 j = self.handle.expect(['Unpacking\sobjects','Already up-to-date'])
539 if j == 0:
540 main.log.info("pulling repository now")
541 elif j == 1:
542 main.log.info("Up to date!")
543 else:
544 main.log.error("something went wrong")
545 return main.FALSE
546 self.handle.expect("ONOS\$", 30)
547 elif i==2:
548 main.log.info("pulling repository now")
549 self.handle.expect("ONOS\$", 30)
550 elif i==3:
551 main.log.error("TIMEOUT")
552 return main.FALSE
553 elif i==4:
admin530b4c92013-08-14 16:54:35 -0700554 main.log.info("Already up to date")
555 uptodate = 1
adminbae64d82013-08-01 10:50:15 -0700556 elif i==5:
557 main.log.info("Aborting... Are there conflicting git files?")
558 return main.FALSE
559
admin530b4c92013-08-14 16:54:35 -0700560 '''
adminbae64d82013-08-01 10:50:15 -0700561 main.log.info("./setup-local-maven.sh")
562 self.handle.sendline("./setup-local-maven.sh")
563 self.handle.expect("local-maven.sh")
564 while 1:
565 i=self.handle.expect(['BUILD\sFAILURE','BUILD\sSUCCESS','ONOS\$',pexpect.TIMEOUT],timeout=90)
566 if i == 0:
567 main.log.error("Build failure!")
568 return main.FALSE
569 elif i == 1:
570 main.log.info("Build success!")
571 elif i == 2:
572 main.log.info("Build complete")
573 break;
574 elif i == 3:
575 main.log.error("TIMEOUT!")
576 return main.FALSE
admin530b4c92013-08-14 16:54:35 -0700577 '''
578 if uptodate == 0:
579 main.log.info("mvn clean")
580 self.handle.sendline("mvn clean")
581 while 1:
582 i=self.handle.expect(['BUILD\sFAILURE','BUILD\sSUCCESS','ONOS\$',pexpect.TIMEOUT],timeout=30)
583 if i == 0:
584 main.log.error("Build failure!")
585 return main.FALSE
586 elif i == 1:
587 main.log.info("Build success!")
588 elif i == 2:
589 main.log.info("Build complete")
590 break;
591 elif i == 3:
592 main.log.error("TIMEOUT!")
593 return main.FALSE
adminbae64d82013-08-01 10:50:15 -0700594
admin530b4c92013-08-14 16:54:35 -0700595 main.log.info("mvn compile")
596 self.handle.sendline("mvn compile")
597 while 1:
598 i=self.handle.expect(['BUILD\sFAILURE','BUILD\sSUCCESS','ONOS\$',pexpect.TIMEOUT],timeout=30)
599 if i == 0:
600 main.log.error("Build failure!")
601 return main.FALSE
602 elif i == 1:
603 main.log.info("Build success!")
604 elif i == 2:
605 main.log.info("Build complete")
606 break;
607 elif i == 3:
608 main.log.error("TIMEOUT!")
609 return main.FALSE
admin4a58db92013-09-30 12:04:54 -0700610
611 def tcpdump(self):
612 self.handle.sendline("")
613 self.handle.expect("\$")
614 self.handle.sendline("sudo tcpdump -n -i eth0 -s0 -w onos-logs/tcpdump &")
615
616 def kill_tcpdump(self):
617 self.handle.sendline("")
618 self.handle.expect("\$")
619 self.handle.sendline("sudo kill -9 `ps -ef | grep \"tcpdump -n\" | grep -v grep | awk '{print $2}'`")