andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 1 | |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 2 | def __init__( self ): |
| 3 | self.ip = '127.0.0.1' |
| 4 | |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 5 | def checkOnosLog( nodeIp, option='', |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 6 | outputType=0): |
| 7 | """ |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 8 | Listens to the log for any Errors and Exceptions. |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 9 | |
| 10 | Runs 'onos-check-logs <option>' |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 11 | This script only returns if there are any errors |
| 12 | or exceptions |
| 13 | |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 14 | outputType |
| 15 | 0: Return output of log |
| 16 | 1: Return (#Errors, #Exceptions, #Warn) |
| 17 | |
| 18 | """ |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 19 | if not isinstance( option, basestring ): |
| 20 | main.log.error( 'Incorrect grep format specified' ) |
| 21 | return main.FALSE |
| 22 | |
| 23 | try: |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 24 | main.log.info( 'Starting Onos-log listening for '+ |
| 25 | str(option) ) |
| 26 | cmd = 'onos-check-logs ' + str(nodeIp) + ' old' |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 27 | if outputType == 0: |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 28 | main.ONOSbench.handle.sendline( cmd ) |
| 29 | main.ONOSbench.handle.expect( cmd ) |
| 30 | main.ONOSbench.handle.expect('\$') |
| 31 | logResult = main.ONOSbench.handle.before |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 32 | return logResult |
| 33 | elif outputType == 1: |
| 34 | # Important in assertion criteria |
| 35 | # to determine how much warn / error is |
| 36 | # acceptable |
| 37 | return 'Implement option 1' |
| 38 | else: |
| 39 | main.log.error( 'Incorrect outputType specified' ) |
| 40 | return main.FALSE |
| 41 | |
| 42 | except Exception: |
| 43 | main.log.exception( self.name + ': Uncaught exception' ) |
| 44 | main.cleanup() |
| 45 | main.exit() |
| 46 | |
| 47 | def setLogLevel( level ): |
| 48 | """ |
| 49 | Set the log level of onos |
| 50 | """ |
| 51 | main.log.info( 'setLogLevel implement me' ) |
| 52 | |
andrew@onlab.us | 484ef83 | 2015-05-29 16:08:27 -0400 | [diff] [blame] | 53 | def getLogReport( nodeIp, searchTerms ): |
| 54 | """ |
| 55 | Refer to CLI driver for 'logReport' |
| 56 | """ |
| 57 | main.log.info( 'getLogReport - implement me!' ) |