admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | ''' |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 3 | Created on 31-May-2013 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 4 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 5 | @author: Anil Kumar (anilkumar.s@paxterrasolutions.com) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 6 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 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. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 11 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 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. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 16 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 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/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 19 | |
| 20 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 21 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 22 | import time |
| 23 | import pexpect |
| 24 | import struct, fcntl, os, sys, signal |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 25 | import re |
| 26 | import json |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 27 | import traceback |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 28 | import urllib2 |
| 29 | from urllib2 import URLError, HTTPError |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 30 | sys.path.append("../") |
| 31 | from drivers.common.clidriver import CLI |
| 32 | |
| 33 | class OnosCliDriver(CLI): |
| 34 | |
| 35 | def __init__(self): |
| 36 | super(CLI, self).__init__() |
| 37 | |
| 38 | def connect(self,**connectargs): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 39 | ''' |
| 40 | Creates ssh handle for ONOS. |
| 41 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 42 | try: |
| 43 | for key in connectargs: |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 44 | vars(self)[key] = connectargs[key] |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 45 | self.home = "~/ONOS" |
| 46 | for key in self.options: |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 47 | if key == "home": |
| 48 | self.home = self.options['home'] |
| 49 | break |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 50 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 51 | |
| 52 | self.name = self.options['name'] |
| 53 | self.handle = super(OnosCliDriver,self).connect(user_name = self.user_name, ip_address = self.ip_address,port = self.port, pwd = self.pwd, home = self.home) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 54 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 55 | if self.handle: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 56 | return self.handle |
| 57 | else : |
| 58 | main.log.info("NO ONOS HANDLE") |
| 59 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 60 | except pexpect.EOF: |
| 61 | main.log.error(self.name + ": EOF exception found") |
| 62 | main.log.error(self.name + ": " + self.handle.before) |
| 63 | main.cleanup() |
| 64 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 65 | except: |
| 66 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 67 | main.log.error( traceback.print_exc() ) |
| 68 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 69 | main.cleanup() |
| 70 | main.exit() |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 71 | |
| 72 | def portKill(self, port): |
| 73 | try: |
| 74 | self.handle.sendline("") |
| 75 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 76 | cmd = "sudo tcpkill -i eth0 port " + str(port) + " 2>/dev/null 1>/dev/null &" |
| 77 | self.handle.sendline(cmd) |
| 78 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 79 | except pexpect.EOF: |
| 80 | main.log.error(self.name + ": EOF exception found") |
| 81 | main.log.error(self.name + ": " + self.handle.before) |
| 82 | main.cleanup() |
| 83 | main.exit() |
| 84 | except: |
| 85 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 86 | main.log.error( traceback.print_exc() ) |
| 87 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 88 | main.cleanup() |
| 89 | main.exit() |
| 90 | |
| 91 | def endPortKill(self,port): |
| 92 | try: |
| 93 | self.handle.sendline("") |
| 94 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 95 | self.handle.sendline("sudo pkill tcpkill") |
| 96 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 97 | except pexpect.EOF: |
| 98 | main.log.error(self.name + ": EOF exception found") |
| 99 | main.log.error(self.name + ": " + self.handle.before) |
| 100 | main.cleanup() |
| 101 | main.exit() |
| 102 | except: |
| 103 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 104 | main.log.error( traceback.print_exc() ) |
| 105 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 106 | main.cleanup() |
| 107 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 108 | |
Jon Hall | f0a494f | 2014-06-23 15:37:40 -0700 | [diff] [blame] | 109 | def start(self, env = ''): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 110 | ''' |
| 111 | Starts ONOS on remote machine. |
| 112 | Returns false if any errors were encountered. |
| 113 | ''' |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 114 | try: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 115 | self.handle.sendline("") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 116 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 117 | self.handle.sendline("cd "+self.home) |
Jon Hall | f0a494f | 2014-06-23 15:37:40 -0700 | [diff] [blame] | 118 | self.handle.sendline(env + "./onos.sh core start") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 119 | i=self.handle.expect(["STARTED","FAILED",pexpect.EOF,pexpect.TIMEOUT]) |
| 120 | response = self.handle.before + str(self.handle.after) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 121 | if i==0: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 122 | j = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT], timeout=60) |
| 123 | if re.search("Killed",response): |
| 124 | main.log.warn(self.name + ": Killed existing process") |
| 125 | if j==0: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 126 | main.log.info(self.name + ": ONOS Started ") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 127 | return main.TRUE |
| 128 | elif j==1: |
| 129 | main.log.error(self.name + ": EOF exception found") |
| 130 | main.log.error(self.name + ": " + self.handle.before) |
| 131 | main.cleanup() |
| 132 | main.exit() |
| 133 | elif j==2: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 134 | main.log.info(self.name + ": ONOS NOT Started, stuck while waiting for it to start ") |
| 135 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 136 | else: |
| 137 | main.log.warn(self.name +": Unexpected response in start") |
| 138 | return main.TRUE |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 139 | elif i==1: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 140 | main.log.error(self.name + ": ONOS Failed to start") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 141 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 142 | elif i==2: |
| 143 | main.log.error(self.name + ": EOF exception found") |
| 144 | main.log.error(self.name + ": " + self.handle.before) |
| 145 | main.cleanup() |
| 146 | main.exit() |
| 147 | elif i==3: |
| 148 | main.log.error(self.name + ": ONOS timedout while starting") |
| 149 | return main.FALSE |
| 150 | else: |
| 151 | main.log.error(self.name + ": ONOS start expect script missed something... ") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 152 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 153 | except pexpect.EOF: |
| 154 | main.log.error(self.name + ": EOF exception found") |
| 155 | main.log.error(self.name + ": " + self.handle.before) |
| 156 | main.cleanup() |
| 157 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 158 | except: |
| 159 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 160 | main.log.error( traceback.print_exc() ) |
| 161 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 162 | main.cleanup() |
| 163 | main.exit() |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 164 | |
| 165 | def start_all(self): |
| 166 | ''' |
| 167 | starts ZK, RC, and ONOS |
| 168 | ''' |
| 169 | self.handle.sendline("cd "+self.home) |
| 170 | self.handle.sendline("./onos.sh start") |
| 171 | self.handle.expect("./onos.sh start") |
| 172 | self.handle.expect(["\$",pexpect.TIMEOUT]) |
| 173 | |
| 174 | |
| 175 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 176 | def start_rest(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 177 | ''' |
| 178 | Starts the rest server on ONOS. |
| 179 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 180 | try: |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 181 | self.handle.sendline("cd "+self.home) |
| 182 | response = self.execute(cmd= "./start-rest.sh start",prompt="\$",timeout=10) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 183 | if re.search("admin",response): |
| 184 | main.log.info(self.name + ": Rest Server Started Successfully") |
| 185 | time.sleep(5) |
| 186 | return main.TRUE |
| 187 | else : |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 188 | main.log.warn(self.name + ": Failed to start Rest Server") |
| 189 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 190 | except pexpect.EOF: |
| 191 | main.log.error(self.name + ": EOF exception found") |
| 192 | main.log.error(self.name + ": " + self.handle.before) |
| 193 | main.cleanup() |
| 194 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 195 | except: |
| 196 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 197 | main.log.error( traceback.print_exc() ) |
| 198 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 199 | main.cleanup() |
| 200 | main.exit() |
| 201 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 202 | def status(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 203 | ''' |
| 204 | Called onos.sh core status and returns TRUE/FALSE accordingly |
| 205 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 206 | try: |
| 207 | self.execute(cmd="\n",prompt="\$",timeout=10) |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 208 | self.handle.sendline("cd "+self.home) |
| 209 | response = self.execute(cmd="./onos.sh core status ",prompt="\d+\sinstance\sof\sonos\srunning",timeout=10) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 210 | self.execute(cmd="\n",prompt="\$",timeout=10) |
| 211 | if re.search("1\sinstance\sof\sonos\srunning",response): |
| 212 | return main.TRUE |
| 213 | elif re.search("0\sinstance\sof\sonos\srunning",response): |
| 214 | return main.FALSE |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 215 | elif re.search("Expected\sPrompt\snot found\s,\sTime Out!!",response): |
| 216 | return main.ERROR |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 217 | else : |
Jon Hall | f0a494f | 2014-06-23 15:37:40 -0700 | [diff] [blame] | 218 | main.log.warn(self.name + " WARNING: status recieved unknown response") |
| 219 | main.log.warn(response) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 220 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 221 | except pexpect.EOF: |
| 222 | main.log.error(self.name + ": EOF exception found") |
| 223 | main.log.error(self.name + ": " + self.handle.before) |
| 224 | main.cleanup() |
| 225 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 226 | except: |
| 227 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 228 | main.log.error( traceback.print_exc() ) |
| 229 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 230 | main.cleanup() |
| 231 | main.exit() |
| 232 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 233 | |
| 234 | def isup(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 235 | ''' |
| 236 | A more complete check to see if ONOS is up and running properly. |
| 237 | First, it checks if the process is up. |
| 238 | Second, it reads the logs for "Exception: Connection refused" |
| 239 | Third, it makes sure the logs are actually moving. |
| 240 | returns TRUE/FALSE accordingly. |
| 241 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 242 | try: |
| 243 | self.execute(cmd="\n",prompt="\$",timeout=10) |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 244 | self.handle.sendline("cd "+self.home) |
| 245 | response = self.execute(cmd= "./onos.sh core status ",prompt="running",timeout=10) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 246 | self.execute(cmd="\n",prompt="\$",timeout=10) |
| 247 | tail1 = self.execute(cmd="tail " + self.home + "/onos-logs/onos.*.log",prompt="\$",timeout=10) |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 248 | time.sleep(10) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 249 | self.execute(cmd="\n",prompt="\$",timeout=10) |
| 250 | tail2 = self.execute(cmd="tail " + self.home + "/onos-logs/onos.*.log",prompt="\$",timeout=10) |
| 251 | pattern = '(.*)1 instance(.*)' |
| 252 | pattern2 = '(.*)Exception: Connection refused(.*)' |
| 253 | # if utilities.assert_matches(expect=pattern,actual=response,onpass="ONOS process is running...",onfail="ONOS process not running..."): |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 254 | running = self.execute(cmd="cat "+self.home+"/onos-logs/onos.*.log | grep 'Sending LLDP out on all ports'",prompt="\$",timeout=10) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 255 | if re.search(pattern, response): |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 256 | if running != "": |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 257 | main.log.info(self.name + ": ONOS process is running...") |
| 258 | if tail1 == tail2: |
| 259 | main.log.error(self.name + ": ONOS is frozen...")#logs aren't moving |
| 260 | return main.FALSE |
| 261 | elif re.search( pattern2,tail1 ): |
| 262 | main.log.info(self.name + ": Connection Refused found in onos log") |
| 263 | return main.FALSE |
| 264 | elif re.search( pattern2,tail2 ): |
| 265 | main.log.info(self.name + ": Connection Refused found in onos log") |
| 266 | return main.FALSE |
| 267 | else: |
| 268 | main.log.info(self.name + ": Onos log is moving! It's looking good!") |
| 269 | return main.TRUE |
Jon Hall | 55c7966 | 2014-05-19 15:03:40 -0700 | [diff] [blame] | 270 | else: |
| 271 | main.log.info(self.name + ": ONOS not yet sending out LLDP messages") |
| 272 | return main.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 273 | else: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 274 | main.log.error(self.name + ": ONOS process not running...") |
| 275 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 276 | except pexpect.EOF: |
| 277 | main.log.error(self.name + ": EOF exception found") |
| 278 | main.log.error(self.name + ": " + self.handle.before) |
| 279 | main.cleanup() |
| 280 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 281 | except: |
| 282 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 283 | main.log.error( traceback.print_exc() ) |
| 284 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 285 | main.cleanup() |
| 286 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 287 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 288 | |
| 289 | |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 290 | def rest_status(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 291 | ''' |
| 292 | Checks if the rest server is running. |
| 293 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 294 | try: |
| 295 | response = self.execute(cmd= self.home + "/start-rest.sh status ",prompt="running",timeout=10) |
| 296 | if re.search("rest\sserver\sis\srunning",response): |
| 297 | main.log.info(self.name + ": Rest Server is running") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 298 | return main.TRUE |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 299 | elif re.search("rest\sserver\sis\snot\srunning",response): |
| 300 | main.log.warn(self.name + ": Rest Server is not Running") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 301 | return main.FALSE |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 302 | else : |
| 303 | main.log.error(self.name + ": No response" +response) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 304 | return main.FALSE |
| 305 | except pexpect.EOF: |
| 306 | main.log.error(self.name + ": EOF exception found") |
| 307 | main.log.error(self.name + ": " + self.handle.before) |
| 308 | main.cleanup() |
| 309 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 310 | except: |
| 311 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 312 | main.log.error( traceback.print_exc() ) |
| 313 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 314 | main.cleanup() |
| 315 | main.exit() |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 316 | |
| 317 | def stop_all(self): |
| 318 | ''' |
| 319 | Runs ./onos.sh stop |
| 320 | ''' |
| 321 | try: |
| 322 | self.handle.sendline("") |
| 323 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 324 | self.handle.sendline("cd "+self.home) |
| 325 | self.handle.sendline("./onos.sh stop") |
Jon Hall | d79c7d0 | 2014-08-15 15:16:51 -0700 | [diff] [blame] | 326 | self.handle.expect(["./onos.sh stop",pexpect.EOF,pexpect.TIMEOUT]) |
| 327 | i=self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT],60) |
admin | e8c47d0 | 2014-06-03 11:59:16 -0700 | [diff] [blame] | 328 | result = self.handle.before |
| 329 | if re.search("Killed", result): |
| 330 | main.log.info(self.name + ": ONOS Killed Successfully") |
| 331 | return main.TRUE |
| 332 | else : |
| 333 | main.log.warn(self.name + ": ONOS wasn't running") |
| 334 | return main.FALSE |
| 335 | except pexpect.EOF: |
| 336 | main.log.error(self.name + ": EOF exception found") |
| 337 | main.log.error(self.name + ": " + self.handle.before) |
| 338 | main.cleanup() |
| 339 | main.exit() |
| 340 | except: |
| 341 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 342 | main.log.error( traceback.print_exc() ) |
| 343 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 344 | main.cleanup() |
| 345 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 346 | |
| 347 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 348 | def stop(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 349 | ''' |
| 350 | Runs ./onos.sh core stop to stop ONOS |
| 351 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 352 | try: |
| 353 | self.handle.sendline("") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 354 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 355 | self.handle.sendline("cd "+self.home) |
| 356 | self.handle.sendline("./onos.sh core stop") |
Jon Hall | d79c7d0 | 2014-08-15 15:16:51 -0700 | [diff] [blame] | 357 | self.handle.expect(["./onos.sh stop",pexpect.EOF,pexpect.TIMEOUT]) |
| 358 | i=self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT],60) |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 359 | result = self.handle.before |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 360 | if re.search("Killed", result): |
| 361 | main.log.info(self.name + ": ONOS Killed Successfully") |
| 362 | return main.TRUE |
| 363 | else : |
| 364 | main.log.warn(self.name + ": ONOS wasn't running") |
| 365 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 366 | except pexpect.EOF: |
| 367 | main.log.error(self.name + ": EOF exception found") |
| 368 | main.log.error(self.name + ": " + self.handle.before) |
| 369 | main.cleanup() |
| 370 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 371 | except: |
| 372 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 373 | main.log.error( traceback.print_exc() ) |
| 374 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 375 | main.cleanup() |
| 376 | main.exit() |
admin | 6903e46 | 2014-07-22 15:30:54 -0700 | [diff] [blame] | 377 | #********************************************************************************************** |
| 378 | #********************************************************************************************** |
| 379 | # The purpose of comp_intents is to find if the high level intents have changed. preIntents |
| 380 | # and postIntents should be the output of curl of the intents. preIntents being the original |
| 381 | # and postIntents being the later. We are looking at the intents with the same id from both |
| 382 | # and comparing the dst and src DPIDs and macs, and the state. If any of these are changed |
| 383 | # we print that there are changes, then return a list of the intents that have changes` |
| 384 | #********************************************************************************************** |
| 385 | #********************************************************************************************** |
| 386 | def comp_intents(self,preIntents,postIntents): |
| 387 | import json |
| 388 | preDecoded = json.loads(preIntents) |
| 389 | postDecoded = json.loads(postIntents) |
| 390 | changes = [] |
| 391 | if not preDecoded: |
| 392 | if postDecoded: |
| 393 | print "THERE ARE CHANGES TO THE HIGH LEVEL INTENTS!!!!" |
| 394 | return postDecoded |
| 395 | for k in preDecoded: |
| 396 | for l in postDecoded: |
| 397 | if l['id']==k['id']: |
| 398 | if k['dstSwitchDpid']==l['dstSwitchDpid'] and k['srcMac']==l['srcMac'] and k['dstMac']==l['dstMac'] and k['srcSwitchDpid']==l['srcSwitchDpid'] and k['state']==l['state']: |
| 399 | postDecoded.remove(l) |
| 400 | else: |
| 401 | changes.append(k) |
| 402 | print ("THERE ARE CHANGES TO THE HIGH LEVEL INTENTS!!!") |
| 403 | return changes |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 404 | |
admin | 6903e46 | 2014-07-22 15:30:54 -0700 | [diff] [blame] | 405 | #********************************************************************************************** |
| 406 | #********************************************************************************************** |
| 407 | # the purpose of comp_low is to find if the low level intents have changed. The main idea |
| 408 | # is to determine if the path has changed. Again, like with the comp_intents function, the |
| 409 | # pre and post Intents variables are the json dumps of wm/onos/intent/low. The variables |
| 410 | # that will be compared are the state, and the path. |
| 411 | #********************************************************************************************** |
| 412 | #********************************************************************************************** |
| 413 | def comp_low(self, preIntents,postIntents): |
| 414 | import json |
| 415 | preDecoded = json.loads(preIntents) |
| 416 | postDecoded = json.loads(postIntents) |
| 417 | changes = [] |
| 418 | if not preDecoded: |
| 419 | if postDecoded: |
| 420 | print "THERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!" |
| 421 | return postDecoded |
| 422 | for k in preDecoded: |
| 423 | for l in postDecoded: |
| 424 | if l['id']==k['id']: |
| 425 | if l['path']!=k['path']: |
| 426 | changes.append(l) |
| 427 | print "\n\n\n\nTHERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!" |
| 428 | else: |
| 429 | if k['state']!=l['state']: |
| 430 | changes.append(l) |
| 431 | print "\n\n\n\nTHERE ARE CHANGES TO THE LOW LEVEL INTENTS!!!" |
| 432 | else: |
| 433 | print "NO CHANGES SO FAR\n\n\n" |
| 434 | |
| 435 | |
| 436 | return changes |
| 437 | |
| 438 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 439 | def rest_stop(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 440 | ''' |
| 441 | Runs ./start-rest.sh stop to stop ONOS rest server |
| 442 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 443 | try: |
| 444 | response = self.execute(cmd= self.home + "/start-rest.sh stop ",prompt="killing",timeout=10) |
| 445 | self.execute(cmd="\n",prompt="\$",timeout=10) |
| 446 | if re.search("killing", response): |
| 447 | main.log.info(self.name + ": Rest Server Stopped") |
| 448 | return main.TRUE |
| 449 | else : |
| 450 | main.log.error(self.name + ": Failed to Stop, Rest Server is not Running") |
| 451 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 452 | except pexpect.EOF: |
| 453 | main.log.error(self.name + ": EOF exception found") |
| 454 | main.log.error(self.name + ": " + self.handle.before) |
| 455 | main.cleanup() |
| 456 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 457 | except: |
| 458 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 459 | main.log.error( traceback.print_exc() ) |
| 460 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 461 | main.cleanup() |
| 462 | main.exit() |
| 463 | |
| 464 | |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 465 | def kill(self): |
| 466 | import re |
| 467 | try: |
| 468 | self.handle.sendline("ps -ef |grep 'ONOS/conf/logback' |awk 'NR==1 {print $2}' |xargs sudo kill -9") |
| 469 | self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 470 | self.handle.sendline("ps -ef |grep 'ONOS/conf/logback' |wc -l") |
| 471 | self.handle.expect(["wc -l",pexpect.EOF,pexpect.TIMEOUT]) |
| 472 | response = self.handle.after |
| 473 | if re.search("1",response): |
| 474 | return "ONOS Killed!" |
| 475 | else: |
| 476 | return "ERROR!!! ONOS MAY NOT HAVE BEEN KILLED PROPERLY!!!" |
| 477 | except pexpect.EOF: |
| 478 | main.log.error(self.name + ": EOF exception found") |
| 479 | main.log.error(self.hane + ": " + self.handle.before) |
| 480 | main.cleanup() |
| 481 | main.exit() |
| 482 | except: |
| 483 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 484 | main.log.error( traceback.print_exc() ) |
| 485 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 486 | main.cleanup() |
| 487 | main.exit() |
| 488 | |
| 489 | |
| 490 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 491 | def disconnect(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 492 | ''' |
| 493 | Called when Test is complete to disconnect the ONOS handle. |
| 494 | ''' |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 495 | response = '' |
| 496 | try: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 497 | self.handle.sendline("exit") |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 498 | self.handle.expect("closed") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 499 | except pexpect.EOF: |
| 500 | main.log.error(self.name + ": EOF exception found") |
| 501 | main.log.error(self.name + ": " + self.handle.before) |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 502 | except: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 503 | main.log.error(self.name + ": Connection failed to the host") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 504 | response = main.FALSE |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 505 | return response |
| 506 | |
Jon Hall | 76f2c46 | 2014-04-17 11:37:15 -0700 | [diff] [blame] | 507 | def print_version(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 508 | ''' |
| 509 | Writes the COMMIT number to the report to be parsed by Jenkins data collecter. |
| 510 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 511 | try: |
| 512 | self.handle.sendline("export TERM=xterm-256color") |
| 513 | self.handle.expect("xterm-256color") |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 514 | self.handle.expect("\$") |
Jon Hall | cc0d30e | 2014-09-15 14:57:40 -0700 | [diff] [blame^] | 515 | self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 5 \"commit\" --color=never; cd \.\.") |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 516 | self.handle.expect("cd ..") |
| 517 | self.handle.expect("\$") |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 518 | response=(self.name +": \n"+ str(self.handle.before + self.handle.after)) |
| 519 | main.log.report(response) |
Jon Hall | 76f2c46 | 2014-04-17 11:37:15 -0700 | [diff] [blame] | 520 | except pexpect.EOF: |
| 521 | main.log.error(self.name + ": EOF exception found") |
| 522 | main.log.error(self.name + ": " + self.handle.before) |
| 523 | main.cleanup() |
| 524 | main.exit() |
| 525 | except: |
| 526 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 527 | main.log.error( traceback.print_exc() ) |
| 528 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 529 | main.cleanup() |
| 530 | def get_version(self): |
| 531 | ''' |
| 532 | Writes the COMMIT number to the report to be parsed by Jenkins data collecter. |
| 533 | ''' |
| 534 | try: |
| 535 | self.handle.sendline("export TERM=xterm-256color") |
| 536 | self.handle.expect("xterm-256color") |
| 537 | self.handle.expect("\$") |
Jon Hall | cc0d30e | 2014-09-15 14:57:40 -0700 | [diff] [blame^] | 538 | self.handle.sendline("cd " + self.home + "; git log -1 --pretty=fuller --decorate=short | grep -A 5 \"commit\" --color=never; cd \.\.") |
Jon Hall | 76f2c46 | 2014-04-17 11:37:15 -0700 | [diff] [blame] | 539 | self.handle.expect("cd ..") |
| 540 | self.handle.expect("\$") |
| 541 | response=(self.name +": \n"+ str(self.handle.before + self.handle.after)) |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 542 | lines=response.splitlines() |
| 543 | for line in lines: |
| 544 | print line |
| 545 | return lines[2] |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 546 | except pexpect.EOF: |
| 547 | main.log.error(self.name + ": EOF exception found") |
| 548 | main.log.error(self.name + ": " + self.handle.before) |
| 549 | main.cleanup() |
| 550 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 551 | except: |
| 552 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 553 | main.log.error( traceback.print_exc() ) |
| 554 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 555 | main.cleanup() |
| 556 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 557 | |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 558 | |
admin | dc1c507 | 2014-06-24 15:57:19 -0700 | [diff] [blame] | 559 | |
| 560 | #********************************************************************* |
| 561 | #********************************************************************* |
| 562 | # shortest_path is a command to find the shortest path between two |
| 563 | # switches. It is called using the IP, port, and source and |
| 564 | # destination dpids |
| 565 | #********************************************************************* |
| 566 | #********************************************************************* |
| 567 | |
| 568 | def shortest_path(self,ONOSIP,ONOSPort,srcDPID,dstDPID): |
| 569 | main.log.report("Finding the shortest Path between "+str(srcDPID) + " to " + str(dstDPID)) |
| 570 | url = "http://%s:%s/wm/onos/intent/path/switch/%s/shortest-path/%s"%(ONOSIP,ONOSPort,srcDPID,dstDPID) |
| 571 | parsed_result = [] |
| 572 | try: |
| 573 | response = urllib2.urlopen(url) |
| 574 | result = response.read() |
| 575 | response.close() |
| 576 | if len(result) != 0: |
| 577 | parsed_result = json.loads(result) |
| 578 | except HTTPError as exc: |
| 579 | print "ERROR:" |
| 580 | print " REST GET URL: %s" % url |
| 581 | # NOTE: exc.fp contains the object with the response payload |
| 582 | error_payload = json.loads(exc.fp.read()) |
| 583 | print " REST Error Code: %s" % (error_payload['code']) |
| 584 | print " REST Error Summary: %s" % (error_payload['summary']) |
| 585 | print " REST Error Description: %s" % (error_payload['formattedDescription']) |
| 586 | print " HTTP Error Code: %s" % exc.code |
| 587 | print " HTTP Error Reason: %s" % exc.reason |
| 588 | except URLError as exc: |
| 589 | print "ERROR:" |
| 590 | print " REST GET URL: %s" % url |
| 591 | print " URL Error Reason: %s" % exc.reason |
| 592 | |
| 593 | if len(parsed_result)==0: |
| 594 | return |
| 595 | result = json.dumps(parsed_result,indent=4) |
| 596 | print(str(result)) |
| 597 | return result |
| 598 | |
| 599 | |
| 600 | #********************************************************************* |
| 601 | #********************************************************************* |
| 602 | # show_intent is a command to show intents. |
| 603 | # Parameters include intentIP, intentPort, intentURL, and intent_id |
| 604 | # Based on the url, it will show either high or low intents |
| 605 | # If intent_id is left blank, it will show all high or all low intents |
| 606 | # Else it will show the intent with the id |
| 607 | #********************************************************************* |
| 608 | #********************************************************************* |
| 609 | |
| 610 | |
| 611 | |
| 612 | def show_intent(self,intentIP,intentPort=8080,intentURL="wm/onos/intent",intent_type="high",intent_id="all"): |
| 613 | main.log.report("Getting (an) intent(s)") |
| 614 | if intent_id=="all": |
| 615 | url = "http://%s:%s/%s/%s"%(intentIP,intentPort,intentURL,intent_type) |
| 616 | else: |
| 617 | url = "http://%s:%s/%s/%s/%s"%(intentIP,intentPort,intentURL,intent_type,intent_id) |
| 618 | print(url) |
| 619 | parsed_result = [] |
| 620 | try: |
| 621 | response = urllib2.urlopen(url) |
| 622 | result = response.read() |
| 623 | response.close() |
| 624 | if len(result) != 0: |
| 625 | parsed_result = json.loads(result) |
| 626 | except HTTPError as exc: |
| 627 | print "ERROR:" |
| 628 | print " REST GET URL: %s" % url |
| 629 | # NOTE: exc.fp contains the object with the response payload |
| 630 | error_payload = json.loads(exc.fp.read()) |
| 631 | print " REST Error Code: %s" % (error_payload['code']) |
| 632 | print " REST Error Summary: %s" % (error_payload['summary']) |
| 633 | print " REST Error Description: %s" % (error_payload['formattedDescription']) |
| 634 | print " HTTP Error Code: %s" % exc.code |
| 635 | print " HTTP Error Reason: %s" % exc.reason |
| 636 | return str(error_payload['code']) |
| 637 | except URLError as exc: |
| 638 | print "ERROR:" |
| 639 | print " REST GET URL: %s" % url |
| 640 | print " URL Error Reason: %s" % exc.reason |
| 641 | return str(error_payload['code']) |
| 642 | |
| 643 | if len(parsed_result)==0: |
| 644 | return |
| 645 | result = json.dumps(parsed_result,indent=4) |
| 646 | print(str(result)) |
| 647 | return result |
| 648 | |
| 649 | |
| 650 | #********************************************************************* |
| 651 | #********************************************************************* |
| 652 | # del_intent is to delete either all or some or one intents |
| 653 | # if intent_id is left blank, it will delete all intents |
| 654 | # else, intent_id should be of the form "intent_id=1,2,3" |
| 655 | #********************************************************************* |
| 656 | #********************************************************************* |
| 657 | |
| 658 | def del_intent(self,intentIP,intentPort=8080,intentURL="wm/onos/intent",intent_id="all"): |
| 659 | main.log.report("Deleting (an) intent(s)") |
| 660 | if intent_id=="all": |
| 661 | url = "http://%s:%s/%s/high"%(intentIP,intentPort,intentURL) |
| 662 | else: |
| 663 | url = "http://%s:%s/%s/high?%s"%(intentIP,intentPort,intentURL,intent_id) |
| 664 | |
| 665 | print(url) |
| 666 | |
| 667 | parsed_result = [] |
| 668 | try: |
| 669 | request = urllib2.Request(url) |
| 670 | request.get_method = lambda: 'DELETE' |
| 671 | response = urllib2.urlopen(request) |
| 672 | result = response.read() |
| 673 | response.close() |
| 674 | if len(result) != 0: |
| 675 | parsed_result = json.loads(result) |
| 676 | print(parsed_result) |
| 677 | except HTTPError as exc: |
| 678 | print "ERROR:" |
| 679 | print " REST DELETE URL: %s" % url |
| 680 | # NOTE: exc.fp contains the object with the response payload |
| 681 | error_payload = json.loads(exc.fp.read()) |
| 682 | print " REST Error Code: %s" % (error_payload['code']) |
| 683 | print " REST Error Summary: %s" % (error_payload['summary']) |
| 684 | print " REST Error Description: %s" % (error_payload['formattedDescription']) |
| 685 | print " HTTP Error Code: %s" % exc.code |
| 686 | print " HTTP Error Reason: %s" % exc.reason |
| 687 | except URLError as exc: |
| 688 | print "ERROR:" |
| 689 | print " REST DELETE URL: %s" % url |
| 690 | print " URL Error Reason: %s" % exc.reason |
| 691 | return result |
| 692 | |
| 693 | #********************************************************************* |
| 694 | #********************************************************************* |
| 695 | # add_intent will add a single intent by using dpids and macs. |
| 696 | #********************************************************************* |
| 697 | #********************************************************************* |
| 698 | |
| 699 | |
| 700 | def add_intent(self, intent_id,src_dpid,dst_dpid,src_mac,dst_mac,intentIP,intentPort=8080,intentURL="wm/onos/intent" , intent_type = 'SHORTEST_PATH', static_path=False, src_port=1,dst_port=1): |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 701 | "CLI command callback: set intent" |
| 702 | |
| 703 | intents = [] |
| 704 | oper = {} |
| 705 | # Create the POST payload |
| 706 | oper['intentId'] = intent_id |
| 707 | oper['intentType'] = intent_type # XXX: Hardcoded |
| 708 | oper['staticPath'] = static_path # XXX: Hardcoded |
| 709 | oper['srcSwitchDpid'] = src_dpid |
| 710 | oper['srcSwitchPort'] = src_port |
| 711 | oper['dstSwitchDpid'] = dst_dpid |
| 712 | oper['dstSwitchPort'] = dst_port |
| 713 | oper['matchSrcMac'] = src_mac |
| 714 | oper['matchDstMac'] = dst_mac |
| 715 | intents.append(oper) |
admin | dc1c507 | 2014-06-24 15:57:19 -0700 | [diff] [blame] | 716 | url = "http://%s:%s/%s/high"%(intentIP,intentPort,intentURL) |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 717 | parsed_result = [] |
| 718 | data_json = json.dumps(intents) |
Jon Hall | 43d1e96 | 2014-08-08 11:51:24 -0700 | [diff] [blame] | 719 | result = main.FALSE |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 720 | try: |
| 721 | request = urllib2.Request(url,data_json) |
| 722 | request.add_header("Content-Type", "application/json") |
| 723 | response=urllib2.urlopen(request) |
| 724 | result = response.read() |
| 725 | response.close() |
| 726 | if len(result) != 0: |
| 727 | parsed_result = json.loads(result) |
| 728 | except HTTPError as exc: |
| 729 | print "ERROR:" |
| 730 | print " REST GET URL: %s" % url |
| 731 | # NOTE: exc.fp contains the object with the response payload |
| 732 | error_payload = json.loads(exc.fp.read()) |
| 733 | print " REST Error Code: %s" % (error_payload['code']) |
| 734 | print " REST Error Summary: %s" % (error_payload['summary']) |
| 735 | print " REST Error Description: %s" % (error_payload['formattedDescription']) |
| 736 | print " HTTP Error Code: %s" % exc.code |
| 737 | print " HTTP Error Reason: %s" % exc.reason |
Jon Hall | 43d1e96 | 2014-08-08 11:51:24 -0700 | [diff] [blame] | 738 | return " HTTP Error Code: %s, Reason: %s" % exc.code, exc.reason |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 739 | except URLError as exc: |
| 740 | print "ERROR:" |
| 741 | print " REST GET URL: %s" % url |
| 742 | print " URL Error Reason: %s" % exc.reason |
Jon Hall | 43d1e96 | 2014-08-08 11:51:24 -0700 | [diff] [blame] | 743 | return " HTTP Error Reason: %s" % exc.reason |
admin | dc1c507 | 2014-06-24 15:57:19 -0700 | [diff] [blame] | 744 | return result |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | def add_intents(self): |
| 750 | main.log.info("Sending new intents to ONOS") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 751 | self.handle.sendline("cd "+self.home+ "/scripts") |
| 752 | self.handle.expect("scripts") |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 753 | main.log.info("Adding intents") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 754 | self.handle.sendline("./pyintents.py") |
Jon Hall | 9c6e2c0 | 2014-05-02 10:18:53 -0700 | [diff] [blame] | 755 | self.handle.expect(["$",pexpect.EOF,pexpect.TIMEOUT]) |
| 756 | response = self.handle.before |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 757 | self.handle.sendline("cd "+self.home) |
| 758 | return main.TRUE |
| 759 | |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 760 | def rm_intents(self): |
| 761 | main.log.info("Deleteing Intents from ONOS") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 762 | self.handle.sendline("cd "+self.home+ "/scripts") |
| 763 | self.handle.expect("scripts") |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 764 | main.log.info("Deleting Intnents") |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 765 | self.handle.sendline("./rmpyintents.py") |
Jon Hall | 9c6e2c0 | 2014-05-02 10:18:53 -0700 | [diff] [blame] | 766 | self.handle.expect(["$",pexpect.EOF,pexpect.TIMEOUT]) |
| 767 | response = self.handle.before |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 768 | self.handle.sendline("cd "+self.home) |
| 769 | return main.TRUE |
| 770 | |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 771 | def purge_intents(self): |
Jon Hall | 265149f | 2014-04-25 13:39:52 -0700 | [diff] [blame] | 772 | main.log.info("Purging dead intents") |
| 773 | self.handle.sendline("cd "+self.home+ "/scripts") |
| 774 | self.handle.expect("scripts") |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 775 | main.log.info("Sending Purge Intent Rest call to ONOS") |
Jon Hall | 265149f | 2014-04-25 13:39:52 -0700 | [diff] [blame] | 776 | self.handle.sendline("./purgeintents.py") |
| 777 | self.handle.sendline("cd "+self.home) |
| 778 | return main.TRUE |
admin | c6cfc1c | 2014-04-21 13:55:21 -0700 | [diff] [blame] | 779 | |
| 780 | |
| 781 | |
Jon Hall | 4a2b048 | 2014-04-18 16:29:26 -0700 | [diff] [blame] | 782 | def add_flow(self, testONip, user = "admin", password = "", flowDef = "/flowdef.txt"): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 783 | ''' |
| 784 | Copies the flowdef file from TestStation -> ONOS machine |
| 785 | Then runs ./add_flow.py to add the flows to ONOS |
| 786 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 787 | try: |
| 788 | main.log.info("Adding Flows...") |
| 789 | self.handle.sendline("scp %s@%s:%s /tmp/flowtmp" %(user,testONip,flowDef)) |
| 790 | i=self.handle.expect(['[pP]assword:', '100%', pexpect.TIMEOUT],30) |
| 791 | if(i==0): |
| 792 | self.handle.sendline("%s" %(password)) |
| 793 | self.handle.sendline("") |
| 794 | self.handle.expect("100%") |
| 795 | self.handle.expect("\$", 30) |
| 796 | self.handle.sendline(self.home + "/web/add_flow.py -m onos -f /tmp/flowtmp") |
| 797 | self.handle.expect("\$", 1000) |
| 798 | main.log.info("Flows added") |
| 799 | return main.TRUE |
| 800 | |
| 801 | elif(i==1): |
| 802 | self.handle.sendline("") |
| 803 | self.handle.expect("\$", 10) |
| 804 | self.handle.sendline( self.home + "/web/add_flow.py -m onos -f /tmp/flowtmp") |
| 805 | self.handle.expect("\$", 1000) |
| 806 | main.log.info("Flows added") |
| 807 | return main.TRUE |
| 808 | |
| 809 | elif(i==2): |
| 810 | main.log.error("Flow Def file SCP Timed out...") |
| 811 | return main.FALSE |
| 812 | |
| 813 | else: |
| 814 | main.log.error("Failed to add flows...") |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 815 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 816 | except pexpect.EOF: |
| 817 | main.log.error(self.name + ": EOF exception found") |
| 818 | main.log.error(self.name + ": " + self.handle.before) |
| 819 | main.cleanup() |
| 820 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 821 | except: |
| 822 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 823 | main.log.error( traceback.print_exc() ) |
| 824 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 825 | main.cleanup() |
| 826 | main.exit() |
| 827 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 828 | |
| 829 | def delete_flow(self, *delParams): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 830 | ''' |
| 831 | Deletes a specific flow, a range of flows, or all flows. |
| 832 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 833 | try: |
| 834 | if len(delParams)==1: |
| 835 | if str(delParams[0])=="all": |
| 836 | main.log.info(self.name + ": Deleting ALL flows...") |
| 837 | #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh all",prompt="done",timeout=150) |
| 838 | self.handle.sendline(self.home + "/web/delete_flow.py all") |
| 839 | self.handle.expect("delete_flow") |
| 840 | self.handle.expect("\$",1000) |
| 841 | main.log.info(self.name + ": Flows deleted") |
| 842 | else: |
| 843 | main.log.info(self.name + ": Deleting flow "+str(delParams[0])+"...") |
| 844 | #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh "+str(delParams[0]),prompt="done",timeout=150) |
| 845 | #self.execute(cmd="\n",prompt="\$",timeout=60) |
| 846 | self.handle.sendline(self.home +"/web/delete_flow.py %d" % int(delParams[0])) |
| 847 | self.handle.expect("delete_flow") |
| 848 | self.handle.expect("\$",60) |
| 849 | main.log.info(self.name + ": Flow deleted") |
| 850 | elif len(delParams)==2: |
| 851 | main.log.info(self.name + ": Deleting flows "+str(delParams[0])+" through "+str(delParams[1])+"...") |
| 852 | #self.execute(cmd="~/ONOS/scripts/TestON_delete_flow.sh "+str(delParams[0])+" "+str(delParams[1]),prompt="done",timeout=150) |
| 853 | #self.execute(cmd="\n",prompt="\$",timeout=60) |
| 854 | self.handle.sendline(self.home + "/web/delete_flow.py %d %d" % (int(delParams[0]), int(delParams[1]))) |
| 855 | self.handle.expect("delete_flow") |
| 856 | self.handle.expect("\$",600) |
| 857 | main.log.info(self.name + ": Flows deleted") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 858 | except pexpect.EOF: |
| 859 | main.log.error(self.name + ": EOF exception found") |
| 860 | main.log.error(self.name + ": " + self.handle.before) |
| 861 | main.cleanup() |
| 862 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 863 | except: |
| 864 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 865 | main.log.error( traceback.print_exc() ) |
| 866 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 867 | main.cleanup() |
| 868 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 869 | |
| 870 | def check_flow(self): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 871 | ''' |
| 872 | Calls the ./get_flow.py all and checks: |
| 873 | - If each FlowPath has at least one FlowEntry |
| 874 | - That there are no "NOT"s found |
| 875 | returns TRUE/FALSE |
| 876 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 877 | try: |
| 878 | flowEntryDetect = 1 |
| 879 | count = 0 |
| 880 | self.handle.sendline("clear") |
| 881 | time.sleep(1) |
| 882 | self.handle.sendline(self.home + "/web/get_flow.py all") |
| 883 | self.handle.expect("get_flow") |
Jon Hall | 3bd7c79 | 2014-05-30 09:05:21 -0700 | [diff] [blame] | 884 | for x in range(15): |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 885 | i=self.handle.expect(['FlowPath','FlowEntry','NOT','\$',pexpect.TIMEOUT],timeout=180) |
| 886 | if i==0: |
| 887 | count = count + 1 |
| 888 | if flowEntryDetect == 0: |
| 889 | main.log.info(self.name + ": FlowPath without FlowEntry") |
| 890 | return main.FALSE |
| 891 | else: |
| 892 | flowEntryDetect = 0 |
| 893 | elif i==1: |
| 894 | flowEntryDetect = 1 |
| 895 | elif i==2: |
| 896 | main.log.error(self.name + ": Found a NOT") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 897 | return main.FALSE |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 898 | elif i==3: |
| 899 | if count == 0: |
| 900 | main.log.info(self.name + ": There don't seem to be any flows here...") |
| 901 | return main.FALSE |
| 902 | else: |
| 903 | main.log.info(self.name + ": All flows pass") |
| 904 | main.log.info(self.name + ": Number of FlowPaths: "+str(count)) |
| 905 | return main.TRUE |
| 906 | elif i==4: |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 907 | main.log.error(self.name + ":Check_flow() - Command Timeout!") |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 908 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 909 | except pexpect.EOF: |
| 910 | main.log.error(self.name + ": EOF exception found") |
| 911 | main.log.error(self.name + ": " + self.handle.before) |
| 912 | main.cleanup() |
| 913 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 914 | except: |
| 915 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 916 | main.log.error( traceback.print_exc() ) |
| 917 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 918 | main.cleanup() |
| 919 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 920 | |
| 921 | def get_flow(self, *flowParams): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 922 | ''' |
| 923 | Returns verbose output of ./get_flow.py |
| 924 | ''' |
| 925 | try: |
| 926 | if len(flowParams)==1: |
| 927 | if str(flowParams[0])=="all": |
| 928 | self.execute(cmd="\n",prompt="\$",timeout=60) |
| 929 | main.log.info(self.name + ": Getting all flow data...") |
| 930 | data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh all",prompt="done",timeout=150) |
| 931 | self.execute(cmd="\n",prompt="\$",timeout=60) |
| 932 | return data |
| 933 | else: |
| 934 | main.log.info(self.name + ": Retrieving flow "+str(flowParams[0])+" data...") |
| 935 | data = self.execute(cmd=self.home +"/scripts/TestON_get_flow.sh "+str(flowParams[0]),prompt="done",timeout=150) |
| 936 | self.execute(cmd="\n",prompt="\$",timeout=60) |
| 937 | return data |
| 938 | elif len(flowParams)==5: |
| 939 | main.log.info(self.name + ": Retrieving flow installer data...") |
| 940 | data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3])+" "+str(flowParams[4]),prompt="done",timeout=150) |
| 941 | self.execute(cmd="\n",prompt="\$",timeout=60) |
| 942 | return data |
| 943 | elif len(flowParams)==4: |
| 944 | main.log.info(self.name + ": Retrieving flow endpoints...") |
| 945 | data = self.execute(cmd=self.home + "/scripts/TestON_get_flow.sh "+str(flowParams[0])+" "+str(flowParams[1])+" "+str(flowParams[2])+" "+str(flowParams[3]),prompt="done",timeout=150) |
| 946 | self.execute(cmd="\n",prompt="\$",timeout=60) |
| 947 | return data |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 948 | except pexpect.EOF: |
| 949 | main.log.error(self.name + ": EOF exception found") |
| 950 | main.log.error(self.name + ": " + self.handle.before) |
| 951 | main.cleanup() |
| 952 | main.exit() |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 953 | except: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 954 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 955 | main.log.error( traceback.print_exc() ) |
| 956 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 957 | main.cleanup() |
| 958 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 959 | |
| 960 | |
Jon Hall | 2f42a67 | 2014-05-28 10:13:18 -0700 | [diff] [blame] | 961 | # http://localhost:8080/wm/onos/topology/switches |
| 962 | # http://localhost:8080/wm/onos/topology/links |
Jon Hall | 8060af0 | 2014-04-14 14:17:58 -0700 | [diff] [blame] | 963 | # http://localhost:8080/wm/onos/registry/controllers/json |
| 964 | # http://localhost:8080/wm/onos/registry/switches/json" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 965 | |
| 966 | def get_json(self, url): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 967 | ''' |
| 968 | Helper functions used to parse the json output of a rest call |
| 969 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 970 | try: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 971 | try: |
| 972 | command = "curl -s %s" % (url) |
| 973 | result = os.popen(command).read() |
| 974 | parsedResult = json.loads(result) |
| 975 | except: |
| 976 | print "REST IF %s has issue" % command |
| 977 | parsedResult = "" |
| 978 | |
| 979 | if type(parsedResult) == 'dict' and parsedResult.has_key('code'): |
| 980 | print "REST %s returned code %s" % (command, parsedResult['code']) |
| 981 | parsedResult = "" |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 982 | return parsedResult |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 983 | except pexpect.EOF: |
| 984 | main.log.error(self.name + ": EOF exception found") |
| 985 | main.log.error(self.name + ": " + self.handle.before) |
| 986 | main.cleanup() |
| 987 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 988 | except: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 989 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 990 | main.log.error( traceback.print_exc() ) |
| 991 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 992 | main.cleanup() |
| 993 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 994 | |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 995 | def num_switch(self,RestIP,RestPort="8080"): |
| 996 | url = "http://%s:%s/wm/onos/topology/switches" %(RestIP,RestPort) |
| 997 | parsedResult = self.get_json(url) |
| 998 | if parsedResult == "": |
| 999 | retcode = 1 |
| 1000 | return (retcode, "RestAPI has an issue") |
| 1001 | url = "http://%s:%s/wm/onos/registry/switches/json" %(RestIP,RestPort) |
| 1002 | registry = self.get_json(url) |
| 1003 | if registry == "": |
| 1004 | retcode = 1 |
| 1005 | return (retcode, "REST API has an Issue") |
| 1006 | cnt = 0 |
| 1007 | active = 0 |
| 1008 | for s in parsedResult: |
| 1009 | cnt +=1 |
| 1010 | if s['state']=="ACTIVE": |
| 1011 | active+=1 |
| 1012 | return (cnt,active) |
| 1013 | |
| 1014 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1015 | def check_switch(self,RestIP,correct_nr_switch, RestPort ="8080" ): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1016 | ''' |
| 1017 | Used by check_status |
| 1018 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1019 | try: |
| 1020 | buf = "" |
| 1021 | retcode = 0 |
admin | 2e131ab | 2014-05-28 10:03:42 -0700 | [diff] [blame] | 1022 | url="http://%s:%s/wm/onos/topology/switches" % (RestIP, RestPort) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1023 | parsedResult = self.get_json(url) |
| 1024 | if parsedResult == "": |
| 1025 | retcode = 1 |
| 1026 | return (retcode, "Rest API has an issue") |
| 1027 | url = "http://%s:%s/wm/onos/registry/switches/json" % (RestIP, RestPort) |
| 1028 | registry = self.get_json(url) |
| 1029 | |
| 1030 | if registry == "": |
| 1031 | retcode = 1 |
| 1032 | return (retcode, "Rest API has an issue") |
| 1033 | |
| 1034 | cnt = 0 |
| 1035 | active = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1036 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1037 | for s in parsedResult: |
| 1038 | cnt += 1 |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1039 | if s['state'] == "ACTIVE": |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1040 | active += 1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1041 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1042 | buf += "switch: network %d : %d switches %d active\n" % (0+1, cnt, active) |
| 1043 | if correct_nr_switch != cnt: |
| 1044 | buf += "switch fail: network %d should have %d switches but has %d\n" % (1, correct_nr_switch, cnt) |
| 1045 | retcode = 1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1046 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1047 | if correct_nr_switch != active: |
| 1048 | buf += "switch fail: network %d should have %d active switches but has %d\n" % (1, correct_nr_switch, active) |
| 1049 | retcode = 1 |
| 1050 | |
| 1051 | return (retcode, buf) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1052 | except pexpect.EOF: |
| 1053 | main.log.error(self.name + ": EOF exception found") |
| 1054 | main.log.error(self.name + ": " + self.handle.before) |
| 1055 | main.cleanup() |
| 1056 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1057 | except: |
| 1058 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1059 | main.log.error( traceback.print_exc() ) |
| 1060 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1061 | main.cleanup() |
| 1062 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1063 | |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 1064 | def num_link(self,RestIP,RestPort="8080"): |
| 1065 | url = "http://%s:%s/wm/onos/topology/links" % (RestIP,RestPort) |
| 1066 | parsedResult = self.get_json(url) |
| 1067 | if parsedResult == "": |
| 1068 | retcode = 1 |
| 1069 | return (retcode,"RestAPI has an issue") |
| 1070 | intra = 0 |
| 1071 | for s in parsedResult: |
| 1072 | intra+=1 |
| 1073 | return intra |
| 1074 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1075 | def check_link(self,RestIP, nr_links, RestPort = "8080"): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1076 | ''' |
| 1077 | Used by check_status |
| 1078 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1079 | try: |
| 1080 | buf = "" |
| 1081 | retcode = 0 |
| 1082 | |
admin | 2e131ab | 2014-05-28 10:03:42 -0700 | [diff] [blame] | 1083 | url = "http://%s:%s/wm/onos/topology/links" % (RestIP, RestPort) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1084 | parsedResult = self.get_json(url) |
| 1085 | |
| 1086 | if parsedResult == "": |
| 1087 | retcode = 1 |
| 1088 | return (retcode, "Rest API has an issue") |
| 1089 | |
| 1090 | buf += "link: total %d links (correct : %d)\n" % (len(parsedResult), nr_links) |
| 1091 | intra = 0 |
| 1092 | interlink=0 |
| 1093 | |
| 1094 | for s in parsedResult: |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1095 | intra = intra + 1 |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1096 | |
| 1097 | if intra != nr_links: |
| 1098 | buf += "link fail\n" |
| 1099 | retcode = 1 |
| 1100 | |
| 1101 | return (retcode, buf) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1102 | except pexpect.EOF: |
| 1103 | main.log.error(self.name + ": EOF exception found") |
| 1104 | main.log.error(self.name + ": " + self.handle.before) |
| 1105 | main.cleanup() |
| 1106 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1107 | except: |
| 1108 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1109 | main.log.error( traceback.print_exc() ) |
| 1110 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1111 | main.cleanup() |
| 1112 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1113 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1114 | def check_status_report(self, ip, numoswitch, numolink, port="8080"): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1115 | ''' |
| 1116 | Checks the number of swithes & links that ONOS sees against the supplied values. |
| 1117 | Writes to the report log. |
| 1118 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1119 | try: |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1120 | main.log.info(self.name + ": Making some rest calls...") |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1121 | switch = self.check_switch(ip, int(numoswitch), port) |
| 1122 | link = self.check_link(ip, int(numolink), port) |
| 1123 | value = switch[0] |
| 1124 | value += link[0] |
| 1125 | main.log.report( self.name + ": \n-----\n%s%s-----\n" % ( switch[1], link[1]) ) |
| 1126 | if value != 0: |
| 1127 | return main.FALSE |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1128 | else: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1129 | # "PASS" |
| 1130 | return main.TRUE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1131 | except pexpect.EOF: |
| 1132 | main.log.error(self.name + ": EOF exception found") |
| 1133 | main.log.error(self.name + ": " + self.handle.before) |
| 1134 | main.cleanup() |
| 1135 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1136 | except: |
| 1137 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1138 | main.log.error( traceback.print_exc() ) |
| 1139 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1140 | main.cleanup() |
| 1141 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1142 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1143 | def check_status(self, ip, numoswitch, numolink, port = "8080"): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1144 | ''' |
| 1145 | Checks the number of swithes & links that ONOS sees against the supplied values. |
| 1146 | Writes to the main log. |
| 1147 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1148 | try: |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1149 | main.log.info(self.name + ": Making some rest calls...") |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1150 | switch = self.check_switch(ip, int(numoswitch), port) |
| 1151 | link = self.check_link(ip, int(numolink), port) |
| 1152 | value = switch[0] |
| 1153 | value += link[0] |
| 1154 | main.log.info(self.name + ": \n-----\n%s%s-----\n" % ( switch[1], link[1]) ) |
| 1155 | if value != 0: |
| 1156 | return main.FALSE |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1157 | else: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1158 | # "PASS" |
| 1159 | return main.TRUE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1160 | except pexpect.EOF: |
| 1161 | main.log.error(self.name + ": EOF exception found") |
| 1162 | main.log.error(self.name + ": " + self.handle.before) |
| 1163 | main.cleanup() |
| 1164 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1165 | except: |
| 1166 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1167 | main.log.error( traceback.print_exc() ) |
| 1168 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1169 | main.cleanup() |
| 1170 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1171 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1172 | |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 1173 | def git_pull(self, comp1=""): |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1174 | ''' |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1175 | Assumes that "git pull" works without login |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 1176 | |
| 1177 | This function will perform a git pull on the ONOS instance. |
| 1178 | If used as git_pull("NODE") it will do git pull + NODE. This is |
| 1179 | for the purpose of pulling from other nodes if necessary. |
| 1180 | |
| 1181 | Otherwise, this function will perform a git pull in the |
| 1182 | ONOS repository. If it has any problems, it will return main.ERROR |
| 1183 | If it successfully does a git_pull, it will return a 1. |
| 1184 | If it has no updates, it will return a 0. |
| 1185 | |
Jon Hall | d8dc577 | 2014-04-08 16:26:29 -0700 | [diff] [blame] | 1186 | ''' |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1187 | try: |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 1188 | # main.log.info(self.name + ": Stopping ONOS") |
| 1189 | #self.stop() |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1190 | self.handle.sendline("cd " + self.home) |
| 1191 | self.handle.expect("ONOS\$") |
| 1192 | if comp1=="": |
| 1193 | self.handle.sendline("git pull") |
| 1194 | else: |
| 1195 | self.handle.sendline("git pull " + comp1) |
| 1196 | |
| 1197 | uptodate = 0 |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1198 | i=self.handle.expect(['fatal', |
| 1199 | 'Username\sfor\s(.*):\s', |
| 1200 | '\sfile(s*) changed,\s', |
| 1201 | 'Already up-to-date', |
| 1202 | 'Aborting', |
| 1203 | 'You\sare\snot\scurrently\son\sa\sbranch', |
| 1204 | 'You\sasked\sme\sto\spull\swithout\stelling\sme\swhich\sbranch\syou', |
| 1205 | 'Pull\sis\snot\spossible\sbecause\syou\shave\sunmerged\sfiles', |
| 1206 | pexpect.TIMEOUT], |
| 1207 | timeout=300) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1208 | #debug |
| 1209 | #main.log.report(self.name +": \n"+"git pull response: " + str(self.handle.before) + str(self.handle.after)) |
| 1210 | if i==0: |
| 1211 | main.log.error(self.name + ": Git pull had some issue...") |
| 1212 | return main.ERROR |
| 1213 | elif i==1: |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1214 | main.log.error(self.name + ": Git Pull Asking for username. ") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1215 | return main.ERROR |
| 1216 | elif i==2: |
| 1217 | main.log.info(self.name + ": Git Pull - pulling repository now") |
| 1218 | self.handle.expect("ONOS\$", 120) |
| 1219 | return 0 |
| 1220 | elif i==3: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1221 | main.log.info(self.name + ": Git Pull - Already up to date") |
| 1222 | return 1 |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1223 | elif i==4: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1224 | main.log.info(self.name + ": Git Pull - Aborting... Are there conflicting git files?") |
| 1225 | return main.ERROR |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1226 | elif i==5: |
Jon Hall | 5a8aac6 | 2014-06-03 09:30:21 -0700 | [diff] [blame] | 1227 | main.log.info(self.name + ": Git Pull - You are not currently on a branch so git pull failed!") |
| 1228 | return main.ERROR |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1229 | elif i==6: |
Jon Hall | 847cfad | 2014-09-03 14:10:08 -0700 | [diff] [blame] | 1230 | main.log.info(self.name + ": Git Pull - You have not configured an upstream branch to pull from. Git pull failed!") |
| 1231 | return main.ERROR |
Jon Hall | 7dae6cf | 2014-09-11 15:09:48 -0700 | [diff] [blame] | 1232 | elif i==7: |
| 1233 | main.log.info(self.name + ": Git Pull - Pull is not possible because you have unmerged files.") |
| 1234 | return main.ERROR |
| 1235 | elif i==8: |
| 1236 | main.log.error(self.name + ": Git Pull - TIMEOUT") |
| 1237 | main.log.error(self.name + " Response was: " + str(self.handle.before)) |
| 1238 | return main.ERROR |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1239 | else: |
| 1240 | main.log.error(self.name + ": Git Pull - Unexpected response, check for pull errors") |
| 1241 | return main.ERROR |
| 1242 | except pexpect.EOF: |
| 1243 | main.log.error(self.name + ": EOF exception found") |
| 1244 | main.log.error(self.name + ": " + self.handle.before) |
| 1245 | main.cleanup() |
| 1246 | main.exit() |
| 1247 | except: |
| 1248 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1249 | main.log.error( traceback.print_exc() ) |
| 1250 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1251 | main.cleanup() |
| 1252 | main.exit() |
admin | e0eeea2 | 2014-04-14 10:22:46 -0700 | [diff] [blame] | 1253 | #******************************************************** |
| 1254 | |
| 1255 | |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 1256 | |
| 1257 | |
| 1258 | def git_checkout(self, branch="onos13integration"): |
| 1259 | ''' |
| 1260 | Assumes that "git pull" works without login |
| 1261 | |
| 1262 | This function will perform a git pull on the ONOS instance. |
| 1263 | If used as git_pull("NODE") it will do git pull + NODE. This is |
| 1264 | for the purpose of pulling from other nodes if necessary. |
| 1265 | |
| 1266 | Otherwise, this function will perform a git pull in the |
| 1267 | ONOS repository. If it has any problems, it will return main.ERROR |
| 1268 | If it successfully does a git_pull, it will return a 1. |
| 1269 | If it has no updates, it will return a 0. |
| 1270 | |
| 1271 | ''' |
| 1272 | try: |
| 1273 | # main.log.info(self.name + ": Stopping ONOS") |
| 1274 | #self.stop() |
| 1275 | self.handle.sendline("cd " + self.home) |
| 1276 | self.handle.expect("ONOS\$") |
| 1277 | if branch != 'master': |
| 1278 | #self.handle.sendline('git stash') |
| 1279 | #self.handle.expect('ONOS\$') |
| 1280 | #print "After issuing git stash cmnd: ", self.handle.before |
| 1281 | cmd = "git checkout "+branch |
| 1282 | print "checkout cmd = ", cmd |
| 1283 | self.handle.sendline(cmd) |
| 1284 | uptodate = 0 |
| 1285 | i=self.handle.expect(['fatal','Username\sfor\s(.*):\s','Already\son\s\'onos13integration\'','Switched\sto\sbranch\s\'onos13integration\'', pexpect.TIMEOUT],timeout=60) |
| 1286 | else: |
| 1287 | #self.handle.sendline('git stash apply') |
| 1288 | #self.handle.expect('ONOS\$') |
| 1289 | #print "After issuing git stash apply cmnd: ", self.handle.before |
| 1290 | cmd = "git checkout "+branch |
| 1291 | print "checkout cmd = ", cmd |
| 1292 | self.handle.sendline(cmd) |
| 1293 | uptodate = 0 |
| 1294 | switchedToMaster = 0 |
| 1295 | i=self.handle.expect(['fatal','Username\sfor\s(.*):\s','Already\son\s\'master\'','Switched\sto\sbranch\s\'master\'', pexpect.TIMEOUT],timeout=60) |
| 1296 | |
| 1297 | |
| 1298 | if i==0: |
| 1299 | main.log.error(self.name + ": Git checkout had some issue...") |
| 1300 | return main.ERROR |
| 1301 | elif i==1: |
| 1302 | main.log.error(self.name + ": Git checkout Asking for username!!! BADD!") |
| 1303 | return main.ERROR |
| 1304 | elif i==2: |
| 1305 | main.log.info(self.name + ": Git Checkout %s : Already on this branch" %branch) |
| 1306 | self.handle.expect("ONOS\$") |
| 1307 | print "after checkout cmd = ", self.handle.before |
| 1308 | switchedToMaster = 1 |
| 1309 | return 1 |
| 1310 | elif i==3: |
| 1311 | main.log.info(self.name + ": Git checkout %s - Switched to this branch" %branch) |
| 1312 | self.handle.expect("ONOS\$") |
| 1313 | print "after checkout cmd = ", self.handle.before |
| 1314 | switchedToMaster = 1 |
| 1315 | return 1 |
| 1316 | elif i==4: |
| 1317 | main.log.error(self.name + ": Git Checkout- TIMEOUT") |
| 1318 | main.log.error(self.name + " Response was: " + str(self.handle.before)) |
| 1319 | return main.ERROR |
| 1320 | else: |
| 1321 | main.log.error(self.name + ": Git Checkout - Unexpected response, check for pull errors") |
| 1322 | return main.ERROR |
| 1323 | |
| 1324 | except pexpect.EOF: |
| 1325 | main.log.error(self.name + ": EOF exception found") |
| 1326 | main.log.error(self.name + ": " + self.handle.before) |
| 1327 | main.cleanup() |
| 1328 | main.exit() |
| 1329 | except: |
| 1330 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1331 | main.log.error( traceback.print_exc() ) |
| 1332 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1333 | main.cleanup() |
| 1334 | main.exit() |
| 1335 | #******************************************************** |
| 1336 | self.handle.sendline("git branch") |
| 1337 | self.handle.expect("ONOS\$") |
| 1338 | print "git branch output = ", self.handle.before |
| 1339 | print "*****************************************" |
| 1340 | self.handle.sendline('cd\.\.') |
| 1341 | self.handle.expect("\$") |
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
admin | 7373a81 | 2014-04-16 09:49:02 -0700 | [diff] [blame] | 1350 | def git_compile(self): |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1351 | ''' |
| 1352 | Compiles ONOS |
| 1353 | First runs mvn clean then mvn compile |
| 1354 | ''' |
| 1355 | try: |
| 1356 | main.log.info(self.name + ": mvn clean") |
admin | 8fc0282 | 2014-04-16 13:31:23 -0700 | [diff] [blame] | 1357 | self.handle.sendline("cd " + self.home) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1358 | self.handle.sendline("mvn clean") |
| 1359 | while 1: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1360 | i=self.handle.expect(['There\sis\sinsufficient\smemory\sfor\sthe\sJava\sRuntime\sEnvironment\sto\scontinue','BUILD\sFAILURE','BUILD\sSUCCESS','ONOS\$',pexpect.TIMEOUT],timeout=30) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1361 | if i == 0: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1362 | main.log.error(self.name + ":There is insufficient memory for the Java Runtime Environment to continue.") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1363 | return main.FALSE |
| 1364 | elif i == 1: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1365 | main.log.error(self.name + ": Clean failure!") |
| 1366 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1367 | elif i == 2: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1368 | main.log.info(self.name + ": Clean success!") |
| 1369 | elif i == 3: |
admin | 8fc0282 | 2014-04-16 13:31:23 -0700 | [diff] [blame] | 1370 | main.log.info(self.name + ": Clean complete") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1371 | break; |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1372 | elif i == 4: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1373 | main.log.error(self.name + ": mvn clean TIMEOUT!") |
| 1374 | return main.FALSE |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1375 | else: |
| 1376 | main.log.error(self.name + ": unexpected response from mvn clean") |
| 1377 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1378 | |
| 1379 | main.log.info(self.name + ": mvn compile") |
| 1380 | self.handle.sendline("mvn compile") |
| 1381 | while 1: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1382 | i=self.handle.expect(['There\sis\sinsufficient\smemory\sfor\sthe\sJava\sRuntime\sEnvironment\sto\scontinue','BUILD\sFAILURE','BUILD\sSUCCESS','ONOS\$',pexpect.TIMEOUT],timeout=60) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1383 | if i == 0: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1384 | main.log.error(self.name + ":There is insufficient memory for the Java Runtime Environment to continue.") |
| 1385 | return main.FALSE |
| 1386 | if i == 1: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1387 | main.log.error(self.name + ": Build failure!") |
| 1388 | return main.FALSE |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1389 | elif i == 2: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1390 | main.log.info(self.name + ": Build success!") |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1391 | elif i == 3: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1392 | main.log.info(self.name + ": Build complete") |
Jon Hall | 010f541 | 2014-05-21 15:10:12 -0700 | [diff] [blame] | 1393 | self.handle.expect("\$", timeout=60) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1394 | return main.TRUE |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1395 | elif i == 4: |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1396 | main.log.error(self.name + ": mvn compile TIMEOUT!") |
| 1397 | return main.FALSE |
| 1398 | else: |
Jon Hall | 1636f94 | 2014-04-17 10:07:23 -0700 | [diff] [blame] | 1399 | main.log.error(self.name + ": unexpected response from mvn compile") |
| 1400 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1401 | except pexpect.EOF: |
| 1402 | main.log.error(self.name + ": EOF exception found") |
| 1403 | main.log.error(self.name + ": " + self.handle.before) |
| 1404 | main.cleanup() |
| 1405 | main.exit() |
| 1406 | except: |
| 1407 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1408 | main.log.error( traceback.print_exc() ) |
| 1409 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1410 | main.cleanup() |
| 1411 | main.exit() |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 1412 | |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1413 | def tcpdump(self, intf = "eth0"): |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1414 | ''' |
| 1415 | Runs tpdump on an intferface and saves in onos-logs under the ONOS home directory |
| 1416 | intf can be specified, or the default eth0 is used |
| 1417 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1418 | try: |
| 1419 | self.handle.sendline("") |
| 1420 | self.handle.expect("\$") |
Jon Hall | 26f316b | 2014-04-11 11:21:25 -0700 | [diff] [blame] | 1421 | self.handle.sendline("sudo tcpdump -n -i "+ intf + " -s0 -w " + self.home +"/onos-logs/tcpdump &") |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1422 | i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT],timeout=10) |
| 1423 | if i == 0: |
| 1424 | main.log.error(self.name + ": tcpdump - No such device exists. tcpdump attempted on: " + intf) |
| 1425 | return main.FALSE |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1426 | elif i == 1: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1427 | main.log.info(self.name + ": tcpdump started on " + intf) |
| 1428 | return main.TRUE |
James Lee | c9cacaf | 2014-04-08 09:17:39 -0700 | [diff] [blame] | 1429 | elif i == 2: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1430 | main.log.error(self.name + ": tcpdump command timed out! Check interface name, given interface was: " + intf) |
| 1431 | return main.FALSE |
| 1432 | else: |
| 1433 | main.log.error(self.name + ": tcpdump - unexpected response") |
| 1434 | return main.FALSE |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1435 | except pexpect.EOF: |
| 1436 | main.log.error(self.name + ": EOF exception found") |
| 1437 | main.log.error(self.name + ": " + self.handle.before) |
| 1438 | main.cleanup() |
| 1439 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1440 | except: |
| 1441 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1442 | main.log.error( traceback.print_exc() ) |
| 1443 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1444 | main.cleanup() |
| 1445 | main.exit() |
| 1446 | |
admin | 4a58db9 | 2013-09-30 12:04:54 -0700 | [diff] [blame] | 1447 | def kill_tcpdump(self): |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1448 | ''' |
| 1449 | Kills any tcpdump processes running |
| 1450 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1451 | try: |
| 1452 | self.handle.sendline("") |
| 1453 | self.handle.expect("\$") |
| 1454 | self.handle.sendline("sudo kill -9 `ps -ef | grep \"tcpdump -n\" | grep -v grep | awk '{print $2}'`") |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1455 | except pexpect.EOF: |
| 1456 | main.log.error(self.name + ": EOF exception found") |
| 1457 | main.log.error(self.name + ": " + self.handle.before) |
| 1458 | main.cleanup() |
| 1459 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1460 | except: |
| 1461 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1462 | main.log.error( traceback.print_exc() ) |
| 1463 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1464 | main.cleanup() |
| 1465 | main.exit() |
| 1466 | |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1467 | def find_host(self,RestIP,RestPort,RestAPI,hostMAC): |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 1468 | retcode = 0 # number of hosts found with given MAC |
| 1469 | retswitch = [] # Switch DPID's of hosts found with MAC |
| 1470 | retport = [] # Switch port connected to to hosts found with MAC |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1471 | foundHost = [] |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1472 | try: |
Jon Hall | 2f42a67 | 2014-05-28 10:13:18 -0700 | [diff] [blame] | 1473 | ##### device rest API is: 'host:8080/wm/onos/topology/switches' ### |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1474 | url ="http://%s:%s%s" %(RestIP,RestPort,RestAPI) |
| 1475 | |
| 1476 | try: |
| 1477 | command = "curl -s %s" % (url) |
| 1478 | result = os.popen(command).read() |
| 1479 | parsedResult = json.loads(result) |
| 1480 | # print parsedResult |
| 1481 | except: |
| 1482 | print "REST IF %s has issue" % command |
| 1483 | parsedResult = "" |
| 1484 | |
| 1485 | if parsedResult == "": |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1486 | return (retcode, "Rest API has an error", retport) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1487 | else: |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1488 | for host in enumerate(parsedResult): |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1489 | if (host[1] != []): |
| 1490 | try: |
| 1491 | foundHost = host[1]['mac'] |
| 1492 | except: |
| 1493 | print "Error in detecting MAC address." |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1494 | if foundHost == hostMAC: |
| 1495 | for switch in enumerate(host[1]['attachmentPoints']): |
| 1496 | retswitch.append(switch[1]['dpid']) |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1497 | retport.append(switch[1]['portNumber']) |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1498 | retcode = retcode +1 |
| 1499 | foundHost ='' |
| 1500 | ''' |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1501 | for switch in enumerate(parsedResult): |
| 1502 | for port in enumerate(switch[1]['ports']): |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 1503 | if ( port[1]['hosts'] != [] ): |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1504 | try: |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 1505 | foundHost = port[1]['hosts'][0]['ipv4addresses'][0]['ipv4'] |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1506 | except: |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1507 | print "Error in detecting MAC address." |
| 1508 | if foundHost == hostMAC: |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1509 | retswitch.append(switch[1]['dpid']) |
| 1510 | retport.append(port[1]['desc']) |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 1511 | retmac.append(port[1]['hosts'][0]['mac']) |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1512 | retcode = retcode +1 |
Jon Hall | f15f785 | 2014-05-20 10:37:23 -0700 | [diff] [blame] | 1513 | foundHost ='' |
| 1514 | ''' |
| 1515 | return(retcode, retswitch, retport) |
Jon Hall | ae05dc2 | 2014-04-16 10:56:28 -0700 | [diff] [blame] | 1516 | except pexpect.EOF: |
| 1517 | main.log.error(self.name + ": EOF exception found") |
| 1518 | main.log.error(self.name + ": " + self.handle.before) |
| 1519 | main.cleanup() |
| 1520 | main.exit() |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 1521 | except: |
| 1522 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1523 | main.log.error( traceback.print_exc() ) |
| 1524 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1525 | main.cleanup() |
| 1526 | main.exit() |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1527 | |
| 1528 | def check_exceptions(self): |
| 1529 | ''' |
| 1530 | Greps the logs for "xception" |
| 1531 | ''' |
| 1532 | try: |
| 1533 | output = '' |
| 1534 | self.handle.sendline("") |
Jon Hall | a78cf9a | 2014-05-16 10:49:30 -0700 | [diff] [blame] | 1535 | i = self.handle.expect(["\$",pexpect.EOF,pexpect.TIMEOUT]) |
Jon Hall | 2c4f554 | 2014-08-05 13:45:29 -0700 | [diff] [blame] | 1536 | main.log.warn("first expect response: " +str(i)) |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1537 | self.handle.sendline("cd "+self.home+"/onos-logs") |
Jon Hall | 2c4f554 | 2014-08-05 13:45:29 -0700 | [diff] [blame] | 1538 | i = self.handle.expect(["onos-logs\$",pexpect.EOF,pexpect.TIMEOUT]) |
| 1539 | main.log.warn("second expect response: " +str(i)) |
| 1540 | |
| 1541 | self.handle.sendline("zgrep \"xception\" *.log *.log.gz *.stderr") |
| 1542 | #i = self.handle.expect(["\*.stdout",pexpect.EOF,pexpect.TIMEOUT]) |
Jon Hall | a78cf9a | 2014-05-16 10:49:30 -0700 | [diff] [blame] | 1543 | #main.log.warn("third expect response: " +str(i)) |
Jon Hall | 2c4f554 | 2014-08-05 13:45:29 -0700 | [diff] [blame] | 1544 | print self.handle.before |
| 1545 | print |
| 1546 | print self.handle.after |
| 1547 | i = self.handle.expect(["ONOS/onos-logs\$",pexpect.EOF,pexpect.TIMEOUT],timeout=120) |
| 1548 | main.log.warn("fourth expect response: " +str(i)) |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1549 | response = self.handle.before |
admin | 6903e46 | 2014-07-22 15:30:54 -0700 | [diff] [blame] | 1550 | print response |
Jon Hall | a78cf9a | 2014-05-16 10:49:30 -0700 | [diff] [blame] | 1551 | count = 0 |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1552 | print response |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1553 | for line in response.splitlines(): |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1554 | if re.search("gzip: \*\.log\.gz:", line): |
Jon Hall | 2c4f554 | 2014-08-05 13:45:29 -0700 | [diff] [blame] | 1555 | #gzip complaining about file not found |
Jon Hall | bb650fe | 2014-07-14 14:54:48 -0700 | [diff] [blame] | 1556 | pass |
Jon Hall | 724a2f4 | 2014-06-23 16:04:22 -0700 | [diff] [blame] | 1557 | elif re.search("log\.gz:",line): |
| 1558 | output+="Exceptions found in " + line + "\n" |
| 1559 | count +=1 |
Jon Hall | 2c4f554 | 2014-08-05 13:45:29 -0700 | [diff] [blame] | 1560 | elif re.search("log:", line): |
| 1561 | output +="Exceptions found in " + line + "\n" |
| 1562 | count +=1 |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1563 | elif re.search("std...:",line): |
| 1564 | output+="Exceptions found in " + line + "\n" |
Jon Hall | a78cf9a | 2014-05-16 10:49:30 -0700 | [diff] [blame] | 1565 | count +=1 |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1566 | else: |
| 1567 | pass |
| 1568 | #these should be the old logs |
admin | 1723f1c | 2014-05-19 16:08:39 -0700 | [diff] [blame] | 1569 | main.log.report(str(count) + " Exceptions were found on "+self.name) |
SeanCorcoran | 29b7054 | 2014-05-14 14:53:42 -0700 | [diff] [blame] | 1570 | return output |
| 1571 | except pexpect.TIMEOUT: |
| 1572 | main.log.error(self.name + ": Timeout exception found in check_exceptions function") |
| 1573 | except pexpect.EOF: |
| 1574 | main.log.error(self.name + ": EOF exception found") |
| 1575 | main.log.error(self.name + ": " + self.handle.before) |
| 1576 | main.cleanup() |
| 1577 | main.exit() |
| 1578 | except: |
| 1579 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1580 | main.log.error( traceback.print_exc() ) |
| 1581 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1582 | main.cleanup() |
| 1583 | main.exit() |
Ahmed El-Hassany | 41e70fd | 2014-07-02 14:59:36 -0700 | [diff] [blame] | 1584 | |
Ahmed El-Hassany | ab175ff | 2014-08-20 11:50:38 -0700 | [diff] [blame] | 1585 | |
Ahmed El-Hassany | 41e70fd | 2014-07-02 14:59:36 -0700 | [diff] [blame] | 1586 | def block_peer(self, ip_address): |
| 1587 | ''' |
| 1588 | Block traffic to the destination IP address. |
| 1589 | ''' |
| 1590 | try: |
| 1591 | for chain in ['INPUT', 'OUTPUT']: |
| 1592 | check_block_cmd = "sudo iptables -L %s -n | grep \"DROP.*%s\"" % (chain, ip_address) |
| 1593 | add_block_cmd = "sudo iptables -I %s 1 -s %s -j DROP" % (chain, ip_address) |
| 1594 | response1 = self.execute(cmd=check_block_cmd,prompt="\$",timeout=10) |
| 1595 | if ip_address in response1: |
| 1596 | main.log.error("Already blocked: %s" % response1) |
| 1597 | return main.TRUE |
| 1598 | response2 = self.execute(cmd=add_block_cmd,prompt="\$",timeout=10) |
| 1599 | main.log.info("add_block_cmd: %s" % response2) |
| 1600 | return main.TRUE |
| 1601 | except pexpect.EOF: |
| 1602 | main.log.error(self.name + ": EOF exception found") |
| 1603 | main.log.error(self.name + ": " + self.handle.before) |
| 1604 | main.cleanup() |
| 1605 | main.exit() |
| 1606 | except: |
| 1607 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1608 | main.log.error( traceback.print_exc() ) |
| 1609 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1610 | main.cleanup() |
| 1611 | main.exit() |
| 1612 | |
| 1613 | def unblock_peer(self, ip_address): |
| 1614 | ''' |
| 1615 | Unblock traffic to the destination IP address. |
| 1616 | ''' |
| 1617 | try: |
| 1618 | for chain in ['INPUT', 'OUTPUT']: |
| 1619 | # To make sure all rules are deleted in case there were multiple |
| 1620 | # installed in the iptables |
| 1621 | max_iterations = 10 |
| 1622 | for i in range(max_iterations): |
| 1623 | check_block_cmd = "sudo iptables -L %s -n | grep \"DROP.*%s\"" % (chain, ip_address) |
| 1624 | remove_block_cmd = "sudo iptables -D %s -s %s -j DROP" % (chain, ip_address) |
| 1625 | response1 = self.execute(cmd=check_block_cmd,prompt="\$",timeout=10) |
| 1626 | if ip_address not in response1: |
| 1627 | main.log.warn("Already unblocked: %s" % response1) |
| 1628 | return main.TRUE |
| 1629 | response2 = self.execute(cmd=remove_block_cmd,prompt="\$",timeout=10) |
| 1630 | main.log.info("remove_block_cmd: %s" % response2) |
| 1631 | return main.TRUE |
| 1632 | except pexpect.EOF: |
| 1633 | main.log.error(self.name + ": EOF exception found") |
| 1634 | main.log.error(self.name + ": " + self.handle.before) |
| 1635 | main.cleanup() |
| 1636 | main.exit() |
| 1637 | except: |
| 1638 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1639 | main.log.error( traceback.print_exc() ) |
| 1640 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1641 | main.cleanup() |
| 1642 | main.exit() |
Ahmed El-Hassany | ab175ff | 2014-08-20 11:50:38 -0700 | [diff] [blame] | 1643 | |
| 1644 | |
| 1645 | def unblock_all(self): |
| 1646 | ''' |
| 1647 | Remove all controller block rules |
| 1648 | ''' |
| 1649 | try: |
| 1650 | unblock_cmd = "sudo iptables --flush" |
| 1651 | response = self.execute(cmd=unblock_cmd,prompt="\$", timeout=10) |
| 1652 | return main.TRUE |
| 1653 | except pexpect.EOF: |
| 1654 | main.log.error(self.name + ": EOF exception found") |
| 1655 | main.log.error(self.name + ": " + self.handle.before) |
| 1656 | main.cleanup() |
| 1657 | main.exit() |
| 1658 | except: |
| 1659 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1660 | main.log.error( traceback.print_exc() ) |
| 1661 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 1662 | main.cleanup() |
| 1663 | main.exit() |
Jon Hall | 44a450f | 2014-09-12 13:24:48 -0700 | [diff] [blame] | 1664 | return main.ERROR |