blob: c03db3d81201a32a44d8a424daa6e5065c6622b9 [file] [log] [blame]
Jon Hall05b2b432014-10-08 19:53:25 -04001#!/usr/bin/env python
andrewonlabe8e56fd2014-10-09 17:12:44 -04002
Jon Hall05b2b432014-10-08 19:53:25 -04003'''
andrewonlabe8e56fd2014-10-09 17:12:44 -04004This driver interacts with ONOS bench, the OSGi platform
5that configures the ONOS nodes. (aka ONOS-next)
6
7Please follow the coding style demonstrated by existing
8functions and document properly.
9
10If you are a contributor to the driver, please
11list your email here for future contact:
12
13jhall@onlab.us
14andrew@onlab.us
15
16OCT 9 2014
17
Jon Hall05b2b432014-10-08 19:53:25 -040018'''
andrewonlabe8e56fd2014-10-09 17:12:44 -040019
Jon Hallea7818b2014-10-09 14:30:59 -040020#TODO: Document
Jon Hall05b2b432014-10-08 19:53:25 -040021
andrewonlab7735d852014-10-09 13:02:47 -040022import sys
Jon Hall05b2b432014-10-08 19:53:25 -040023import time
24import pexpect
25import re
26import traceback
andrewonlab7735d852014-10-09 13:02:47 -040027import os.path
Jon Hall05b2b432014-10-08 19:53:25 -040028sys.path.append("../")
29from drivers.common.clidriver import CLI
30
31class OnosDriver(CLI):
32
33 def __init__(self):
34 super(CLI, self).__init__()
35
36 def connect(self,**connectargs):
37 '''
38 Creates ssh handle for ONOS "bench".
39 '''
40 try:
41 for key in connectargs:
42 vars(self)[key] = connectargs[key]
43 self.home = "~/ONOS"
44 for key in self.options:
45 if key == "home":
46 self.home = self.options['home']
47 break
48
49
50 self.name = self.options['name']
Jon Hallea7818b2014-10-09 14:30:59 -040051 self.handle = super(OnosDriver,self).connect(
52 user_name = self.user_name,
53 ip_address = self.ip_address,
54 port = self.port,
55 pwd = self.pwd,
56 home = self.home)
Jon Hallea7818b2014-10-09 14:30:59 -040057
58 self.handle.sendline("cd "+ self.home)
59 self.handle.expect("\$")
Jon Hall05b2b432014-10-08 19:53:25 -040060 if self.handle:
61 return self.handle
62 else :
63 main.log.info("NO ONOS HANDLE")
64 return main.FALSE
65 except pexpect.EOF:
66 main.log.error(self.name + ": EOF exception found")
67 main.log.error(self.name + ": " + self.handle.before)
68 main.cleanup()
69 main.exit()
70 except:
71 main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
72 main.log.error( traceback.print_exc() )
73 main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
74 main.cleanup()
75 main.exit()
76
77 def disconnect(self):
78 '''
79 Called when Test is complete to disconnect the ONOS handle.
80 '''
81 response = ''
82 try:
83 self.handle.sendline("exit")
84 self.handle.expect("closed")
85 except pexpect.EOF:
86 main.log.error(self.name + ": EOF exception found")
87 main.log.error(self.name + ": " + self.handle.before)
88 except:
89 main.log.error(self.name + ": Connection failed to the host")
90 response = main.FALSE
91 return response
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -040092
93 def onos_package(self):
94 '''
95 Produce a self-contained tar.gz file that can be deployed
96 and executed on any platform with Java 7 JRE.
97 '''
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -040098
99 try:
100 self.handle.sendline("onos-package")
Jon Hallea7818b2014-10-09 14:30:59 -0400101 self.handle.expect("onos-package")
andrewonlab0748d2a2014-10-09 13:24:17 -0400102 self.handle.expect("tar.gz",timeout=10)
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -0400103 handle = str(self.handle.before)
104 main.log.info("onos-package command returned: "+
105 handle)
andrewonlab0748d2a2014-10-09 13:24:17 -0400106 #As long as the sendline does not time out,
107 #return true. However, be careful to interpret
108 #the results of the onos-package command return
109 return main.TRUE
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -0400110
andrewonlab7735d852014-10-09 13:02:47 -0400111 except pexpect.EOF:
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -0400112 main.log.error(self.name + ": EOF exception found")
113 main.log.error(self.name + ": " + self.handle.before)
114 except:
115 main.log.error("Failed to package ONOS")
116 main.cleanup()
117 main.exit()
118
Jon Hallde9d9aa2014-10-08 20:36:02 -0400119 def clean_install(self):
120 '''
121 Runs mvn clean install in the root of the ONOS directory.
122 This will clean all ONOS artifacts then compile each module
andrew@onlab.us9e2cd0f2014-10-08 20:32:32 -0400123
Jon Hallde9d9aa2014-10-08 20:36:02 -0400124 Returns: main.TRUE on success
125 On Failure, exits the test
126 '''
127 try:
Jon Hallea7818b2014-10-09 14:30:59 -0400128 main.log.info("Running 'mvn clean install' on " + str(self.name) +
129 ". This may take some time.")
130 self.handle.sendline("cd "+ self.home)
131 self.handle.expect("\$")
132
133 self.handle.sendline("\n")
134 self.handle.expect("\$")
Jon Hallde9d9aa2014-10-08 20:36:02 -0400135 self.handle.sendline("mvn clean install")
Jon Hallea7818b2014-10-09 14:30:59 -0400136 self.handle.expect("mvn clean install")
Jon Hallde9d9aa2014-10-08 20:36:02 -0400137 while 1:
138 i=self.handle.expect([
139 'There\sis\sinsufficient\smemory\sfor\sthe\sJava\s\
140 Runtime\sEnvironment\sto\scontinue',
141 'BUILD\sFAILURE',
142 'BUILD\sSUCCESS',
143 'ONOS\$',
144 pexpect.TIMEOUT],timeout=600)
145 if i == 0:
146 main.log.error(self.name + ":There is insufficient memory \
147 for the Java Runtime Environment to continue.")
148 #return main.FALSE
149 main.cleanup()
150 main.exit()
151 if i == 1:
152 main.log.error(self.name + ": Build failure!")
153 #return main.FALSE
154 main.cleanup()
155 main.exit()
156 elif i == 2:
157 main.log.info(self.name + ": Build success!")
158 elif i == 3:
159 main.log.info(self.name + ": Build complete")
Jon Hallf8ef52c2014-10-09 19:37:33 -0400160 #Print the build time
161 for line in self.handle.before.splitlines():
162 if "Total time:" in line:
163 main.log.info(line)
Jon Hallea7818b2014-10-09 14:30:59 -0400164 self.handle.sendline("\n")
Jon Hallde9d9aa2014-10-08 20:36:02 -0400165 self.handle.expect("\$", timeout=60)
166 return main.TRUE
167 elif i == 4:
168 main.log.error(self.name + ": mvn clean install TIMEOUT!")
169 #return main.FALSE
170 main.cleanup()
171 main.exit()
172 else:
173 main.log.error(self.name + ": unexpected response from \
174 mvn clean install")
175 #return main.FALSE
176 main.cleanup()
177 main.exit()
178 except pexpect.EOF:
179 main.log.error(self.name + ": EOF exception found")
180 main.log.error(self.name + ": " + self.handle.before)
181 main.cleanup()
182 main.exit()
183 except:
184 main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
185 main.log.error( traceback.print_exc() )
186 main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
187 main.cleanup()
188 main.exit()
Jon Hallacabffd2014-10-09 12:36:53 -0400189
190 def git_pull(self, comp1=""):
191 '''
192 Assumes that "git pull" works without login
193
194 This function will perform a git pull on the ONOS instance.
195 If used as git_pull("NODE") it will do git pull + NODE. This is
196 for the purpose of pulling from other nodes if necessary.
197
198 Otherwise, this function will perform a git pull in the
199 ONOS repository. If it has any problems, it will return main.ERROR
200 If it successfully does a git_pull, it will return a 1.
201 If it has no updates, it will return a 0.
202
203 '''
204 try:
205 # main.log.info(self.name + ": Stopping ONOS")
206 #self.stop()
207 self.handle.sendline("cd " + self.home)
208 self.handle.expect("ONOS\$")
209 if comp1=="":
210 self.handle.sendline("git pull")
211 else:
212 self.handle.sendline("git pull " + comp1)
213
214 uptodate = 0
215 i=self.handle.expect(['fatal',
216 'Username\sfor\s(.*):\s',
217 '\sfile(s*) changed,\s',
218 'Already up-to-date',
219 'Aborting',
220 'You\sare\snot\scurrently\son\sa\sbranch',
221 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou',
222 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles',
223 pexpect.TIMEOUT],
224 timeout=300)
225 #debug
226 #main.log.report(self.name +": \n"+"git pull response: " + str(self.handle.before) + str(self.handle.after))
227 if i==0:
228 main.log.error(self.name + ": Git pull had some issue...")
229 return main.ERROR
230 elif i==1:
231 main.log.error(self.name + ": Git Pull Asking for username. ")
232 return main.ERROR
233 elif i==2:
234 main.log.info(self.name + ": Git Pull - pulling repository now")
235 self.handle.expect("ONOS\$", 120)
236 return 0
237 elif i==3:
238 main.log.info(self.name + ": Git Pull - Already up to date")
239 return 1
240 elif i==4:
241 main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?")
242 return main.ERROR
243 elif i==5:
244 main.log.info(self.name + ": Git Pull - You are not currently on a branch so git pull failed!")
245 return main.ERROR
246 elif i==6:
247 main.log.info(self.name + ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!")
248 return main.ERROR
249 elif i==7:
250 main.log.info(self.name + ": Git Pull - Pull is not possible because you have unmerged files.")
251 return main.ERROR
252 elif i==8:
253 main.log.error(self.name + ": Git Pull - TIMEOUT")
254 main.log.error(self.name + " Response was: " + str(self.handle.before))
255 return main.ERROR
256 else:
257 main.log.error(self.name + ": Git Pull - Unexpected response, check for pull errors")
258 return main.ERROR
259 except pexpect.EOF:
260 main.log.error(self.name + ": EOF exception found")
261 main.log.error(self.name + ": " + self.handle.before)
262 main.cleanup()
263 main.exit()
264 except:
265 main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
266 main.log.error( traceback.print_exc() )
267 main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
268 main.cleanup()
269 main.exit()
270
271 def git_checkout(self, branch="master"):
272 '''
273 Assumes that "git pull" works without login
274
275 This function will perform a git git checkout on the ONOS instance.
276 If used as git_checkout("branch") it will do git checkout of the "branch".
277
278 Otherwise, this function will perform a git checkout of the master
279 branch of the ONOS repository. If it has any problems, it will return
280 main.ERROR.
281 If the branch was already the specified branch, or the git checkout was
282 successful then the function will return main.TRUE.
283
284 '''
285 try:
286 # main.log.info(self.name + ": Stopping ONOS")
287 #self.stop()
288 self.handle.sendline("cd " + self.home)
289 self.handle.expect("ONOS\$")
290 if branch != 'master':
291 #self.handle.sendline('git stash')
292 #self.handle.expect('ONOS\$')
293 #print "After issuing git stash cmnd: ", self.handle.before
294 cmd = "git checkout "+branch
295 print "checkout cmd = ", cmd
296 self.handle.sendline(cmd)
297 uptodate = 0
298 i=self.handle.expect(['fatal',
299 'Username\sfor\s(.*):\s',
300 'Already\son\s\'',
301 'Switched\sto\sbranch\s\'',
302 pexpect.TIMEOUT],timeout=60)
303 else:
304 #self.handle.sendline('git stash apply')
305 #self.handle.expect('ONOS\$')
306 #print "After issuing git stash apply cmnd: ", self.handle.before
307 cmd = "git checkout "+branch
308 print "checkout cmd = ", cmd
309 self.handle.sendline(cmd)
310 uptodate = 0
311 switchedToMaster = 0
312 i=self.handle.expect(['fatal',
313 'Username\sfor\s(.*):\s',
314 'Already\son\s\'master\'',
315 'Switched\sto\sbranch\s\'master\'',
316 pexpect.TIMEOUT],timeout=60)
317
318
319 if i==0:
320 main.log.error(self.name + ": Git checkout had some issue...")
321 return main.ERROR
322 elif i==1:
323 main.log.error(self.name + ": Git checkout Asking for username!!! Bad!")
324 return main.ERROR
325 elif i==2:
326 main.log.info(self.name + ": Git Checkout %s : Already on this branch" %branch)
327 self.handle.expect("ONOS\$")
328 print "after checkout cmd = ", self.handle.before
329 switchedToMaster = 1
330 return main.TRUE
331 elif i==3:
332 main.log.info(self.name + ": Git checkout %s - Switched to this branch" %branch)
333 self.handle.expect("ONOS\$")
334 print "after checkout cmd = ", self.handle.before
335 switchedToMaster = 1
336 return main.TRUE
337 elif i==4:
338 main.log.error(self.name + ": Git Checkout- TIMEOUT")
339 main.log.error(self.name + " Response was: " + str(self.handle.before))
340 return main.ERROR
341 else:
342 main.log.error(self.name + ": Git Checkout - Unexpected response, check for pull errors")
343 return main.ERROR
344
345 except pexpect.EOF:
346 main.log.error(self.name + ": EOF exception found")
347 main.log.error(self.name + ": " + self.handle.before)
348 main.cleanup()
349 main.exit()
350 except:
351 main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
352 main.log.error( traceback.print_exc() )
353 main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
354 main.cleanup()
355 main.exit()
andrewonlab95ca1462014-10-09 14:04:24 -0400356
357 def set_cell(self, cellname):
358 '''
359 Calls 'cell <name>' to set the environment variables on ONOSbench
360 '''
361 try:
362 if not cellname:
363 main.log.error("Must define cellname")
364 main.cleanup()
365 main.exit()
366 else:
367 self.handle.sendline("cell "+str(cellname))
368 #Expect the cellname in the ONOS_CELL variable.
369 #Note that this variable name is subject to change
370 # and that this driver will have to change accordingly
371 self.handle.expect("ONOS_CELL="+str(cellname))
372 handle_before = self.handle.before
373 handle_after = self.handle.after
andrewonlabc03bf6c2014-10-09 14:56:18 -0400374 #Get the rest of the handle
375 self.handle.sendline("")
376 self.handle.expect("\$")
377 handle_more = self.handle.before
andrewonlab95ca1462014-10-09 14:04:24 -0400378
379 main.log.info("Cell call returned: "+handle_before+
andrewonlabc03bf6c2014-10-09 14:56:18 -0400380 handle_after + handle_more)
andrewonlab95ca1462014-10-09 14:04:24 -0400381
382 return main.TRUE
383
384 except pexpect.EOF:
385 main.log.error(self.name + ": EOF exception found")
386 main.log.error(self.name + ": " + self.handle.before)
387 main.cleanup()
388 main.exit()
389 except:
390 main.log.info(self.name+" ::::::")
391 main.log.error( traceback.print_exc())
392 main.log.info(self.name+" ::::::")
393 main.cleanup()
394 main.exit()
395
andrewonlabc03bf6c2014-10-09 14:56:18 -0400396 def verify_cell(self):
397 '''
398 Calls 'onos-verify-cell' to check for cell installation
399 '''
andrewonlab8d0d7d72014-10-09 16:33:15 -0400400 #TODO: Add meaningful expect value
401
andrewonlabc03bf6c2014-10-09 14:56:18 -0400402 try:
403 #Clean handle by sending empty and expecting $
404 self.handle.sendline("")
405 self.handle.expect("\$")
406 self.handle.sendline("onos-verify-cell")
407 self.handle.expect("\$")
408 handle_before = self.handle.before
409 handle_after = self.handle.after
410 #Get the rest of the handle
411 self.handle.sendline("")
412 self.handle.expect("\$")
413 handle_more = self.handle.before
414
415 main.log.info("Verify cell returned: "+handle_before+
416 handle_after + handle_more)
417
418 return main.TRUE
Jon Hall7993bfc2014-10-09 16:30:14 -0400419 except pexpect.EOF:
420 main.log.error(self.name + ": EOF exception found")
421 main.log.error(self.name + ": " + self.handle.before)
422 main.cleanup()
423 main.exit()
424 except:
425 main.log.info(self.name+" ::::::")
426 main.log.error( traceback.print_exc())
427 main.log.info(self.name+" ::::::")
428 main.cleanup()
429 main.exit()
430
431
432 def onos_install(self, options="-f", node = ""):
433 '''
434 Installs ONOS bits on the designated cell machine.
435 If -f option is provided, it also forces an uninstall.
436 Presently, install also includes onos-push-bits and
437 onos-config within.
438 The node option allows you to selectively only push the jar
439 files to certain onos nodes
440
441 Returns: main.TRUE on success and main.FALSE on failure
442 '''
443 try:
444 self.handle.sendline("onos-install " + options + " " + node)
445 self.handle.expect("onos-install ")
446 #NOTE: this timeout may need to change depending on the network and size of ONOS
447 i=self.handle.expect(["Network\sis\sunreachable",
448 "onos\sstart/running,\sprocess",
449 pexpect.TIMEOUT],timeout=60)
450
451
452 if i == 0:
453 main.log.warn("Network is unreachable")
454 return main.FALSE
455 elif i == 1:
456 main.log.info("ONOS was installed on the VM and started")
457 return main.TRUE
458 elif i == 2:
459 main.log.info("Installation of ONOS on the VM timed out")
460 return main.FALSE
andrewonlabc03bf6c2014-10-09 14:56:18 -0400461
462 except pexpect.EOF:
463 main.log.error(self.name + ": EOF exception found")
464 main.log.error(self.name + ": " + self.handle.before)
465 main.cleanup()
466 main.exit()
467 except:
468 main.log.info(self.name+" ::::::")
469 main.log.error( traceback.print_exc())
470 main.log.info(self.name+" ::::::")
471 main.cleanup()
472 main.exit()
andrewonlab95ca1462014-10-09 14:04:24 -0400473
andrewonlab8d0d7d72014-10-09 16:33:15 -0400474 def onos_start(self, node_ip):
475 '''
476 Calls onos command: 'onos-service [<node-ip>] start'
andrewonlabe8e56fd2014-10-09 17:12:44 -0400477 This command is a remote management of the ONOS upstart daemon
andrewonlab8d0d7d72014-10-09 16:33:15 -0400478 '''
479
480 try:
481 self.handle.sendline("")
482 self.handle.expect("\$")
483 self.handle.sendline("onos-service "+str(node_ip)+
484 " start")
485 i = self.handle.expect([
486 "Job\sis\salready\srunning",
487 "start/running",
488 "Unknown\sinstance",
489 pexpect.TIMEOUT],timeout=60)
490
491 if i == 0:
492 main.log.info("Service is already running")
493 return main.TRUE
494 elif i == 1:
495 main.log.info("ONOS service started")
496 return main.TRUE
497 else:
498 main.log.error("ONOS service failed to start")
499 main.cleanup()
500 main.exit()
andrewonlab8d0d7d72014-10-09 16:33:15 -0400501 except pexpect.EOF:
502 main.log.error(self.name + ": EOF exception found")
503 main.log.error(self.name + ": " + self.handle.before)
504 main.cleanup()
505 main.exit()
506 except:
507 main.log.info(self.name+" ::::::")
508 main.log.error( traceback.print_exc())
509 main.log.info(self.name+" ::::::")
510 main.cleanup()
511 main.exit()
512
andrewonlab2b30bd32014-10-09 16:48:55 -0400513 def onos_stop(self, node_ip):
514 '''
515 Calls onos command: 'onos-service [<node-ip>] stop'
andrewonlabe8e56fd2014-10-09 17:12:44 -0400516 This command is a remote management of the ONOS upstart daemon
andrewonlab2b30bd32014-10-09 16:48:55 -0400517 '''
518 try:
519 self.handle.sendline("")
520 self.handle.expect("\$")
521 self.handle.sendline("onos-service "+str(node_ip)+
522 " stop")
523 i = self.handle.expect([
524 "stop/waiting",
525 "Unknown\sinstance",
526 pexpect.TIMEOUT],timeout=60)
527
528 if i == 0:
529 main.log.info("ONOS service stopped")
530 return main.TRUE
531 elif i == 1:
532 main.log.info("Unknown ONOS instance specified: "+
533 str(node_ip))
534 return main.FALSE
535 else:
536 main.log.error("ONOS service failed to stop")
537 return main.FALSE
538
539 except pexpect.EOF:
540 main.log.error(self.name + ": EOF exception found")
541 main.log.error(self.name + ": " + self.handle.before)
542 main.cleanup()
543 main.exit()
544 except:
545 main.log.info(self.name+" ::::::")
546 main.log.error( traceback.print_exc())
547 main.log.info(self.name+" ::::::")
548 main.cleanup()
549 main.exit()
550
andrewonlabc8d47972014-10-09 16:52:36 -0400551 def onos_uninstall(self):
552 '''
553 Calls the command: 'onos-uninstall'
andrewonlabe8e56fd2014-10-09 17:12:44 -0400554 Uninstalls ONOS from the designated cell machine, stopping
555 if needed
andrewonlabc8d47972014-10-09 16:52:36 -0400556 '''
557 try:
558 self.handle.sendline("")
559 self.handle.expect("\$")
560 self.handle.sendline("onos-uninstall")
561 self.handle.expect("\$")
562
andrewonlab84727452014-10-09 18:15:36 -0400563 main.log.info("ONOS cell machine was uninstalled")
andrewonlabc8d47972014-10-09 16:52:36 -0400564 #onos-uninstall command does not return any text
565 return main.TRUE
566
567 except pexpect.EOF:
568 main.log.error(self.name + ": EOF exception found")
569 main.log.error(self.name + ": " + self.handle.before)
570 main.cleanup()
571 main.exit()
572 except:
573 main.log.info(self.name+" ::::::")
574 main.log.error( traceback.print_exc())
575 main.log.info(self.name+" ::::::")
576 main.cleanup()
577 main.exit()
andrewonlab2b30bd32014-10-09 16:48:55 -0400578
andrewonlabe8e56fd2014-10-09 17:12:44 -0400579 def onos_kill(self, node_ip):
580 '''
581 Calls the command: 'onos-kill [<node-ip>]'
582 "Remotely, and unceremoniously kills the ONOS instance running on
583 the specified cell machine" - Tom V
584 '''
585
586 try:
587 self.handle.sendline("")
588 self.handle.expect("\$")
589 self.handle.sendline("onos-kill " + str(node_ip))
590 i = self.handle.expect([
591 "\$",
592 "No\sroute\sto\shost",
593 "password:",
594 pexpect.TIMEOUT], timeout=20)
595
596 if i == 0:
597 main.log.info("ONOS instance "+str(node_ip)+" was killed")
598 return main.TRUE
599 elif i == 1:
600 main.log.info("No route to host")
601 return main.FALSE
602 elif i == 2:
603 main.log.info("Passwordless login for host: "+str(node_ip)+
604 " not configured")
605 return main.FALSE
606 else:
607 main.log.info("ONOS instasnce was not killed")
608 return main.FALSE
609
610 except pexpect.EOF:
611 main.log.error(self.name + ": EOF exception found")
612 main.log.error(self.name + ": " + self.handle.before)
613 main.cleanup()
614 main.exit()
615 except:
616 main.log.info(self.name+" ::::::")
617 main.log.error( traceback.print_exc())
618 main.log.info(self.name+" ::::::")
619 main.cleanup()
620 main.exit()
621
Jon Hall7993bfc2014-10-09 16:30:14 -0400622 def isup(self, node = ""):
623 '''
624 Run's onos-wait-for-start which only returns once ONOS is at run level 100(ready for use)
andrewonlab8d0d7d72014-10-09 16:33:15 -0400625
Jon Hall7993bfc2014-10-09 16:30:14 -0400626 Returns: main.TRUE if ONOS is running and main.FALSE on timeout
627 '''
628 try:
629 self.handle.sendline("onos-wait-for-start " + node )
630 self.handle.expect("onos-wait-for-start")
631 #NOTE: this timeout is arbitrary"
632 i = self.handle.expect(["\$", pexpect.TIMEOUT], timeout = 120)
633 if i == 0:
634 main.log.info(self.name + ": " + node + " is up")
635 return main.TRUE
636 elif i == 1:
637 #NOTE: since this function won't return until ONOS is ready,
638 # we will kill it on timeout
639 self.handle.sendline("\003") #Control-C
640 self.handle.expect("\$")
641 return main.FALSE
642 except pexpect.EOF:
643 main.log.error(self.name + ": EOF exception found")
644 main.log.error(self.name + ": " + self.handle.before)
645 main.cleanup()
646 main.exit()
647 except:
648 main.log.info(self.name+" ::::::")
649 main.log.error( traceback.print_exc())
650 main.log.info(self.name+" ::::::")
651 main.cleanup()
652 main.exit()